Hi I am trying to create a PST reader application of Outlook with Ruby ruby-msg.
I have setup the repository and trying to run the code and it alsways shows the following error
lib/mapi/pst.rb:167:in `%': invalid value for Integer(): "\x17" (ArgumentError)
My Code is as follows
require 'mapi/pst'
pst = Mapi::Pst.new open('/ruby-msg-master/backup.pst')
p pst.header
Unable to find the solution what to do so that the issue resolved
It looks like you need Ruby 1.8.7, see this bug report.
Sorry at this point ruby 1.9 is not supported
So anything newer than 1.9, including 2.3, probably isn't supported either.
Looking at the code, only 1997 and 2003 seem to be supported.
Them gem is probably too old, and you might want to look for another tool (possibly in another language) to convert your pst to a plain text format (e.g. xml or csv).
Related
I have Ruby code that uses "keyword arguments" like so:
def run_cmd(command, arg1: true, arg2: nil)
...
end
When I run the code, it works as expected, but my IDE doesn't seem to know how to interpret this. It renders the formatting of my entire file incorrectly because of these keyword arguments. Are keyword arguments not supported by Eclipse's Dynamic Languages Toolkit? (I'm using DLTK version 2.0.0) If not, is there a different Eclipse plug-in I should be using for Ruby?
You don't even need to know anything about Ruby or DLTK to answer this question, just common sense is enough:
Keyword arguments were added in Ruby 2.0, which was released in honor of Ruby's 20th anniversary on February, 24th 2013. Eclipse DLTK 2.0.0 was released on June, 24th 2010, over ten years ago and almost three years before Ruby 2.0.
So, by the simple laws of phyics and some common sense, it is immediately clear that DLTK 2.0.0 cannot possibly support Ruby 2.0 keyword arguments, because they simply did not exist back then.
As a general rule, you should expect some breakage and limitations when using ten year old IDEs.
I'm trying to bulk scan some jpg files with barcodes on them. I've used the ruby bindings for the c++ port of xzing. When I have this file:
scanned by the Web-Version of Xzing (https://zxing.org/w/decode.jspx) everything turns out fine. When I try to scan this one in ruby (using https://github.com/glassechidna/zxing_cpp.rb) nothing is recognized. I already tried cranking up the contrast, but it did not help. It's not my ruby setup because it works for loads of other nearly identical codes. The only thing I can think of is any difference between the Java version and the C++ port, but this is absolute poking in the dark, I've started using zxing just today.
Could anyone get this code recognized in ruby? Thank you very much.
The gem you're using and/or it's dependencies our out of date. If you want to still use Ruby for your project, you can try using one of the online services in the comments for the decoding. You could either try to use the
mechanize gem or roll your own using other http ruby tools such as httparty or Ruby's Net::HTTP
How can I change the comment symbol in Ruby? It is normally #, but I want it to be a different character.
You could modify the parser definition in the source code, compile it and run with your custom Ruby binary, modifying any gems you want to use to match your new comment scheme.
You could write some type of preprocessor script to modify your comments in rb files to temporary files then launch ruby on those processed files.
Or you could deal with using #.
Propose your language change on the Ruby bug tracker, including:
Present a really strong use case, why you want to break 10s of millions of lines of existing code written by 10s of thousands of developers.
Create a proof-of-concept implementation for YARV, and ideally for the other implementations as well.
(Ideally) Create an automated migration tool.
Gather community consensus and support, respond to all questions and doubts.
Iff your proposal gets accepted, there needs to be a transition plan. It will probably look something like this:
When Ruby 2.4/3.0 gets released in December 2016, a deprecation notice will be added to the documentation.
When Ruby 2.5/3.1/4.0 gets released in December 2017, a warning will be added about the upcoming deprecation of #.
When Ruby 2.6/3.2/4.1/5.0 gets released in December 2018, a switch will be added that allows you to choose between # and your proposal, with the default being #.
When Ruby 2.7/3.3/4.2/5.1/6.0 gets released in December 2019, the default for the switch will be reversed.
When Ruby 2.8/3.4/4.3/5.2/6.1/7.0 gets released in December 2020, the switch will be removed, and your proposal will be the new comment character for Ruby.
Adoption of that version will probably be very slow, because of the massive backwards incompatibility your proposal induces, similar to Ruby 1.9 which took years to get adopted.
So, it's a lot of work for you, but sometime in 2021–2022, the Ruby community will have changed over to your proposal.
I'm using hpricot to read HTML. I got a segmentation fault error, I googled and some say upgrade to latest version of Ruby. I am using rails 2.3.2 and ruby 1.8.7. How to resolve this error?
I was trying to parse html pages with many unicode characters in them and Hpricot kept crashing. Finally, I used the monkey patch from sanitize and put it in the environment.rb for my rails application. There hasn't been a single crash since I added this patch:
http://github.com/rgrove/sanitize/blob/1e1dc9681de99e32dc166f591343dfa60fc1f648/lib/sanitize/monkeypatch/hpricot.rb
If you're free to choose your HTML parsing library, switch it.
Why, the creator of Hpricot, recently posted that you should better use Nokogiri instead of HPricot, nowadays.
You may also have a look at HTTParty.
On ruby 1.8.5 try using hpricot -v 0.6.161
That worked for me.
From memory, since I last used it about a year ago:
Hpricot stores attributes in a fixed-size buffer, and some frameworks generate outrageously long hashes in document attributes. There's some static field you can set before parsing that lets you set the size of this buffer.
I remember it being fairly prominent in the docs on the webpage, though of course it's gone now.
Well, based on your own question, I'd say "Upgrade to the latest version of Ruby". However, I've also had problems with hpricot segfaulting, which seemed to be related to my usage of threading.
This appears to be an outstanding issue on the bug list. I have experienced it to. My theory is has to do with the HTML structure or bad/corrupt character in the file but I have not found where exactly.
Here are the links to the issues:
http://github.com/why/hpricot/issues/#issue/10
http://github.com/why/hpricot/issues/#issue/4
I'm having the same segfault issue but sadly can't consult the issues Dave cited above, even via Google cache -- from what I've been googling the parse.rb segfaults have to do with encoded entities or alt character sets (accented characters perhaps)
The sanitize lib encountered the same issue and posted a monkeypatch here:
http://github.com/rgrove/sanitize/blob/1e1dc9681de99e32dc166f591343dfa60fc1f648/lib/sanitize/monkeypatch/hpricot.rb
Does anyone know of a library that I can use on OS X/Linux to parse Word files and output the content as HTML?
I've had a look at win32ole but as far as I can see it's for Windows only, although I could be wrong.
Any suggestions?
The Word document format (ignoring docx for the moment) is terrible and was constantly changing. IMHO that is why there are so few (read: zero) Ruby libraries out there to parse them.
What I recommend doing is using JRuby and some of the established Java libraries for reading the doc format. Google should help you out there: http://schmidt.devlib.org/java/libraries-word.html.
There is a Java project for reading MIcrosoft file formats, POI (http://poi.apache.org/) and they do have Ruby bindings (http://poi.apache.org/poi-ruby.html) but I'm not sure how up-to-date those are. On their site it says the Ruby bindings are for 1.8.2...