gini-api 0.9.3 → 0.9.4

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: 48a332c434967ccd2d8906da4f64f7a8a27346b3
4
- data.tar.gz: a3143decf245e1ef61800716558726431d9601e3
3
+ metadata.gz: 0a949ae559fd91862b4eda06e33bd99d717e923c
4
+ data.tar.gz: ef662694c99fd59112f90c6e0a2b35a316e5e858
5
5
  SHA512:
6
- metadata.gz: 33f11fa2e20aefb5e51e68fa495445c1b5da7eb6f46612ef4ed3dcbc513d071753bd2241b0e8220c9b217cbfbbf141931927a17827c3813c1f359eb54741cee2
7
- data.tar.gz: 9819589db65cde5ddb460ac6e75887d1adf976be5bffc58707b5daf413b5999e4234e7d951d8615e02d5a0b07f219b37eba9346b13f47bb23763b9c81d8bf82c
6
+ metadata.gz: 585493d99b5060412222a182df04d84a0613532826c5f2178380c061ffd943059ae76a74ea710bef0e42057d1c904039a95324b49f36b0af3cd87683f732d223
7
+ data.tar.gz: 02360f6508c2d1df34ddae1d969c16924f29d26412ed5ff46bda906c539eb741a257c5a43dc907a2b1b0ac9f7922acd561ad87a0e6d12e5011e4b16073c87046
data/README.md CHANGED
@@ -57,6 +57,10 @@ doc.id
57
57
  # => "123456789-abcd-ef12-000000000000"
58
58
  doc.progress
59
59
  # => "COMPLETED"
60
+ doc.completed?
61
+ # => true
62
+ doc.successful?
63
+ # => true
60
64
  ```
61
65
 
62
66
  ### List
@@ -67,6 +67,22 @@ module Gini
67
67
  end
68
68
  end
69
69
 
70
+ # Indicate if the document has been processed
71
+ #
72
+ # @return [Boolean] true if progress == PENDING
73
+ #
74
+ def completed?
75
+ @progress != 'PENDING'
76
+ end
77
+
78
+ # Was the document processed successfully?
79
+ #
80
+ # @return [Boolean] true/false based on @progress
81
+ #
82
+ def successful?
83
+ @progress == 'COMPLETED'
84
+ end
85
+
70
86
  # Get processed document
71
87
  #
72
88
  # @return [data] The binary representation of the processed document (pdf, jpg, png, ...)
@@ -1,5 +1,5 @@
1
1
  module Gini
2
2
  module Api
3
- VERSION = "0.9.3"
3
+ VERSION = "0.9.4"
4
4
  end
5
5
  end
@@ -48,6 +48,8 @@ describe Gini::Api::Document do
48
48
  it { should respond_to(:extractions) }
49
49
  it { should respond_to(:layout) }
50
50
  it { should respond_to(:pages) }
51
+ it { should respond_to(:completed?) }
52
+ it { should respond_to(:successful?) }
51
53
 
52
54
  it 'does accept duration' do
53
55
  expect(document.duration).to be_nil
@@ -99,6 +101,86 @@ describe Gini::Api::Document do
99
101
 
100
102
  end
101
103
 
104
+ describe '#completed?' do
105
+
106
+ context 'with state = PENDING' do
107
+
108
+ let(:response) do
109
+ double('Response', {
110
+ status: 200,
111
+ headers: { 'content-type' => header },
112
+ body: {
113
+ progress: 'PENDING'
114
+ }.to_json
115
+ })
116
+ end
117
+
118
+ it do
119
+ expect(document.completed?).to be_false
120
+ end
121
+
122
+ end
123
+
124
+ context 'with state != PENDING' do
125
+
126
+ let(:response) do
127
+ double('Response', {
128
+ status: 200,
129
+ headers: { 'content-type' => header },
130
+ body: {
131
+ progress: 'COMPLETED'
132
+ }.to_json
133
+ })
134
+ end
135
+
136
+ it do
137
+ expect(document.completed?).to be_true
138
+ end
139
+
140
+ end
141
+
142
+ end
143
+
144
+ describe '#successful?' do
145
+
146
+ context 'with state = COMPLETED' do
147
+
148
+ let(:response) do
149
+ double('Response', {
150
+ status: 200,
151
+ headers: { 'content-type' => header },
152
+ body: {
153
+ progress: 'COMPLETED'
154
+ }.to_json
155
+ })
156
+ end
157
+
158
+ it do
159
+ expect(document.successful?).to be_true
160
+ end
161
+
162
+ end
163
+
164
+ context 'with state == ERROR' do
165
+
166
+ let(:response) do
167
+ double('Response', {
168
+ status: 200,
169
+ headers: { 'content-type' => header },
170
+ body: {
171
+ progress: 'ERROR'
172
+ }.to_json
173
+ })
174
+ end
175
+
176
+ it do
177
+ expect(document.successful?).to be_false
178
+ end
179
+
180
+ end
181
+
182
+ end
183
+
102
184
  describe '#processed' do
103
185
 
104
186
  let(:pd_response) do
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.3
4
+ version: 0.9.4
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-03-18 00:00:00.000000000 Z
11
+ date: 2014-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth2