rtesseract 2.2.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. checksums.yaml +5 -5
  2. data/.document +1 -2
  3. data/.gitignore +12 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +13 -10
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +4 -17
  8. data/Gemfile.lock +40 -85
  9. data/LICENSE.txt +18 -17
  10. data/README.md +137 -0
  11. data/Rakefile +4 -48
  12. data/bin/console +14 -0
  13. data/bin/setup +8 -0
  14. data/lib/rtesseract.rb +22 -220
  15. data/lib/rtesseract/box.rb +15 -60
  16. data/lib/rtesseract/check.rb +14 -0
  17. data/lib/rtesseract/command.rb +41 -0
  18. data/lib/rtesseract/configuration.rb +15 -64
  19. data/lib/rtesseract/pdf.rb +18 -0
  20. data/lib/rtesseract/text.rb +9 -0
  21. data/lib/rtesseract/tsv.rb +18 -0
  22. data/lib/rtesseract/version.rb +3 -0
  23. data/rtesseract.gemspec +27 -98
  24. metadata +36 -85
  25. data/README.rdoc +0 -156
  26. data/VERSION +0 -1
  27. data/lib/processors/mini_magick.rb +0 -43
  28. data/lib/processors/none.rb +0 -34
  29. data/lib/processors/rmagick.rb +0 -46
  30. data/lib/rtesseract/blob.rb +0 -34
  31. data/lib/rtesseract/box_char.rb +0 -31
  32. data/lib/rtesseract/errors.rb +0 -21
  33. data/lib/rtesseract/mixed.rb +0 -54
  34. data/lib/rtesseract/processor.rb +0 -19
  35. data/lib/rtesseract/utils.rb +0 -44
  36. data/lib/rtesseract/uzn.rb +0 -47
  37. data/spec/configs/eng.user-words.txt +0 -13
  38. data/spec/images/README.pdf +0 -0
  39. data/spec/images/blank.tif +0 -0
  40. data/spec/images/mixed.tif +0 -0
  41. data/spec/images/orientation_reverse.png +0 -0
  42. data/spec/images/test with spaces.tif +0 -0
  43. data/spec/images/test-pdf.png +0 -0
  44. data/spec/images/test.bmp +0 -0
  45. data/spec/images/test.jpg +0 -0
  46. data/spec/images/test.png +0 -0
  47. data/spec/images/test.tif +0 -0
  48. data/spec/images/test1.tif +0 -0
  49. data/spec/images/test_words.png +0 -0
  50. data/spec/rtesseract_box_char_spec.rb +0 -82
  51. data/spec/rtesseract_box_spec.rb +0 -36
  52. data/spec/rtesseract_mixed_spec.rb +0 -49
  53. data/spec/rtesseract_spec.rb +0 -282
  54. data/spec/rtesseract_uzn_spec.rb +0 -56
  55. data/spec/spec_helper.rb +0 -21
@@ -1,56 +0,0 @@
1
- # encoding: UTF-8
2
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
-
4
- describe 'Rtesseract::Uzn' do
5
- before do
6
- @path = Pathname.new(__FILE__.gsub('rtesseract_uzn_spec.rb', '')).expand_path
7
- @image_tif = @path.join('images', 'mixed.tif').to_s
8
- end
9
-
10
- it 'should be instantiable' do
11
- expect(RTesseract::Uzn.new.class).to eql(RTesseract::Uzn)
12
- expect(RTesseract::Uzn.new(@image_tif).class).to eql(RTesseract::Uzn)
13
- end
14
-
15
- it 'should translate parts of the image to text from a block' do
16
- uzn_block = RTesseract::Uzn.new(@image_tif) do |image|
17
- image.area(x: 28, y: 19, w: 25, h: 25) # position of 4
18
- image.area(x: 180, y: 22, w: 20, h: 28) # position of 3
19
- image.area(x: 218, y: 22, w: 24, h: 28) # position of F
20
- image.area(x: 248, y: 24, w: 22, h: 22) # position of F
21
- end
22
-
23
- expect(uzn_block.to_s_without_spaces).to eql('43FF')
24
- end
25
-
26
- it 'should translate parts of the image to text from initializer options' do
27
- @areas = []
28
- @areas << { x: 28, y: 19, w: 25, h: 25 } # position of 4
29
- @areas << { x: 180, y: 22, w: 20, h: 28 } # position of 3
30
- @areas << { x: 218, y: 22, w: 24, h: 28 } # position of f
31
- @areas << { x: 248, y: 24, w: 22, h: 22 } # position of f
32
-
33
- uzn_block = RTesseract::Uzn.new(@image_tif, areas: @areas)
34
- expect(uzn_block.to_s_without_spaces).to eql('43FF')
35
- end
36
-
37
- it 'should handle a blank image' do
38
- @areas = []
39
- @areas << { x: 28, y: 19, w: 25, h: 25 } # position of 4
40
- @areas << { x: 180, y: 22, w: 20, h: 28 } # position of 3
41
- @areas << { x: 218, y: 22, w: 24, h: 28 } # position of f
42
- @areas << { x: 248, y: 24, w: 22, h: 22 } # position of f
43
- uzn_block = RTesseract::Uzn.new(@path.join('images', 'blank.tif').to_s, areas: @areas)
44
- expect(uzn_block.to_s_without_spaces).to eql('')
45
- end
46
-
47
- it ' get a error' do
48
- @areas = [{ x: 28, y: 19, w: 25, h: 25 }]
49
-
50
- uzn_block = RTesseract::Uzn.new(@path.join('images', 'test_not_exists.png').to_s, areas: @areas, psm: 7)
51
- expect { uzn_block.to_s_without_spaces }.to raise_error(RTesseract::ImageNotSelectedError)
52
-
53
- uzn_block = RTesseract::Uzn.new(@image_tif, areas: @areas, psm: 7, command: 'tesseract_error')
54
- expect { uzn_block.to_s }.to raise_error(RTesseract::ConversionError)
55
- end
56
- end
data/spec/spec_helper.rb DELETED
@@ -1,21 +0,0 @@
1
- # encoding: UTF-8
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- $LOAD_PATH.unshift(File.dirname(__FILE__))
4
- require 'rspec'
5
- require 'coveralls'
6
- require 'simplecov'
7
- SimpleCov.start do
8
- add_filter '/spec/'
9
- end
10
- Coveralls.wear!
11
-
12
- require 'rtesseract'
13
- # Requires supporting files with custom matchers and macros, etc,
14
- # in ./support/ and its subdirectories.
15
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
16
-
17
- RSpec.configure do |config|
18
- config.after(:each) do
19
- RTesseract.configuration = RTesseract::Configuration.new
20
- end
21
- end