ocrsdk 0.1.1 → 0.1.2
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.
- data/VERSION +1 -1
- data/lib/ocrsdk/image.rb +1 -1
- data/spec/helpers/ocrsdk_helpers.rb +8 -8
- data/spec/ocrsdk/image_spec.rb +8 -8
- data/spec/ocrsdk/promise_spec.rb +3 -3
- data/spec/spec_helper.rb +1 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/ocrsdk/image.rb
CHANGED
@@ -19,7 +19,7 @@ class OCRSDK::Image < OCRSDK::AbstractEntity
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def as_pdf(languages)
|
22
|
-
xml_string = api_process_image @image_path, languages, :
|
22
|
+
xml_string = api_process_image @image_path, languages, :pdf_text_and_images, :document_conversion
|
23
23
|
|
24
24
|
OCRSDK::Promise.from_response xml_string
|
25
25
|
end
|
@@ -12,7 +12,7 @@ module OCRSDKHelpers
|
|
12
12
|
filesCount="10"
|
13
13
|
credits="10"
|
14
14
|
estimatedProcessingTime="3600"
|
15
|
-
resultUrl="http://
|
15
|
+
resultUrl="http://cloud.ocrsdk.com/result_url"
|
16
16
|
description="My first OCR task"/>
|
17
17
|
<task/>
|
18
18
|
</response>
|
@@ -31,7 +31,7 @@ module OCRSDKHelpers
|
|
31
31
|
filesCount="10"
|
32
32
|
credits="0"
|
33
33
|
estimatedProcessingTime="3600"
|
34
|
-
resultUrl="http://
|
34
|
+
resultUrl="http://cloud.ocrsdk.com/result_url"
|
35
35
|
description="My first OCR task"/>
|
36
36
|
<task/>
|
37
37
|
</response>
|
@@ -50,7 +50,7 @@ module OCRSDKHelpers
|
|
50
50
|
filesCount="10"
|
51
51
|
credits="10"
|
52
52
|
estimatedProcessingTime="3600"
|
53
|
-
resultUrl="http://
|
53
|
+
resultUrl="http://cloud.ocrsdk.com/result_url"
|
54
54
|
description="My first OCR task"/>
|
55
55
|
<task/>
|
56
56
|
</response>
|
@@ -69,7 +69,7 @@ module OCRSDKHelpers
|
|
69
69
|
filesCount="10"
|
70
70
|
credits="10"
|
71
71
|
estimatedProcessingTime="3600"
|
72
|
-
resultUrl="http://
|
72
|
+
resultUrl="http://cloud.ocrsdk.com/result_url"
|
73
73
|
description="My first OCR task"/>
|
74
74
|
<task/>
|
75
75
|
</response>
|
@@ -88,7 +88,7 @@ module OCRSDKHelpers
|
|
88
88
|
filesCount="10"
|
89
89
|
credits="10"
|
90
90
|
estimatedProcessingTime="3600"
|
91
|
-
resultUrl="http://
|
91
|
+
resultUrl="http://cloud.ocrsdk.com/result_url"
|
92
92
|
description="My first OCR task"/>
|
93
93
|
<task/>
|
94
94
|
</response>
|
@@ -96,9 +96,9 @@ module OCRSDKHelpers
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def mock_ocrsdk
|
99
|
-
|
100
|
-
|
101
|
-
|
99
|
+
stub_request(:post, /.*:.*@cloud.ocrsdk.com\/processImage/).to_return(body: process_image_response)
|
100
|
+
stub_request(:get, /.*:.*@cloud.ocrsdk.com\/getTaskStatus\?taskId=.*/).to_return(body: process_image_completed_response )
|
101
|
+
stub_request(:get, 'http://cloud.ocrsdk.com/result_url').to_return(body: 'meow')
|
102
102
|
end
|
103
103
|
|
104
104
|
end
|
data/spec/ocrsdk/image_spec.rb
CHANGED
@@ -10,7 +10,7 @@ describe OCRSDK::Image do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
describe ".as_text" do
|
13
|
-
subject { OCRSDK::Image.new
|
13
|
+
subject { OCRSDK::Image.new TestFiles.russian_jpg_path }
|
14
14
|
before { mock_ocrsdk }
|
15
15
|
|
16
16
|
it "should call api and return Promise" do
|
@@ -19,7 +19,7 @@ describe OCRSDK::Image do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
describe ".as_text_sync" do
|
22
|
-
subject { OCRSDK::Image.new
|
22
|
+
subject { OCRSDK::Image.new TestFiles.russian_jpg_path }
|
23
23
|
before { mock_ocrsdk }
|
24
24
|
|
25
25
|
it "should wait till Promise is done and return result" do
|
@@ -28,7 +28,7 @@ describe OCRSDK::Image do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
describe ".as_pdf" do
|
31
|
-
subject { OCRSDK::Image.new
|
31
|
+
subject { OCRSDK::Image.new TestFiles.russian_jpg_path }
|
32
32
|
before { mock_ocrsdk }
|
33
33
|
|
34
34
|
it "should call api and return Promise" do
|
@@ -37,7 +37,7 @@ describe OCRSDK::Image do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
describe ".as_pdf_sync" do
|
40
|
-
subject { OCRSDK::Image.new
|
40
|
+
subject { OCRSDK::Image.new TestFiles.russian_jpg_path }
|
41
41
|
before { mock_ocrsdk }
|
42
42
|
|
43
43
|
it "should wait till Promise is done and return result if output file isn't specified" do
|
@@ -53,11 +53,11 @@ describe OCRSDK::Image do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
describe ".api_process_image" do
|
56
|
-
subject { OCRSDK::Image.new
|
56
|
+
subject { OCRSDK::Image.new TestFiles.russian_jpg_path }
|
57
57
|
|
58
58
|
it "should raise UnsupportedLanguage on unsupported language" do
|
59
59
|
expect {
|
60
|
-
subject.instance_eval { api_process_image
|
60
|
+
subject.instance_eval { api_process_image TestFiles.russian_jpg_path, [:meow] }
|
61
61
|
}.to raise_error(OCRSDK::UnsupportedLanguage)
|
62
62
|
end
|
63
63
|
|
@@ -69,13 +69,13 @@ describe OCRSDK::Image do
|
|
69
69
|
|
70
70
|
it "should raise UnsupportedOutputFormat on unsupported output format" do
|
71
71
|
expect {
|
72
|
-
subject.instance_eval { api_process_image
|
72
|
+
subject.instance_eval { api_process_image TestFiles.russian_jpg_path, [:russian], :meow }
|
73
73
|
}.to raise_error(OCRSDK::UnsupportedOutputFormat)
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should raise UnsupportedProfile on unsupported profile" do
|
77
77
|
expect {
|
78
|
-
subject.instance_eval { api_process_image
|
78
|
+
subject.instance_eval { api_process_image TestFiles.russian_jpg_path, [:russian], :txt, :meow }
|
79
79
|
}.to raise_error(OCRSDK::UnsupportedProfile)
|
80
80
|
end
|
81
81
|
|
data/spec/ocrsdk/promise_spec.rb
CHANGED
@@ -15,7 +15,7 @@ describe OCRSDK::Promise do
|
|
15
15
|
|
16
16
|
its(:task_id) { should == '22345200-abe8-4f60-90c8-0d43c5f6c0f6' }
|
17
17
|
its(:status) { should == :submitted }
|
18
|
-
its(:result_url) { should == 'http://
|
18
|
+
its(:result_url) { should == 'http://cloud.ocrsdk.com/result_url' }
|
19
19
|
its(:estimate_processing_time) { should == 3600 }
|
20
20
|
its(:estimate_completion) { should == DateTime.parse("2001-01-01T13:18:22Z") + 3600.seconds }
|
21
21
|
end
|
@@ -46,7 +46,7 @@ describe OCRSDK::Promise do
|
|
46
46
|
|
47
47
|
its(:task_id) { should == '22345200-abe8-4f60-90c8-0d43c5f6c0f6' }
|
48
48
|
its(:status) { should == :submitted }
|
49
|
-
its(:result_url) { should == 'http://
|
49
|
+
its(:result_url) { should == 'http://cloud.ocrsdk.com/result_url' }
|
50
50
|
its(:estimate_processing_time) { should == 3600 }
|
51
51
|
its(:estimate_completion) { should == DateTime.parse("2001-01-01T13:18:22Z") + 3600.seconds }
|
52
52
|
end
|
@@ -94,7 +94,7 @@ describe OCRSDK::Promise do
|
|
94
94
|
|
95
95
|
it "should get file with coorect url and return its contents" do
|
96
96
|
RestClient.stub(:get) do |url|
|
97
|
-
url.to_s.should == "http://
|
97
|
+
url.to_s.should == "http://cloud.ocrsdk.com/result_url"
|
98
98
|
"meow"
|
99
99
|
end
|
100
100
|
RestClient.should_receive(:get).once
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ocrsdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|