rtesseract 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4de06a9d89550b8ed47bc7d71e077d567e171973
4
- data.tar.gz: 36e37acca4192274b6c842ba3ed027d9058a0a38
3
+ metadata.gz: e9b2dfc90438d1e2e9ee90d041b719d08bb5112e
4
+ data.tar.gz: a302dd6317004f7fee4708eed828122be5e844da
5
5
  SHA512:
6
- metadata.gz: f87eea8011952bc41de7a8baee0b0634b33a5998750957ca4de1f371ff0855098fc02fb9d39d0f0e42e286c2f6a9ad5a3f64171027720f59e7aed1e9f5ff3cbe
7
- data.tar.gz: 7cc5b71464674271004dd7c0a691d42f23045e2ea743dbce2f1753775c30ec9d527e9b9f0ed0cff3007d4a1ef9b4c7fef939d46221f74d9ce4575b3b80b33296
6
+ metadata.gz: 017f69392c7871f4836e89b8356638ded0218f7dbeeaa28972e6ac0ed0742aa0689dc5ea37322a0c76ca35ee0b962a7f192bb22772dbb02b9e4bb16cb1c3d2af
7
+ data.tar.gz: b4d4a37cb531597fa1ca9cf582ad0e107eaf2a8500ffdf51f1a87f9f0e8dc20ba9cb53a1247b94f9f80cc55407f556c98d63a6670525e9ccb5417ec7889cff95
data/README.rdoc CHANGED
@@ -70,6 +70,14 @@ Processors Options (_Rmagick_ is default)
70
70
 
71
71
  RTesseract.new("test.jpg", :processor => "none")
72
72
 
73
+ Or you can config default processor first:
74
+
75
+ RTesseract.configure do |config|
76
+ config.processor = "mini_magick"
77
+ end
78
+
79
+ RTesseract.new("test.jpg") # It will use mini_magick by default
80
+
73
81
  Language Options
74
82
 
75
83
  RTesseract.new("test.jpg", :lang => "deu")
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.2
1
+ 1.3.3
data/lib/rtesseract.rb CHANGED
@@ -33,6 +33,27 @@ class RTesseract
33
33
  'spa' => %w(sp)
34
34
  }
35
35
 
36
+ class << self
37
+ attr_accessor :configuration
38
+ end
39
+
40
+ def self.configure
41
+ self.configuration ||= Configuration.new
42
+ yield(configuration)
43
+ end
44
+
45
+ class Configuration
46
+ attr_accessor :processor, :lang, :psm
47
+
48
+ def initialize
49
+ @processor = 'rmagick'
50
+ end
51
+
52
+ def to_hash
53
+ {processor: @processor, lang: lang, psm: psm}
54
+ end
55
+ end
56
+
36
57
  def initialize(src = '', options = {})
37
58
  command_line_options(options)
38
59
  @value, @x, @y, @w, @h = [nil]
@@ -45,7 +66,8 @@ class RTesseract
45
66
  end
46
67
 
47
68
  def command_line_options(options)
48
- @options = options
69
+ default_config = RTesseract.configuration ? RTesseract.configuration.to_hash : {}
70
+ @options = default_config.merge(options)
49
71
  @command = @options.option(:command, default_command)
50
72
  @lang = @options.option(:lang, '')
51
73
  @psm = @options.option(:psm, nil)
data/rtesseract.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: rtesseract 1.3.2 ruby lib
5
+ # stub: rtesseract 1.3.3 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "rtesseract"
9
- s.version = "1.3.2"
9
+ s.version = "1.3.3"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Danilo Jeremias da Silva"]
14
- s.date = "2015-12-07"
14
+ s.date = "2016-03-03"
15
15
  s.description = "Ruby library for working with the Tesseract OCR."
16
16
  s.email = "dannnylo@gmail.com"
17
17
  s.extra_rdoc_files = [
@@ -38,7 +38,7 @@ describe 'Rtesseract' do
38
38
  #expect(RTesseract.new(@path.join('images', 'README.pdf').to_s, debug: true).to_s_without_spaces).to eql('')
39
39
  end
40
40
 
41
- it ' support diferent processors' do
41
+ it ' support different processors' do
42
42
  # Rmagick
43
43
  expect(RTesseract.new(@image_tif).to_s_without_spaces).to eql('43XF')
44
44
  expect(RTesseract.new(@image_tif, processor: 'rmagick').to_s_without_spaces).to eql('43XF')
@@ -56,6 +56,7 @@ describe 'Rtesseract' do
56
56
  expect(RTesseract.new(@image_tif, processor: 'none').to_s_without_spaces).to eql('43XF')
57
57
  end
58
58
 
59
+
59
60
  it ' change the image' do
60
61
  image = RTesseract.new(@image_tif)
61
62
  expect(image.to_s_without_spaces).to eql('43XF')
@@ -184,4 +185,33 @@ describe 'Rtesseract' do
184
185
 
185
186
  expect { rtesseract.remove_file(Pathname.new(Dir.tmpdir).join('test_not_exists')) }.to raise_error(RTesseract::TempFilesNotRemovedError)
186
187
  end
188
+
189
+ it ' support default config processors' do
190
+ # Rmagick
191
+ RTesseract.configure {|config| config.processor = 'rmagick' }
192
+ expect(RTesseract.new(@image_tif).processor.a_name?('rmagick')).to eql(true)
193
+
194
+ # MiniMagick
195
+ RTesseract.configure {|config| config.processor = 'mini_magick' }
196
+ expect(RTesseract.new(@image_tif).processor.a_name?('mini_magick')).to eql(true)
197
+
198
+ # QuickMagick
199
+ RTesseract.configure {|config| config.processor = 'quick_magick' }
200
+ expect(RTesseract.new(@image_tif).processor.a_name?('quick_magick')).to eql(true)
201
+
202
+ # NoneMagick
203
+ RTesseract.configure {|config| config.processor = 'none' }
204
+ expect(RTesseract.new(@image_tif).processor.a_name?('none')).to eql(true)
205
+
206
+ # overwrite default
207
+ RTesseract.configure {|config| config.processor = 'mini_magick' }
208
+ expect(RTesseract.new(@image_tif, processor: 'quick_magick').processor.a_name?('quick_magick')).to eql(true)
209
+
210
+ RTesseract.configure {|config| config.lang = 'portuguese' }
211
+ expect(RTesseract.new(@image_tif).lang).to eql(' -l por ')
212
+
213
+ RTesseract.configure {|config| config.psm = 7 }
214
+ expect(RTesseract.new(@image_tif).psm).to eql(' -psm 7 ')
215
+ end
216
+
187
217
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rtesseract
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danilo Jeremias da Silva
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-07 00:00:00.000000000 Z
11
+ date: 2016-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri