rtesseract 3.1.0 → 3.1.1

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
  SHA256:
3
- metadata.gz: 43dd931b6649c05a5cb484f3fc0548075d088e5682bbbea46d7ac3202a9b607c
4
- data.tar.gz: 1b300fa5a83f458c986dabde158b3ff31dfeed6e7c7c3c98a17812fdf62c4bbb
3
+ metadata.gz: 8e5a1940f2ac4c4429afaedc85c0d958159466285ebdd1fd25bd9942ef152a36
4
+ data.tar.gz: 3971293ecf3ff95addc2f67560c9214d82bdd42d53a836c05fb3e343f7110741
5
5
  SHA512:
6
- metadata.gz: 955b9c159f1a89d681e5add1151d79ad2f0f29fbcd65d5558cb08b4a856f5442b6dfd4ae157b57f5bad869dbf9690a13bd1784bb23a7068a7c8402c8abba2468
7
- data.tar.gz: daa3a7aa5ba7549c30f0bb85019c6197acec22854122887a8fd5693b52828f8c1b1210806c6d307f1109ddb784f13f090192884f8ae820941b444055df79de7e
6
+ metadata.gz: 810b41ddbd021094f5d41d5fde2a59aff0deb3c1d343e319f04e47a86f048e4030294af277017a0d694c89b5dd262431e78ed673228784a924602a1b00871f27
7
+ data.tar.gz: 5122bb30c21077fbf8d9dfee754cdce7a57d99572b391ade83d1f904661888a237cf097ec5fbaee81af58015e99c7b5e7ea20b2f30b235af5e679edea443685e
@@ -0,0 +1,31 @@
1
+ name: CI
2
+ on: [push]
3
+ jobs:
4
+ test:
5
+ runs-on: ubuntu-latest
6
+ strategy:
7
+ matrix:
8
+ ruby:
9
+ - '2.5.x'
10
+ - '2.6.x'
11
+ - '2.7.x'
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - name: Install tesseract-ocr
15
+ run: |
16
+ sudo add-apt-repository ppa:alex-p/tesseract-ocr -y
17
+ sudo apt-get update -q
18
+ sudo apt-get install tesseract-ocr tesseract-ocr-eng ghostscript -y
19
+ - name: Setup Ruby
20
+ uses: actions/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby }}
23
+ - name: Bundle
24
+ env:
25
+ MTSR_RAILS_VERSION: ${{ matrix.rails }}
26
+ run: |
27
+ gem uninstall -aIx bundler
28
+ gem install bundler
29
+ bundle install --jobs 4 --retry 3
30
+ - name: Test
31
+ run: bundle exec rake
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rtesseract (3.1.0)
4
+ rtesseract (3.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -3,8 +3,8 @@
3
3
  <a href='http://badge.fury.io/rb/rtesseract'>
4
4
  <img src="https://badge.fury.io/rb/rtesseract.png" alt="Gem Version" />
5
5
  </a>
6
- <a href='https://travis-ci.org/dannnylo/rtesseract'>
7
- <img src="https://travis-ci.org/dannnylo/rtesseract.png?branch=master" alt="Build Status" />
6
+ <a href='https://github.com/dannnylo/rtesseract/workflows/CI/badge.svg'>
7
+ <img src="https://github.com/dannnylo/rtesseract/workflows/CI/badge.svg" alt="Build Status" />
8
8
  </a>
9
9
  <a href='https://coveralls.io/r/dannnylo/rtesseract?branch=master'>
10
10
  <img src="https://coveralls.io/repos/dannnylo/rtesseract/badge.png?branch=master" alt="Coverage Status" />
@@ -6,10 +6,8 @@ require 'pathname'
6
6
 
7
7
  class RTesseract
8
8
  module Base
9
- def temp_file(ext = '')
10
- @rand_file ||= "rtesseract_#{SecureRandom.uuid}"
11
-
12
- Pathname.new(Dir.tmpdir).join("#{@rand_file}#{ext}").to_s
9
+ def temp_file_path
10
+ Pathname.new(Dir.tmpdir).join("rtesseract_#{SecureRandom.uuid}").to_s
13
11
  end
14
12
  end
15
13
  end
@@ -8,9 +8,9 @@ class RTesseract
8
8
  def run(source, errors, options)
9
9
  options.tessedit_create_hocr = 1
10
10
 
11
- RTesseract::Command.new(source, temp_file, errors, options).run
12
-
13
- parse(File.read(temp_file('.hocr')))
11
+ RTesseract::Command.new(source, temp_file_path, errors, options).run do |output_path|
12
+ parse(File.read("#{output_path}.hocr"))
13
+ end
14
14
  end
15
15
 
16
16
  def parse(content)
@@ -6,12 +6,12 @@ class RTesseract
6
6
 
7
7
  attr_reader :options
8
8
 
9
- def initialize(source, output, errors, options)
9
+ def initialize(source, output_path, errors, options)
10
10
  @source = source
11
- @output = output
11
+ @output_path = output_path
12
12
  @options = options
13
13
  @errors = errors
14
- @full_command = [options.command, @source, @output]
14
+ @full_command = [options.command, @source, @output_path]
15
15
  end
16
16
 
17
17
  def full_command
@@ -48,7 +48,11 @@ class RTesseract
48
48
 
49
49
  @errors.push(error)
50
50
 
51
- return output if status.success?
51
+ if status.success?
52
+ return yield(@output_path) if block_given?
53
+
54
+ return output
55
+ end
52
56
 
53
57
  raise RTesseract::Error, error
54
58
  end
@@ -7,9 +7,9 @@ class RTesseract
7
7
  def self.run(source, errors, options)
8
8
  options.tessedit_create_pdf = 1
9
9
 
10
- RTesseract::Command.new(source, temp_file, errors, options).run
11
-
12
- File.open(temp_file('.pdf'), 'r')
10
+ RTesseract::Command.new(source, temp_file_path, errors, options).run do |output_path|
11
+ File.open("#{output_path}.pdf", 'r')
12
+ end
13
13
  end
14
14
  end
15
15
  end
@@ -7,9 +7,9 @@ class RTesseract
7
7
  def self.run(source, errors, options)
8
8
  options.tessedit_create_tsv = 1
9
9
 
10
- RTesseract::Command.new(source, temp_file, errors, options).run
11
-
12
- File.open(temp_file('.tsv'), 'r')
10
+ RTesseract::Command.new(source, temp_file_path, errors, options).run do |output_path|
11
+ File.open("#{output_path}.tsv", 'r')
12
+ end
13
13
  end
14
14
  end
15
15
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class RTesseract
4
- VERSION = '3.1.0'
4
+ VERSION = '3.1.1'
5
5
  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: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danilo Jeremias da Silva
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-20 00:00:00.000000000 Z
11
+ date: 2020-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -74,11 +74,11 @@ extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - ".document"
77
+ - ".github/workflows/ci.yml"
77
78
  - ".gitignore"
78
79
  - ".hound.yml"
79
80
  - ".rspec"
80
81
  - ".rubocop.yml"
81
- - ".travis.yml"
82
82
  - CHANGELOG.md
83
83
  - CODE_OF_CONDUCT.md
84
84
  - Gemfile
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  - !ruby/object:Gem::Version
119
119
  version: '0'
120
120
  requirements: []
121
- rubygems_version: 3.0.6
121
+ rubygems_version: 3.0.8
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: Ruby library for working with the Tesseract OCR.
data/.travis.yml DELETED
@@ -1,17 +0,0 @@
1
- ---
2
-
3
- sudo: false
4
- dist: bionic
5
- language: ruby
6
- cache: bundler
7
-
8
- before_install:
9
- - sudo add-apt-repository ppa:alex-p/tesseract-ocr -y
10
- - sudo apt-get update -q
11
- - sudo apt-get install tesseract-ocr tesseract-ocr-eng ghostscript -y
12
- - gem install bundler
13
-
14
- rvm:
15
- - 2.5.5
16
- - 2.6.5
17
- - 2.7.0