Skip to content

Updated for ruby 1.9.x #4

Merged
merged 8 commits into from Jan 4, 2012

2 participants

@masom
masom commented Dec 28, 2011

Hello

This is an updated ruby-tesseract for 1.9.x

The gemfile has been fixed to properly reference the lib folder.
The file list no longer includes development-related files.

Before calling the convert utility, the argument list is escaped using Shellwords.

Cleans up the temporary text file.

@scottdavis
Owner

I like this pull request a lot but i wouldn't mind seeing some new test cases for these options you added

@scottdavis
Owner

also if your interested in working on this more ill give you commit I only used it for a small side project and i don't work on it very often

@masom
masom commented Dec 28, 2011

I'll add some more unit tests and take a look at the require statements, I was looking at how nokogiri and cover_me were loading up.

I plan on using this gem quite a bit in the near future, if Tesseract can be properly trained. I wouldn't mind commit access but I am just starting out on ruby. I would rather have somebody take a look at the changes I make/propose :)

@scottdavis
Owner
@scottdavis scottdavis commented on the diff Dec 28, 2011
tesseract.gemspec
s.description = %q{Ruby wrapper for google tesseract}
s.summary = %q{Ruby wrapper for google tesseract}
s.email = %q{jetviper21@gmail.com}
s.date = Date.today.to_s
- s.files = `git ls-files`.split("\n")
- s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
@scottdavis
Owner
scottdavis added a note Dec 28, 2011

don't remove this using git here is very common across all gems

@masom
masom added a note Dec 28, 2011

Okay, i'll revise the git command. It was adding all the files to the gem, including non-gem related ones.

@scottdavis
Owner
scottdavis added a note Dec 28, 2011

you are right this is a better approach i forgot i did this in compass https://github.com/chriseppstein/compass/blob/stable/compass.gemspec#L22-36

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@scottdavis scottdavis commented on an outdated diff Dec 28, 2011
lib/tesseract/process.rb
attr_reader :image
- attr_accessor :lang
- CONVERT_COMMAND = 'convert'
- TESSERACT_COMMAND = 'tesseract'
@scottdavis
Owner
scottdavis added a note Dec 28, 2011

use these constants in the defaults below it makes it less "magic"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@scottdavis scottdavis and 1 other commented on an outdated diff Dec 28, 2011
tesseract.gemspec
+ s.required_ruby_version = '>= 1.9.0'
@scottdavis
Owner
scottdavis added a note Dec 28, 2011

This is going to break backwards compatibility and the gem works fine in both 1.8.7 and 1.9.x i would like to keep 1.8.7 support

@masom
masom added a note Dec 28, 2011

Oh, seems like I misread about Shellwords being only in 1.9, will drop the requirement to the version Shellwords was included in the stdlib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@masom
masom commented Dec 28, 2011

All tests passes (aside from the DependencyCheck, never got them to fail)

@scottdavis
Owner

which OS are you on?

@masom
masom commented Dec 28, 2011

Fedora 16

@masom
masom commented Dec 28, 2011

1) Failure:
test: dependency imagemagic fails should throw exception. (TesseractTest) [/home/msamson/dev/ruby-tesseract/test/tesseract_test.rb:26]:
ImageMagick "convert" command not found! Make sure ImageMagick is installed and in the system path
Exception expected but nothing was raised.

2) Failure:
test: dependency os check fails windows should throw exception. (TesseractTest) [/home/msamson/dev/ruby->tesseract/test/tesseract_test.rb:11]:
Only Unix Based enviroments are supported Mac, Linux, etc.
Exception expected but nothing was raised.

3) Failure:
test: dependency tesseract fails should throw exception. (TesseractTest) [/home/msamson/dev/ruby-tesseract/test/tesseract_test.rb:37]:
"tesseract" command not found! Make sure tesseract is installed and in the system path
Exception expected but nothing was raised.

12 tests, 12 assertions, 3 failures, 0 errors, 0 skips

ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]

@scottdavis
Owner

and the tests for DependencyChecker arn't passing?

@masom
masom commented Dec 28, 2011

Both ruby 1.8.7 and 1.9.2 fails the DependencyChecker tests. All others pass.

@scottdavis
Owner
@masom
masom commented Dec 28, 2011

x86_64-linux

Seems it has to do with the manipulation of the RUBY_PLATFORM constant.

@masom
masom commented Dec 28, 2011

Otherwise, the changes works and passes tests on x86 and x86-64

I'm looking into the DependencyChecker but it was failing before my changes. Not a biggy and it should probably be removed and added in the Readme instead of checking at runtime.

@scottdavis
Owner
@scottdavis
Owner
@masom
masom commented Dec 28, 2011

ruby-1.9.2-p290 :001 > system "derp"
=> nil
ruby-1.9.2-p290 :002 > system "ps"
PID TTY TIME CMD
6443 pts/0 00:00:00 bash
9613 pts/0 00:00:00 ruby
9938 pts/0 00:00:00 ps
=> true

system returns nil when the command was not executed, we can raise on that. Will submit an update.

@scottdavis scottdavis merged commit c865813 into scottdavis:master Jan 4, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.