docraptor 1.1.0 → 1.2.0beta1
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 +5 -13
- data/.gitignore +38 -2
- data/.rspec +2 -0
- data/.swagger-codegen-ignore +32 -0
- data/.swagger-codegen/VERSION +1 -0
- data/.swagger-revision +1 -1
- data/CHANGELOG.md +3 -0
- data/Gemfile +5 -1
- data/LICENSE +4 -10
- data/README.md +5 -4
- data/Rakefile +9 -0
- data/docraptor.gemspec +34 -16
- data/docraptor.yaml +5 -1
- data/lib/docraptor.rb +12 -0
- data/lib/docraptor/api/doc_api.rb +40 -56
- data/lib/docraptor/api_client.rb +102 -35
- data/lib/docraptor/api_error.rb +19 -5
- data/lib/docraptor/configuration.rb +40 -1
- data/lib/docraptor/models/async_doc.rb +61 -22
- data/lib/docraptor/models/async_doc_status.rb +66 -32
- data/lib/docraptor/models/doc.rb +122 -54
- data/lib/docraptor/models/prince_options.rb +116 -81
- data/lib/docraptor/version.rb +13 -1
- data/script/fix_gemspec.rb +31 -0
- data/script/post_generate_language +3 -0
- data/spec/api/doc_api_spec.rb +83 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/async_doc_spec.rb +42 -0
- data/spec/models/async_doc_status_spec.rb +72 -0
- data/spec/models/doc_spec.rb +128 -0
- data/spec/models/prince_options_spec.rb +214 -0
- data/spec/spec_helper.rb +111 -0
- data/swagger-config.json +11 -3
- metadata +135 -112
@@ -1,6 +1,19 @@
|
|
1
|
+
=begin
|
2
|
+
#DocRaptor v1
|
3
|
+
|
4
|
+
#A native client library for the DocRaptor HTML to PDF/XLS service.
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
1
13
|
require 'date'
|
2
14
|
|
3
15
|
module DocRaptor
|
16
|
+
|
4
17
|
class PrinceOptions
|
5
18
|
# Set the baseurl for assets.
|
6
19
|
attr_accessor :baseurl
|
@@ -89,68 +102,60 @@ module DocRaptor
|
|
89
102
|
# In Prince 9.0 and up you can set the PDF profile.
|
90
103
|
attr_accessor :profile
|
91
104
|
|
105
|
+
class EnumAttributeValidator
|
106
|
+
attr_reader :datatype
|
107
|
+
attr_reader :allowable_values
|
108
|
+
|
109
|
+
def initialize(datatype, allowable_values)
|
110
|
+
@allowable_values = allowable_values.map do |value|
|
111
|
+
case datatype.to_s
|
112
|
+
when /Integer/i
|
113
|
+
value.to_i
|
114
|
+
when /Float/i
|
115
|
+
value.to_f
|
116
|
+
else
|
117
|
+
value
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def valid?(value)
|
123
|
+
!value || allowable_values.include?(value)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
92
127
|
# Attribute mapping from ruby-style variable name to JSON key.
|
93
128
|
def self.attribute_map
|
94
129
|
{
|
95
|
-
|
96
130
|
:'baseurl' => :'baseurl',
|
97
|
-
|
98
131
|
:'no_xinclude' => :'no_xinclude',
|
99
|
-
|
100
132
|
:'no_network' => :'no_network',
|
101
|
-
|
102
133
|
:'no_parallel_downloads' => :'no_parallel_downloads',
|
103
|
-
|
104
134
|
:'http_user' => :'http_user',
|
105
|
-
|
106
135
|
:'http_password' => :'http_password',
|
107
|
-
|
108
136
|
:'http_proxy' => :'http_proxy',
|
109
|
-
|
110
137
|
:'http_timeout' => :'http_timeout',
|
111
|
-
|
112
138
|
:'insecure' => :'insecure',
|
113
|
-
|
114
139
|
:'media' => :'media',
|
115
|
-
|
116
140
|
:'no_author_style' => :'no_author_style',
|
117
|
-
|
118
141
|
:'no_default_style' => :'no_default_style',
|
119
|
-
|
120
142
|
:'no_embed_fonts' => :'no_embed_fonts',
|
121
|
-
|
122
143
|
:'no_subset_fonts' => :'no_subset_fonts',
|
123
|
-
|
124
144
|
:'no_compress' => :'no_compress',
|
125
|
-
|
126
145
|
:'encrypt' => :'encrypt',
|
127
|
-
|
128
146
|
:'key_bits' => :'key_bits',
|
129
|
-
|
130
147
|
:'user_password' => :'user_password',
|
131
|
-
|
132
148
|
:'owner_password' => :'owner_password',
|
133
|
-
|
134
149
|
:'disallow_print' => :'disallow_print',
|
135
|
-
|
136
150
|
:'disallow_copy' => :'disallow_copy',
|
137
|
-
|
138
151
|
:'disallow_annotate' => :'disallow_annotate',
|
139
|
-
|
140
152
|
:'disallow_modify' => :'disallow_modify',
|
141
|
-
|
142
153
|
:'debug' => :'debug',
|
143
|
-
|
144
154
|
:'input' => :'input',
|
145
|
-
|
146
155
|
:'version' => :'version',
|
147
|
-
|
148
156
|
:'javascript' => :'javascript',
|
149
|
-
|
150
157
|
:'css_dpi' => :'css_dpi',
|
151
|
-
|
152
158
|
:'profile' => :'profile'
|
153
|
-
|
154
159
|
}
|
155
160
|
end
|
156
161
|
|
@@ -186,149 +191,166 @@ module DocRaptor
|
|
186
191
|
:'javascript' => :'BOOLEAN',
|
187
192
|
:'css_dpi' => :'Integer',
|
188
193
|
:'profile' => :'String'
|
189
|
-
|
190
194
|
}
|
191
195
|
end
|
192
196
|
|
197
|
+
# Initializes the object
|
198
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
193
199
|
def initialize(attributes = {})
|
194
200
|
return unless attributes.is_a?(Hash)
|
195
201
|
|
196
202
|
# convert string to symbol for hash key
|
197
|
-
attributes = attributes.
|
203
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
198
204
|
|
199
|
-
|
200
|
-
if attributes[:'baseurl']
|
205
|
+
if attributes.has_key?(:'baseurl')
|
201
206
|
self.baseurl = attributes[:'baseurl']
|
202
207
|
end
|
203
208
|
|
204
|
-
if attributes
|
209
|
+
if attributes.has_key?(:'no_xinclude')
|
205
210
|
self.no_xinclude = attributes[:'no_xinclude']
|
206
211
|
end
|
207
212
|
|
208
|
-
if attributes
|
213
|
+
if attributes.has_key?(:'no_network')
|
209
214
|
self.no_network = attributes[:'no_network']
|
210
215
|
end
|
211
216
|
|
212
|
-
if attributes
|
217
|
+
if attributes.has_key?(:'no_parallel_downloads')
|
213
218
|
self.no_parallel_downloads = attributes[:'no_parallel_downloads']
|
214
219
|
end
|
215
220
|
|
216
|
-
if attributes
|
221
|
+
if attributes.has_key?(:'http_user')
|
217
222
|
self.http_user = attributes[:'http_user']
|
218
223
|
end
|
219
224
|
|
220
|
-
if attributes
|
225
|
+
if attributes.has_key?(:'http_password')
|
221
226
|
self.http_password = attributes[:'http_password']
|
222
227
|
end
|
223
228
|
|
224
|
-
if attributes
|
229
|
+
if attributes.has_key?(:'http_proxy')
|
225
230
|
self.http_proxy = attributes[:'http_proxy']
|
226
231
|
end
|
227
232
|
|
228
|
-
if attributes
|
233
|
+
if attributes.has_key?(:'http_timeout')
|
229
234
|
self.http_timeout = attributes[:'http_timeout']
|
230
235
|
end
|
231
236
|
|
232
|
-
if attributes
|
237
|
+
if attributes.has_key?(:'insecure')
|
233
238
|
self.insecure = attributes[:'insecure']
|
234
239
|
end
|
235
240
|
|
236
|
-
if attributes
|
241
|
+
if attributes.has_key?(:'media')
|
237
242
|
self.media = attributes[:'media']
|
238
243
|
else
|
239
244
|
self.media = "print"
|
240
245
|
end
|
241
246
|
|
242
|
-
if attributes
|
247
|
+
if attributes.has_key?(:'no_author_style')
|
243
248
|
self.no_author_style = attributes[:'no_author_style']
|
244
249
|
end
|
245
250
|
|
246
|
-
if attributes
|
251
|
+
if attributes.has_key?(:'no_default_style')
|
247
252
|
self.no_default_style = attributes[:'no_default_style']
|
248
253
|
end
|
249
254
|
|
250
|
-
if attributes
|
255
|
+
if attributes.has_key?(:'no_embed_fonts')
|
251
256
|
self.no_embed_fonts = attributes[:'no_embed_fonts']
|
252
257
|
end
|
253
258
|
|
254
|
-
if attributes
|
259
|
+
if attributes.has_key?(:'no_subset_fonts')
|
255
260
|
self.no_subset_fonts = attributes[:'no_subset_fonts']
|
256
261
|
end
|
257
262
|
|
258
|
-
if attributes
|
263
|
+
if attributes.has_key?(:'no_compress')
|
259
264
|
self.no_compress = attributes[:'no_compress']
|
260
265
|
end
|
261
266
|
|
262
|
-
if attributes
|
267
|
+
if attributes.has_key?(:'encrypt')
|
263
268
|
self.encrypt = attributes[:'encrypt']
|
264
269
|
end
|
265
270
|
|
266
|
-
if attributes
|
271
|
+
if attributes.has_key?(:'key_bits')
|
267
272
|
self.key_bits = attributes[:'key_bits']
|
268
273
|
end
|
269
274
|
|
270
|
-
if attributes
|
275
|
+
if attributes.has_key?(:'user_password')
|
271
276
|
self.user_password = attributes[:'user_password']
|
272
277
|
end
|
273
278
|
|
274
|
-
if attributes
|
279
|
+
if attributes.has_key?(:'owner_password')
|
275
280
|
self.owner_password = attributes[:'owner_password']
|
276
281
|
end
|
277
282
|
|
278
|
-
if attributes
|
283
|
+
if attributes.has_key?(:'disallow_print')
|
279
284
|
self.disallow_print = attributes[:'disallow_print']
|
280
285
|
end
|
281
286
|
|
282
|
-
if attributes
|
287
|
+
if attributes.has_key?(:'disallow_copy')
|
283
288
|
self.disallow_copy = attributes[:'disallow_copy']
|
284
289
|
end
|
285
290
|
|
286
|
-
if attributes
|
291
|
+
if attributes.has_key?(:'disallow_annotate')
|
287
292
|
self.disallow_annotate = attributes[:'disallow_annotate']
|
288
293
|
end
|
289
294
|
|
290
|
-
if attributes
|
295
|
+
if attributes.has_key?(:'disallow_modify')
|
291
296
|
self.disallow_modify = attributes[:'disallow_modify']
|
292
297
|
end
|
293
298
|
|
294
|
-
if attributes
|
299
|
+
if attributes.has_key?(:'debug')
|
295
300
|
self.debug = attributes[:'debug']
|
296
301
|
end
|
297
302
|
|
298
|
-
if attributes
|
303
|
+
if attributes.has_key?(:'input')
|
299
304
|
self.input = attributes[:'input']
|
300
305
|
else
|
301
306
|
self.input = "html"
|
302
307
|
end
|
303
308
|
|
304
|
-
if attributes
|
309
|
+
if attributes.has_key?(:'version')
|
305
310
|
self.version = attributes[:'version']
|
306
311
|
end
|
307
312
|
|
308
|
-
if attributes
|
313
|
+
if attributes.has_key?(:'javascript')
|
309
314
|
self.javascript = attributes[:'javascript']
|
310
315
|
end
|
311
316
|
|
312
|
-
if attributes
|
317
|
+
if attributes.has_key?(:'css_dpi')
|
313
318
|
self.css_dpi = attributes[:'css_dpi']
|
314
319
|
end
|
315
320
|
|
316
|
-
if attributes
|
321
|
+
if attributes.has_key?(:'profile')
|
317
322
|
self.profile = attributes[:'profile']
|
318
323
|
end
|
319
324
|
|
320
325
|
end
|
321
326
|
|
327
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
328
|
+
# @return Array for valid properies with the reasons
|
329
|
+
def list_invalid_properties
|
330
|
+
invalid_properties = Array.new
|
331
|
+
return invalid_properties
|
332
|
+
end
|
333
|
+
|
334
|
+
# Check to see if the all the properties in the model are valid
|
335
|
+
# @return true if the model is valid
|
336
|
+
def valid?
|
337
|
+
input_validator = EnumAttributeValidator.new('String', ["html", "xml", "auto"])
|
338
|
+
return false unless input_validator.valid?(@input)
|
339
|
+
return true
|
340
|
+
end
|
341
|
+
|
322
342
|
# Custom attribute writer method checking allowed values (enum).
|
343
|
+
# @param [Object] input Object to be assigned
|
323
344
|
def input=(input)
|
324
|
-
|
325
|
-
|
326
|
-
fail "invalid value for 'input', must be one of #{
|
345
|
+
validator = EnumAttributeValidator.new('String', ["html", "xml", "auto"])
|
346
|
+
unless validator.valid?(input)
|
347
|
+
fail ArgumentError, "invalid value for 'input', must be one of #{validator.allowable_values}."
|
327
348
|
end
|
328
349
|
@input = input
|
329
350
|
end
|
330
351
|
|
331
|
-
#
|
352
|
+
# Checks equality by comparing each attribute.
|
353
|
+
# @param [Object] Object to be compared
|
332
354
|
def ==(o)
|
333
355
|
return true if self.equal?(o)
|
334
356
|
self.class == o.class &&
|
@@ -364,35 +386,41 @@ module DocRaptor
|
|
364
386
|
end
|
365
387
|
|
366
388
|
# @see the `==` method
|
389
|
+
# @param [Object] Object to be compared
|
367
390
|
def eql?(o)
|
368
391
|
self == o
|
369
392
|
end
|
370
393
|
|
371
|
-
#
|
394
|
+
# Calculates hash code according to all attributes.
|
395
|
+
# @return [Fixnum] Hash code
|
372
396
|
def hash
|
373
397
|
[baseurl, no_xinclude, no_network, no_parallel_downloads, http_user, http_password, http_proxy, http_timeout, insecure, media, no_author_style, no_default_style, no_embed_fonts, no_subset_fonts, no_compress, encrypt, key_bits, user_password, owner_password, disallow_print, disallow_copy, disallow_annotate, disallow_modify, debug, input, version, javascript, css_dpi, profile].hash
|
374
398
|
end
|
375
399
|
|
376
|
-
#
|
400
|
+
# Builds the object from hash
|
401
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
402
|
+
# @return [Object] Returns the model itself
|
377
403
|
def build_from_hash(attributes)
|
378
404
|
return nil unless attributes.is_a?(Hash)
|
379
405
|
self.class.swagger_types.each_pair do |key, type|
|
380
|
-
if type =~
|
406
|
+
if type =~ /\AArray<(.*)>/i
|
407
|
+
# check to ensure the input is an array given that the the attribute
|
408
|
+
# is documented as an array but the input is not
|
381
409
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
382
410
|
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
383
|
-
else
|
384
|
-
#TODO show warning in debug mode
|
385
411
|
end
|
386
412
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
387
413
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
388
|
-
else
|
389
|
-
# data not found in attributes(hash), not an issue as the data can be optional
|
390
|
-
end
|
414
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
391
415
|
end
|
392
416
|
|
393
417
|
self
|
394
418
|
end
|
395
419
|
|
420
|
+
# Deserializes the data based on type
|
421
|
+
# @param string type Data type
|
422
|
+
# @param string value Value to be deserialized
|
423
|
+
# @return [Object] Deserialized data
|
396
424
|
def _deserialize(type, value)
|
397
425
|
case type.to_sym
|
398
426
|
when :DateTime
|
@@ -406,7 +434,7 @@ module DocRaptor
|
|
406
434
|
when :Float
|
407
435
|
value.to_f
|
408
436
|
when :BOOLEAN
|
409
|
-
if value.to_s =~
|
437
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
410
438
|
true
|
411
439
|
else
|
412
440
|
false
|
@@ -417,7 +445,7 @@ module DocRaptor
|
|
417
445
|
when /\AArray<(?<inner_type>.+)>\z/
|
418
446
|
inner_type = Regexp.last_match[:inner_type]
|
419
447
|
value.map { |v| _deserialize(inner_type, v) }
|
420
|
-
when /\AHash<(?<k_type
|
448
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
421
449
|
k_type = Regexp.last_match[:k_type]
|
422
450
|
v_type = Regexp.last_match[:v_type]
|
423
451
|
{}.tap do |hash|
|
@@ -426,21 +454,25 @@ module DocRaptor
|
|
426
454
|
end
|
427
455
|
end
|
428
456
|
else # model
|
429
|
-
|
430
|
-
|
457
|
+
temp_model = DocRaptor.const_get(type).new
|
458
|
+
temp_model.build_from_hash(value)
|
431
459
|
end
|
432
460
|
end
|
433
461
|
|
462
|
+
# Returns the string representation of the object
|
463
|
+
# @return [String] String presentation of the object
|
434
464
|
def to_s
|
435
465
|
to_hash.to_s
|
436
466
|
end
|
437
467
|
|
438
|
-
# to_body is an alias to
|
468
|
+
# to_body is an alias to to_hash (backward compatibility)
|
469
|
+
# @return [Hash] Returns the object in the form of hash
|
439
470
|
def to_body
|
440
471
|
to_hash
|
441
472
|
end
|
442
473
|
|
443
|
-
#
|
474
|
+
# Returns the object in the form of hash
|
475
|
+
# @return [Hash] Returns the object in the form of hash
|
444
476
|
def to_hash
|
445
477
|
hash = {}
|
446
478
|
self.class.attribute_map.each_pair do |attr, param|
|
@@ -451,8 +483,10 @@ module DocRaptor
|
|
451
483
|
hash
|
452
484
|
end
|
453
485
|
|
454
|
-
#
|
486
|
+
# Outputs non-array value in the form of hash
|
455
487
|
# For object, use to_hash. Otherwise, just return the value
|
488
|
+
# @param [Object] value Any valid value
|
489
|
+
# @return [Hash] Returns the value in the form of hash
|
456
490
|
def _to_hash(value)
|
457
491
|
if value.is_a?(Array)
|
458
492
|
value.compact.map{ |v| _to_hash(v) }
|
@@ -468,4 +502,5 @@ module DocRaptor
|
|
468
502
|
end
|
469
503
|
|
470
504
|
end
|
505
|
+
|
471
506
|
end
|
data/lib/docraptor/version.rb
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
=begin
|
2
|
+
#DocRaptor v1
|
3
|
+
|
4
|
+
#A native client library for the DocRaptor HTML to PDF/XLS service.
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
1
13
|
module DocRaptor
|
2
|
-
VERSION = "1.
|
14
|
+
VERSION = "1.2.0beta1"
|
3
15
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
bad_files = %q{s.files = `find *`.split("\n").uniq.sort.select{|f| !f.empty? }}
|
2
|
+
bad_test_files = %q{s.test_files = `find spec/*`.split("\n")}
|
3
|
+
good_files = %q{s.files = `git ls-files`.split("\n").uniq.sort.select{|f| !f.empty? }}
|
4
|
+
good_test_files = %q{s.test_files = `git ls-files spec test`.split("\n")}
|
5
|
+
|
6
|
+
development_dependency_marker = %q{ s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.12'}
|
7
|
+
development_dependency_marker_plus_injection =
|
8
|
+
" s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.12'
|
9
|
+
|
10
|
+
# added by script/fix_gemspec.rb.
|
11
|
+
s.add_development_dependency 'rake', '~>11.2', '>= 11.2.2'
|
12
|
+
s.add_development_dependency 'pry', '~>0.10', '>= 0.10.4'
|
13
|
+
# </added> : if the above lines are missing in the gemspec, then
|
14
|
+
# the matcher for autotest is probably broken"
|
15
|
+
|
16
|
+
filename = "docraptor.gemspec"
|
17
|
+
content = File.read(filename)
|
18
|
+
[bad_files, bad_test_files, development_dependency_marker].each do |bad_content_to_check|
|
19
|
+
unless content.include?(bad_content_to_check)
|
20
|
+
raise "Couldn't find content in docraptor.gemspec. Check matchers in there for: “#{bad_content_to_check}”"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
updated_content = content.dup
|
24
|
+
updated_content.sub!(bad_files, good_files)
|
25
|
+
updated_content.sub!(bad_test_files, good_test_files)
|
26
|
+
updated_content.sub!(development_dependency_marker,
|
27
|
+
development_dependency_marker_plus_injection)
|
28
|
+
|
29
|
+
File.open(filename, "w") do |file|
|
30
|
+
file.write(updated_content)
|
31
|
+
end
|