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.
@@ -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.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
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[:'no_xinclude']
209
+ if attributes.has_key?(:'no_xinclude')
205
210
  self.no_xinclude = attributes[:'no_xinclude']
206
211
  end
207
212
 
208
- if attributes[:'no_network']
213
+ if attributes.has_key?(:'no_network')
209
214
  self.no_network = attributes[:'no_network']
210
215
  end
211
216
 
212
- if attributes[:'no_parallel_downloads']
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[:'http_user']
221
+ if attributes.has_key?(:'http_user')
217
222
  self.http_user = attributes[:'http_user']
218
223
  end
219
224
 
220
- if attributes[:'http_password']
225
+ if attributes.has_key?(:'http_password')
221
226
  self.http_password = attributes[:'http_password']
222
227
  end
223
228
 
224
- if attributes[:'http_proxy']
229
+ if attributes.has_key?(:'http_proxy')
225
230
  self.http_proxy = attributes[:'http_proxy']
226
231
  end
227
232
 
228
- if attributes[:'http_timeout']
233
+ if attributes.has_key?(:'http_timeout')
229
234
  self.http_timeout = attributes[:'http_timeout']
230
235
  end
231
236
 
232
- if attributes[:'insecure']
237
+ if attributes.has_key?(:'insecure')
233
238
  self.insecure = attributes[:'insecure']
234
239
  end
235
240
 
236
- if attributes[:'media']
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[:'no_author_style']
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[:'no_default_style']
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[:'no_embed_fonts']
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[:'no_subset_fonts']
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[:'no_compress']
263
+ if attributes.has_key?(:'no_compress')
259
264
  self.no_compress = attributes[:'no_compress']
260
265
  end
261
266
 
262
- if attributes[:'encrypt']
267
+ if attributes.has_key?(:'encrypt')
263
268
  self.encrypt = attributes[:'encrypt']
264
269
  end
265
270
 
266
- if attributes[:'key_bits']
271
+ if attributes.has_key?(:'key_bits')
267
272
  self.key_bits = attributes[:'key_bits']
268
273
  end
269
274
 
270
- if attributes[:'user_password']
275
+ if attributes.has_key?(:'user_password')
271
276
  self.user_password = attributes[:'user_password']
272
277
  end
273
278
 
274
- if attributes[:'owner_password']
279
+ if attributes.has_key?(:'owner_password')
275
280
  self.owner_password = attributes[:'owner_password']
276
281
  end
277
282
 
278
- if attributes[:'disallow_print']
283
+ if attributes.has_key?(:'disallow_print')
279
284
  self.disallow_print = attributes[:'disallow_print']
280
285
  end
281
286
 
282
- if attributes[:'disallow_copy']
287
+ if attributes.has_key?(:'disallow_copy')
283
288
  self.disallow_copy = attributes[:'disallow_copy']
284
289
  end
285
290
 
286
- if attributes[:'disallow_annotate']
291
+ if attributes.has_key?(:'disallow_annotate')
287
292
  self.disallow_annotate = attributes[:'disallow_annotate']
288
293
  end
289
294
 
290
- if attributes[:'disallow_modify']
295
+ if attributes.has_key?(:'disallow_modify')
291
296
  self.disallow_modify = attributes[:'disallow_modify']
292
297
  end
293
298
 
294
- if attributes[:'debug']
299
+ if attributes.has_key?(:'debug')
295
300
  self.debug = attributes[:'debug']
296
301
  end
297
302
 
298
- if attributes[:'input']
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[:'version']
309
+ if attributes.has_key?(:'version')
305
310
  self.version = attributes[:'version']
306
311
  end
307
312
 
308
- if attributes[:'javascript']
313
+ if attributes.has_key?(:'javascript')
309
314
  self.javascript = attributes[:'javascript']
310
315
  end
311
316
 
312
- if attributes[:'css_dpi']
317
+ if attributes.has_key?(:'css_dpi')
313
318
  self.css_dpi = attributes[:'css_dpi']
314
319
  end
315
320
 
316
- if attributes[:'profile']
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
- allowed_values = ["html", "xml", "auto"]
325
- if input && !allowed_values.include?(input)
326
- fail "invalid value for 'input', must be one of #{allowed_values}"
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
- # Check equality by comparing each attribute.
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
- # Calculate hash code according to all attributes.
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
- # build the object from hash
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 =~ /^Array<(.*)>/i
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 =~ /^(true|t|yes|y|1)$/i
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>.+), (?<v_type>.+)>\z/
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
- _model = DocRaptor.const_get(type).new
430
- _model.build_from_hash(value)
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 to_body (backward compatibility))
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
- # return the object in the form of hash
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
- # Method to output non-array value in the form of hash
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
@@ -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.1.0"
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