ocr_space 0.2.7 → 0.2.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ocr_space/file_post.rb +4 -4
- data/lib/ocr_space/from_file.rb +15 -14
- data/lib/ocr_space/from_url.rb +12 -12
- data/lib/ocr_space/version.rb +1 -1
- data/lib/ocr_space.rb +3 -3
- data/ocr_space.gemspec +28 -28
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf750bb7ed29514efe3c1893e572e6bef6092b15
|
4
|
+
data.tar.gz: 1da64cddff8cd276648b7486bf712ca4ccd9c085
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91cae9df5deca49f245e39c2486d7429232468f22601e664b5565bf62000948817c714ba10022637f1e46f9b9e2b9e3aa1ba0a191b6b762ba96139adb5e7a44d
|
7
|
+
data.tar.gz: 4712b8920749d5197f4032329b01f1561870722f37b1ac6eee672e6fe72012d066d5be82fd3e2bb3d1436291b28fbe02d134cb02e3e20baa0068022f3d4d5d69
|
data/lib/ocr_space/file_post.rb
CHANGED
data/lib/ocr_space/from_file.rb
CHANGED
@@ -2,18 +2,19 @@ require 'ocr_space/file_post'
|
|
2
2
|
require 'fileutils'
|
3
3
|
|
4
4
|
module OcrSpace
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
5
|
+
class FromFile
|
6
|
+
attr_reader :data
|
7
|
+
def initialize(apikey: ENV['ocr_api_key'], language: 'eng', isOverlayRequired: false, files: nil, ocr_space: 'https://api.ocr.space/parse/image')
|
8
|
+
@file = File.new(files)
|
9
|
+
@data = OcrSpace::FilePost.post('/parse/image',
|
10
|
+
body: { apikey: apikey,
|
11
|
+
language: language,
|
12
|
+
isOverlayRequired: isOverlayRequired,
|
13
|
+
files: @file })
|
14
|
+
end
|
15
|
+
|
16
|
+
def text_data
|
17
|
+
data.parsed_response['ParsedResults'][0]['ParsedText']
|
18
|
+
end
|
19
|
+
end
|
19
20
|
end
|
data/lib/ocr_space/from_url.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
require 'httparty'
|
2
2
|
|
3
3
|
module OcrSpace
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
4
|
+
class FromUrl
|
5
|
+
attr_reader :data
|
6
|
+
def initialize(apikey: ENV['ocr_api_key'], language: 'eng', isOverlayRequired: false, url: nil, ocr_space: 'https://api.ocr.space/parse/image')
|
7
|
+
@data = HTTParty.post('https://api.ocr.space/parse/image',
|
8
|
+
body: { apikey: apikey,
|
9
|
+
language: language,
|
10
|
+
isOverlayRequired: isOverlayRequired,
|
11
|
+
url: url })
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
def text_data
|
15
|
+
data.parsed_response['ParsedResults'][0]['ParsedText']
|
16
|
+
end
|
16
17
|
end
|
17
|
-
end
|
18
18
|
end
|
data/lib/ocr_space/version.rb
CHANGED
data/lib/ocr_space.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'ocr_space/version'
|
2
|
+
require 'ocr_space/from_url'
|
3
|
+
require 'ocr_space/from_file'
|
data/ocr_space.gemspec
CHANGED
@@ -4,36 +4,36 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'ocr_space/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
spec.name = 'ocr_space'
|
8
|
+
spec.version = OcrSpace::VERSION
|
9
|
+
spec.authors = ['Suyesh Bhandari']
|
10
|
+
spec.email = ['suyeshb@gmail.com']
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
spec.summary = 'Free Online OCR for Ruby - Convert images to text '
|
13
|
+
spec.description = 'Free Online OCR for Ruby - Convert images to text '
|
14
|
+
spec.homepage = 'https://suyesh.github.io/ocr_space/'
|
15
|
+
spec.license = 'MIT'
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
21
|
+
else
|
22
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
23
|
+
'public gem pushes.'
|
24
|
+
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = 'exe'
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ['lib']
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
34
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
35
|
+
spec.add_dependency 'json'
|
36
|
+
spec.add_dependency 'httparty'
|
37
|
+
spec.add_dependency 'httmultiparty'
|
38
|
+
spec.add_dependency 'colorize'
|
39
39
|
end
|