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 +4 -4
- data/.github/workflows/ci.yml +31 -0
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/lib/rtesseract/base.rb +2 -4
- data/lib/rtesseract/box.rb +3 -3
- data/lib/rtesseract/command.rb +8 -4
- data/lib/rtesseract/pdf.rb +3 -3
- data/lib/rtesseract/tsv.rb +3 -3
- data/lib/rtesseract/version.rb +1 -1
- metadata +4 -4
- data/.travis.yml +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e5a1940f2ac4c4429afaedc85c0d958159466285ebdd1fd25bd9942ef152a36
|
4
|
+
data.tar.gz: 3971293ecf3ff95addc2f67560c9214d82bdd42d53a836c05fb3e343f7110741
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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://
|
7
|
-
|
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" />
|
data/lib/rtesseract/base.rb
CHANGED
@@ -6,10 +6,8 @@ require 'pathname'
|
|
6
6
|
|
7
7
|
class RTesseract
|
8
8
|
module Base
|
9
|
-
def
|
10
|
-
|
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
|
data/lib/rtesseract/box.rb
CHANGED
@@ -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,
|
12
|
-
|
13
|
-
|
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)
|
data/lib/rtesseract/command.rb
CHANGED
@@ -6,12 +6,12 @@ class RTesseract
|
|
6
6
|
|
7
7
|
attr_reader :options
|
8
8
|
|
9
|
-
def initialize(source,
|
9
|
+
def initialize(source, output_path, errors, options)
|
10
10
|
@source = source
|
11
|
-
@
|
11
|
+
@output_path = output_path
|
12
12
|
@options = options
|
13
13
|
@errors = errors
|
14
|
-
@full_command = [options.command, @source, @
|
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
|
-
|
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
|
data/lib/rtesseract/pdf.rb
CHANGED
@@ -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,
|
11
|
-
|
12
|
-
|
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
|
data/lib/rtesseract/tsv.rb
CHANGED
@@ -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,
|
11
|
-
|
12
|
-
|
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
|
data/lib/rtesseract/version.rb
CHANGED
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.
|
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-
|
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.
|
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
|