ocr_space 2.3.1 → 2.3.7

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: c6339702d2c10abd4c88dd545be7f4f08d307c7d
4
- data.tar.gz: d43e9b4249ce8c91247dc5b52fb19502b967363f
3
+ metadata.gz: 82e9caf423a3b44c18adf424a567cc443593a98e
4
+ data.tar.gz: a4fee5d67d88d24c1efc81d8039517b6b7cecb3b
5
5
  SHA512:
6
- metadata.gz: 9b8b556d7795a84e505f6ce73ec9840d94af61a1f6c27b59636b2f38e3d1f2580e4dda34ea99ddffc85c897faffd0a3582bf269523fcdf58b4384f40301c2451
7
- data.tar.gz: 1454956b44abf94bb8926f26663caf91c8c5fa91f78b5e7eb69fe858dda54807bcfbc36732a9a981f8235922daa9162ad37f1e310850ccb74f9b3862aeffdf40
6
+ metadata.gz: 33682b75048a98cf16bfa4e5a4d3fd07d8a2293f0eee6e22066302548953e65408446c40935e200ef5854abf408fa54f7515833b7bd2778b123899367ec6ae30
7
+ data.tar.gz: 6f14ecc312ac431c6960a49fd06529d78f3c26468ccf4e3104c7d84242a7eff843cf0f8e4831128f877a15827f7fe982823e3200c6ef641748a19b0fb2b24043
data/README.md CHANGED
@@ -53,6 +53,11 @@ result = resource.convert url: "http://bit.ly/2ih9aXt"
53
53
  puts result
54
54
  => #[{"TextOverlay"=>{"Lines"=>[], "HasOverlay"=>false, "Message"=>"Text overlay is not provided as it is not requested"}, "FileParseExitCode"=>1, "ParsedText"=>"If you want to find the secrets of the \r\nuniverse, think in terms of energy, \r\nfrequency and vibration. \r\nAZ QUOTES \r\n", "ErrorMessage"=>"", "ErrorDetails"=>""}]
55
55
 
56
+ result = resource.clean_convert url: "http://bit.ly/2ih9aXt"
57
+
58
+ puts result
59
+
60
+ => #If you want to find the secrets of the universe, think in terms of energy, frequency and vibration. AZ QUOTES
56
61
  ```
57
62
 
58
63
  #To convert images from file upload
@@ -65,6 +70,11 @@ puts result #Raw result
65
70
 
66
71
  => #{"TextOverlay"=>{"Lines"=>[], "HasOverlay"=>false, "Message"=>"Text overlay is not provided as it is not requested"}, "FileParseExitCode"=>1, "ParsedText"=>"If you want to find the secrets of the \r\nuniverse, think in terms of energy, \r\nfrequency and vibration. \r\nAZ QUOTES \r\n", "ErrorMessage"=>"", "ErrorDetails"=>""}
67
72
 
73
+ result = resource.clean_convert file: "/Users/suyesh/Desktop/nicola_tesla.jpg"
74
+
75
+ puts result
76
+
77
+ => #If you want to find the secrets of the universe, think in terms of energy, frequency and vibration. AZ QUOTES
68
78
  ```
69
79
 
70
80
  #COMMAND LINE INTERFACE ***BONUS***
@@ -1,16 +1,17 @@
1
1
  # !/usr/bin/env ruby
2
2
  require 'colorize'
3
-
3
+ require_relative "../lib/ocr_space"
4
4
  require_relative "../lib/ocr_space/convert"
5
5
 
6
+
6
7
  if ARGV.empty?
7
8
  puts "You need to mention the image path".colorize(:red)
8
9
  else
9
- begin
10
+ begin
10
11
  resource = OcrSpace::Resource.new
11
- result = resource.convert file: ARGV[0]
12
+ result = resource.clean_convert file: ARGV[0]
12
13
  puts result
13
- rescue
14
- puts "Something went wrong, Please try again.".colorize(:red)
14
+ rescue
15
+ puts "Something went wrong. Please try again.".colorize(:red)
15
16
  end
16
17
  end
@@ -1,5 +1,4 @@
1
1
  require 'ocr_space/file_post'
2
-
3
2
  module OcrSpace
4
3
  module Convert
5
4
  def convert(apikey: @api_key, language: 'eng', isOverlayRequired: false, file: nil, url: nil)
@@ -22,5 +21,26 @@ module OcrSpace
22
21
  "You need to Pass either file or url."
23
22
  end
24
23
  end
24
+
25
+ def clean_convert(apikey: @api_key, language: 'eng', isOverlayRequired: false, file: nil, url: nil)
26
+ if file
27
+ @files = File.new(file)
28
+ @data = OcrSpace::FilePost.post('/parse/image',
29
+ body: { apikey: apikey,
30
+ language: language,
31
+ isOverlayRequired: isOverlayRequired,
32
+ file: @files })
33
+ @data = @data.parsed_response['ParsedResults'][0]["ParsedText"].gsub(/\r|\n/, "")
34
+ elsif url
35
+ @data = HTTParty.post('https://api.ocr.space/parse/image',
36
+ body: { apikey: apikey,
37
+ language: language,
38
+ isOverlayRequired: isOverlayRequired,
39
+ url: url })
40
+ @data = @data.parsed_response['ParsedResults'][0]["ParsedText"].gsub(/\r|\n/, "")
41
+ else
42
+ "You need to Pass either file or url."
43
+ end
44
+ end
25
45
  end
26
46
  end
@@ -1,3 +1,3 @@
1
1
  module OcrSpace
2
- VERSION = '2.3.1'.freeze
2
+ VERSION = '2.3.7'.freeze
3
3
  end
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
34
34
 
35
35
  spec.add_development_dependency 'bundler', '~> 1.13'
36
36
  spec.add_development_dependency 'rake', '~> 10.0'
37
+ spec.add_development_dependency 'pry'
37
38
  spec.add_dependency 'json'
38
39
  spec.add_dependency 'httparty'
39
40
  spec.add_dependency 'httmultiparty'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocr_space
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Suyesh Bhandari
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-25 00:00:00.000000000 Z
11
+ date: 2017-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: json
43
57
  requirement: !ruby/object:Gem::Requirement