gini-api 0.9.3 → 0.9.4
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/README.md +4 -0
- data/lib/gini-api/document.rb +16 -0
- data/lib/gini-api/version.rb +1 -1
- data/spec/gini-api/document_spec.rb +82 -0
- 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: 0a949ae559fd91862b4eda06e33bd99d717e923c
|
4
|
+
data.tar.gz: ef662694c99fd59112f90c6e0a2b35a316e5e858
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 585493d99b5060412222a182df04d84a0613532826c5f2178380c061ffd943059ae76a74ea710bef0e42057d1c904039a95324b49f36b0af3cd87683f732d223
|
7
|
+
data.tar.gz: 02360f6508c2d1df34ddae1d969c16924f29d26412ed5ff46bda906c539eb741a257c5a43dc907a2b1b0ac9f7922acd561ad87a0e6d12e5011e4b16073c87046
|
data/README.md
CHANGED
data/lib/gini-api/document.rb
CHANGED
@@ -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, ...)
|
data/lib/gini-api/version.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2014-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth2
|