ocrsdk 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/ocrsdk/image.rb +7 -3
- data/spec/ocrsdk/image_spec.rb +3 -2
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/lib/ocrsdk/image.rb
CHANGED
@@ -49,8 +49,12 @@ private
|
|
49
49
|
profile: profile_to_s(profile))
|
50
50
|
uri = URI.join @url, '/processImage', "?#{params}"
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
retryable tries: OCRSDK.config.number_or_retries, on: OCRSDK::NetworkError, sleep: OCRSDK.config.retry_wait_time do
|
53
|
+
begin
|
54
|
+
RestClient.post uri.to_s, upload: { file: File.new(image_path, 'rb') }
|
55
|
+
rescue RestClient::ExceptionWithResponse
|
56
|
+
raise OCRSDK::NetworkError
|
57
|
+
end
|
58
|
+
end
|
55
59
|
end
|
56
60
|
end
|
data/spec/ocrsdk/image_spec.rb
CHANGED
@@ -6,6 +6,7 @@ describe OCRSDK::Image do
|
|
6
6
|
OCRSDK.setup do |config|
|
7
7
|
config.application_id = 'app_id'
|
8
8
|
config.password = 'pass'
|
9
|
+
config.retry_wait_time = 0
|
9
10
|
end
|
10
11
|
OCRSDK::Mock.success
|
11
12
|
end
|
@@ -68,9 +69,9 @@ describe OCRSDK::Image do
|
|
68
69
|
}.to raise_error(OCRSDK::UnsupportedProfile)
|
69
70
|
end
|
70
71
|
|
71
|
-
it "should raise NetworkError on problems with REST request" do
|
72
|
+
it "should raise NetworkError on problems with REST request, retry 3 times before failing" do
|
72
73
|
RestClient.stub(:post) {|url, params| raise RestClient::ExceptionWithResponse }
|
73
|
-
RestClient.should_receive(:post).
|
74
|
+
RestClient.should_receive(:post).exactly(3)
|
74
75
|
|
75
76
|
expect {
|
76
77
|
subject.instance_eval { api_process_image TestFiles.russian_jpg_path, [:russian] }
|