gini-api 0.9.4 → 0.9.5
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.
- checksums.yaml +4 -4
- data/lib/gini-api/client.rb +6 -4
- data/lib/gini-api/document.rb +1 -1
- data/lib/gini-api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9045dfe6c898a87b0c826c25105220e4f9456c7a
|
4
|
+
data.tar.gz: 6d602fd4cf03e9a79d479048477794dfcb8e8063
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a10e7a373e2253090c35b205ab6e5f32758ca93a4e6dbe47f1e18a32f1bd15ca3c5306abe77c3383342ba9ff5a7847185deca49c4825aaabc243b9d0ee7bee0
|
7
|
+
data.tar.gz: 731b1317a2b130db59aaa915c9bddd19b0c2f57521ac67b0c31fdef6c9b57fbf14c943fd09352794890805eb58ed4cf8cc9e1e75a3e8ac2b4698fa2952a73021
|
data/lib/gini-api/client.rb
CHANGED
@@ -143,6 +143,7 @@ module Gini
|
|
143
143
|
# Upload a document
|
144
144
|
#
|
145
145
|
# @param [String] file path of the document to upload
|
146
|
+
# @param [Float] interval Interval to poll progress
|
146
147
|
#
|
147
148
|
# @return [Gini::Api::Document] Return Gini::Api::Document object for uploaded document
|
148
149
|
#
|
@@ -151,7 +152,7 @@ module Gini
|
|
151
152
|
# @example Upload and monitor progress
|
152
153
|
# doc = api.upload('/tmp/myfile.pdf') { |d| puts "Progress: #{d.progress}" }
|
153
154
|
#
|
154
|
-
def upload(file, &block)
|
155
|
+
def upload(file, interval = 0.5, &block)
|
155
156
|
duration = Hash.new(0)
|
156
157
|
|
157
158
|
# Document upload
|
@@ -160,7 +161,7 @@ module Gini
|
|
160
161
|
# Start polling (0.5s) when document has been uploaded successfully
|
161
162
|
if response.status == 201
|
162
163
|
doc = Gini::Api::Document.new(self, response.headers['location'])
|
163
|
-
duration[:processing] = poll_document(doc, &block)
|
164
|
+
duration[:processing] = poll_document(doc, interval, &block)
|
164
165
|
|
165
166
|
duration[:total] = duration.values.inject(:+)
|
166
167
|
doc.duration = duration
|
@@ -271,14 +272,15 @@ module Gini
|
|
271
272
|
# Poll document and duration
|
272
273
|
#
|
273
274
|
# @param [Gini::Api::Document] doc Document instance to poll
|
275
|
+
# @param [Float] interval Polling interval for completion
|
274
276
|
#
|
275
277
|
# @return [Integer] Processing duration
|
276
278
|
#
|
277
|
-
def poll_document(doc, &block)
|
279
|
+
def poll_document(doc, interval, &block)
|
278
280
|
duration = 0
|
279
281
|
timeout(@processing_timeout) do
|
280
282
|
duration = Benchmark.realtime do
|
281
|
-
doc.poll(&block)
|
283
|
+
doc.poll(interval, &block)
|
282
284
|
end
|
283
285
|
end
|
284
286
|
duration
|
data/lib/gini-api/document.rb
CHANGED
data/lib/gini-api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gini-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Kerwin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth2
|