docraptor 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.docker_env.list +3 -0
- data/.generator-language-identifier +1 -0
- data/.generator-revision +1 -0
- data/.github/pull_request_template.txt +17 -0
- data/.gitignore +20 -14
- data/.gitlab-ci.yml +26 -0
- data/.openapi-generator/FILES +27 -0
- data/.openapi-generator/VERSION +1 -0
- data/{.swagger-codegen-ignore → .openapi-generator-ignore} +23 -7
- data/.review/README.md +16 -0
- data/.review/generated_files/.gitignore +39 -0
- data/.review/generated_files/README.md +107 -0
- data/.rubocop.yml +148 -0
- data/.runtime-environments +10 -0
- data/.travis.yml +12 -7
- data/CHANGELOG.md +5 -0
- data/Gemfile +3 -1
- data/README.md +8 -8
- data/Rakefile +1 -2
- data/docraptor.gemspec +5 -19
- data/docraptor.yaml +5 -4
- data/examples/async.rb +24 -30
- data/examples/hosted_async.rb +21 -33
- data/examples/hosted_sync.rb +19 -32
- data/examples/sync.rb +20 -26
- data/gemfiles/Gemfile.2.5.lock +70 -0
- data/gemfiles/Gemfile.2.6.lock +70 -0
- data/gemfiles/Gemfile.2.7.lock +70 -0
- data/gemfiles/Gemfile.3.0.lock +70 -0
- data/{swagger-config.json → generator-config.json} +3 -2
- data/lib/docraptor/api/doc_api.rb +154 -79
- data/lib/docraptor/api_client.rb +91 -90
- data/lib/docraptor/api_error.rb +22 -3
- data/lib/docraptor/configuration.rb +85 -15
- data/lib/docraptor/models/async_doc.rb +53 -18
- data/lib/docraptor/models/doc.rb +80 -45
- data/lib/docraptor/models/doc_status.rb +58 -23
- data/lib/docraptor/models/prince_options.rb +101 -66
- data/lib/docraptor/version.rb +4 -4
- data/lib/docraptor.rb +3 -3
- data/script/clean +2 -2
- data/script/console +5 -0
- data/script/docker +39 -0
- data/script/fix_gemspec.rb +3 -18
- data/script/generate_language +21 -4
- data/script/inside_container/README.md +6 -0
- data/script/inside_container/test +38 -0
- data/script/post_generate_language +10 -2
- data/script/setup +25 -14
- data/script/swagger +6 -33
- data/script/test +30 -27
- data/test/async.rb +2 -2
- data/test/expire_hosted.rb +2 -2
- data/test/hosted_async.rb +7 -1
- data/test/hosted_sync.rb +2 -2
- data/test/sync.rb +2 -2
- data/test/xlsx.rb +6 -3
- metadata +29 -217
- data/.swagger-codegen/VERSION +0 -1
- data/.swagger-revision +0 -1
- data/spec/api_client_spec.rb +0 -243
- data/spec/configuration_spec.rb +0 -42
- data/spec/spec_helper.rb +0 -111
@@ -3,14 +3,15 @@
|
|
3
3
|
|
4
4
|
#A native client library for the DocRaptor HTML to PDF/XLS service.
|
5
5
|
|
6
|
-
OpenAPI
|
6
|
+
The version of the OpenAPI document: 2.0.0
|
7
7
|
|
8
|
-
Generated by: https://
|
9
|
-
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 6.1.0-SNAPSHOT
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
13
|
require 'date'
|
14
|
+
require 'time'
|
14
15
|
|
15
16
|
module DocRaptor
|
16
17
|
class PrinceOptions
|
@@ -162,171 +163,189 @@ module DocRaptor
|
|
162
163
|
}
|
163
164
|
end
|
164
165
|
|
166
|
+
# Returns all the JSON keys this model knows about
|
167
|
+
def self.acceptable_attributes
|
168
|
+
attribute_map.values
|
169
|
+
end
|
170
|
+
|
165
171
|
# Attribute type mapping.
|
166
|
-
def self.
|
172
|
+
def self.openapi_types
|
167
173
|
{
|
168
174
|
:'baseurl' => :'String',
|
169
|
-
:'no_xinclude' => :'
|
170
|
-
:'no_network' => :'
|
171
|
-
:'no_parallel_downloads' => :'
|
175
|
+
:'no_xinclude' => :'Boolean',
|
176
|
+
:'no_network' => :'Boolean',
|
177
|
+
:'no_parallel_downloads' => :'Boolean',
|
172
178
|
:'http_user' => :'String',
|
173
179
|
:'http_password' => :'String',
|
174
180
|
:'http_proxy' => :'String',
|
175
181
|
:'http_timeout' => :'Integer',
|
176
|
-
:'insecure' => :'
|
182
|
+
:'insecure' => :'Boolean',
|
177
183
|
:'media' => :'String',
|
178
|
-
:'no_author_style' => :'
|
179
|
-
:'no_default_style' => :'
|
180
|
-
:'no_embed_fonts' => :'
|
181
|
-
:'no_subset_fonts' => :'
|
182
|
-
:'no_compress' => :'
|
183
|
-
:'encrypt' => :'
|
184
|
+
:'no_author_style' => :'Boolean',
|
185
|
+
:'no_default_style' => :'Boolean',
|
186
|
+
:'no_embed_fonts' => :'Boolean',
|
187
|
+
:'no_subset_fonts' => :'Boolean',
|
188
|
+
:'no_compress' => :'Boolean',
|
189
|
+
:'encrypt' => :'Boolean',
|
184
190
|
:'key_bits' => :'Integer',
|
185
191
|
:'user_password' => :'String',
|
186
192
|
:'owner_password' => :'String',
|
187
|
-
:'disallow_print' => :'
|
188
|
-
:'disallow_copy' => :'
|
189
|
-
:'disallow_annotate' => :'
|
190
|
-
:'disallow_modify' => :'
|
191
|
-
:'debug' => :'
|
193
|
+
:'disallow_print' => :'Boolean',
|
194
|
+
:'disallow_copy' => :'Boolean',
|
195
|
+
:'disallow_annotate' => :'Boolean',
|
196
|
+
:'disallow_modify' => :'Boolean',
|
197
|
+
:'debug' => :'Boolean',
|
192
198
|
:'input' => :'String',
|
193
199
|
:'version' => :'String',
|
194
|
-
:'javascript' => :'
|
200
|
+
:'javascript' => :'Boolean',
|
195
201
|
:'css_dpi' => :'Integer',
|
196
202
|
:'profile' => :'String',
|
197
203
|
:'pdf_title' => :'String'
|
198
204
|
}
|
199
205
|
end
|
200
206
|
|
207
|
+
# List of attributes with nullable: true
|
208
|
+
def self.openapi_nullable
|
209
|
+
Set.new([
|
210
|
+
])
|
211
|
+
end
|
212
|
+
|
201
213
|
# Initializes the object
|
202
214
|
# @param [Hash] attributes Model attributes in the form of hash
|
203
215
|
def initialize(attributes = {})
|
204
|
-
|
216
|
+
if (!attributes.is_a?(Hash))
|
217
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `DocRaptor::PrinceOptions` initialize method"
|
218
|
+
end
|
205
219
|
|
206
|
-
# convert string to symbol for hash key
|
207
|
-
attributes = attributes.each_with_object({}) { |(k, v), h|
|
220
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
221
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
222
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
223
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `DocRaptor::PrinceOptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
224
|
+
end
|
225
|
+
h[k.to_sym] = v
|
226
|
+
}
|
208
227
|
|
209
|
-
if attributes.
|
228
|
+
if attributes.key?(:'baseurl')
|
210
229
|
self.baseurl = attributes[:'baseurl']
|
211
230
|
end
|
212
231
|
|
213
|
-
if attributes.
|
232
|
+
if attributes.key?(:'no_xinclude')
|
214
233
|
self.no_xinclude = attributes[:'no_xinclude']
|
215
234
|
end
|
216
235
|
|
217
|
-
if attributes.
|
236
|
+
if attributes.key?(:'no_network')
|
218
237
|
self.no_network = attributes[:'no_network']
|
219
238
|
end
|
220
239
|
|
221
|
-
if attributes.
|
240
|
+
if attributes.key?(:'no_parallel_downloads')
|
222
241
|
self.no_parallel_downloads = attributes[:'no_parallel_downloads']
|
223
242
|
end
|
224
243
|
|
225
|
-
if attributes.
|
244
|
+
if attributes.key?(:'http_user')
|
226
245
|
self.http_user = attributes[:'http_user']
|
227
246
|
end
|
228
247
|
|
229
|
-
if attributes.
|
248
|
+
if attributes.key?(:'http_password')
|
230
249
|
self.http_password = attributes[:'http_password']
|
231
250
|
end
|
232
251
|
|
233
|
-
if attributes.
|
252
|
+
if attributes.key?(:'http_proxy')
|
234
253
|
self.http_proxy = attributes[:'http_proxy']
|
235
254
|
end
|
236
255
|
|
237
|
-
if attributes.
|
256
|
+
if attributes.key?(:'http_timeout')
|
238
257
|
self.http_timeout = attributes[:'http_timeout']
|
239
258
|
end
|
240
259
|
|
241
|
-
if attributes.
|
260
|
+
if attributes.key?(:'insecure')
|
242
261
|
self.insecure = attributes[:'insecure']
|
243
262
|
end
|
244
263
|
|
245
|
-
if attributes.
|
264
|
+
if attributes.key?(:'media')
|
246
265
|
self.media = attributes[:'media']
|
247
266
|
else
|
248
267
|
self.media = 'print'
|
249
268
|
end
|
250
269
|
|
251
|
-
if attributes.
|
270
|
+
if attributes.key?(:'no_author_style')
|
252
271
|
self.no_author_style = attributes[:'no_author_style']
|
253
272
|
end
|
254
273
|
|
255
|
-
if attributes.
|
274
|
+
if attributes.key?(:'no_default_style')
|
256
275
|
self.no_default_style = attributes[:'no_default_style']
|
257
276
|
end
|
258
277
|
|
259
|
-
if attributes.
|
278
|
+
if attributes.key?(:'no_embed_fonts')
|
260
279
|
self.no_embed_fonts = attributes[:'no_embed_fonts']
|
261
280
|
end
|
262
281
|
|
263
|
-
if attributes.
|
282
|
+
if attributes.key?(:'no_subset_fonts')
|
264
283
|
self.no_subset_fonts = attributes[:'no_subset_fonts']
|
265
284
|
end
|
266
285
|
|
267
|
-
if attributes.
|
286
|
+
if attributes.key?(:'no_compress')
|
268
287
|
self.no_compress = attributes[:'no_compress']
|
269
288
|
end
|
270
289
|
|
271
|
-
if attributes.
|
290
|
+
if attributes.key?(:'encrypt')
|
272
291
|
self.encrypt = attributes[:'encrypt']
|
273
292
|
end
|
274
293
|
|
275
|
-
if attributes.
|
294
|
+
if attributes.key?(:'key_bits')
|
276
295
|
self.key_bits = attributes[:'key_bits']
|
277
296
|
end
|
278
297
|
|
279
|
-
if attributes.
|
298
|
+
if attributes.key?(:'user_password')
|
280
299
|
self.user_password = attributes[:'user_password']
|
281
300
|
end
|
282
301
|
|
283
|
-
if attributes.
|
302
|
+
if attributes.key?(:'owner_password')
|
284
303
|
self.owner_password = attributes[:'owner_password']
|
285
304
|
end
|
286
305
|
|
287
|
-
if attributes.
|
306
|
+
if attributes.key?(:'disallow_print')
|
288
307
|
self.disallow_print = attributes[:'disallow_print']
|
289
308
|
end
|
290
309
|
|
291
|
-
if attributes.
|
310
|
+
if attributes.key?(:'disallow_copy')
|
292
311
|
self.disallow_copy = attributes[:'disallow_copy']
|
293
312
|
end
|
294
313
|
|
295
|
-
if attributes.
|
314
|
+
if attributes.key?(:'disallow_annotate')
|
296
315
|
self.disallow_annotate = attributes[:'disallow_annotate']
|
297
316
|
end
|
298
317
|
|
299
|
-
if attributes.
|
318
|
+
if attributes.key?(:'disallow_modify')
|
300
319
|
self.disallow_modify = attributes[:'disallow_modify']
|
301
320
|
end
|
302
321
|
|
303
|
-
if attributes.
|
322
|
+
if attributes.key?(:'debug')
|
304
323
|
self.debug = attributes[:'debug']
|
305
324
|
end
|
306
325
|
|
307
|
-
if attributes.
|
326
|
+
if attributes.key?(:'input')
|
308
327
|
self.input = attributes[:'input']
|
309
328
|
else
|
310
329
|
self.input = 'html'
|
311
330
|
end
|
312
331
|
|
313
|
-
if attributes.
|
332
|
+
if attributes.key?(:'version')
|
314
333
|
self.version = attributes[:'version']
|
315
334
|
end
|
316
335
|
|
317
|
-
if attributes.
|
336
|
+
if attributes.key?(:'javascript')
|
318
337
|
self.javascript = attributes[:'javascript']
|
319
338
|
end
|
320
339
|
|
321
|
-
if attributes.
|
340
|
+
if attributes.key?(:'css_dpi')
|
322
341
|
self.css_dpi = attributes[:'css_dpi']
|
323
342
|
end
|
324
343
|
|
325
|
-
if attributes.
|
344
|
+
if attributes.key?(:'profile')
|
326
345
|
self.profile = attributes[:'profile']
|
327
346
|
end
|
328
347
|
|
329
|
-
if attributes.
|
348
|
+
if attributes.key?(:'pdf_title')
|
330
349
|
self.pdf_title = attributes[:'pdf_title']
|
331
350
|
end
|
332
351
|
end
|
@@ -341,7 +360,7 @@ module DocRaptor
|
|
341
360
|
# Check to see if the all the properties in the model are valid
|
342
361
|
# @return true if the model is valid
|
343
362
|
def valid?
|
344
|
-
input_validator = EnumAttributeValidator.new('String', [
|
363
|
+
input_validator = EnumAttributeValidator.new('String', ["html", "xml", "auto"])
|
345
364
|
return false unless input_validator.valid?(@input)
|
346
365
|
true
|
347
366
|
end
|
@@ -349,9 +368,9 @@ module DocRaptor
|
|
349
368
|
# Custom attribute writer method checking allowed values (enum).
|
350
369
|
# @param [Object] input Object to be assigned
|
351
370
|
def input=(input)
|
352
|
-
validator = EnumAttributeValidator.new('String', [
|
371
|
+
validator = EnumAttributeValidator.new('String', ["html", "xml", "auto"])
|
353
372
|
unless validator.valid?(input)
|
354
|
-
fail ArgumentError,
|
373
|
+
fail ArgumentError, "invalid value for \"input\", must be one of #{validator.allowable_values}."
|
355
374
|
end
|
356
375
|
@input = input
|
357
376
|
end
|
@@ -400,18 +419,28 @@ module DocRaptor
|
|
400
419
|
end
|
401
420
|
|
402
421
|
# Calculates hash code according to all attributes.
|
403
|
-
# @return [
|
422
|
+
# @return [Integer] Hash code
|
404
423
|
def hash
|
405
424
|
[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, pdf_title].hash
|
406
425
|
end
|
407
426
|
|
427
|
+
# Builds the object from hash
|
428
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
429
|
+
# @return [Object] Returns the model itself
|
430
|
+
def self.build_from_hash(attributes)
|
431
|
+
new.build_from_hash(attributes)
|
432
|
+
end
|
433
|
+
|
408
434
|
# Builds the object from hash
|
409
435
|
# @param [Hash] attributes Model attributes in the form of hash
|
410
436
|
# @return [Object] Returns the model itself
|
411
437
|
def build_from_hash(attributes)
|
412
438
|
return nil unless attributes.is_a?(Hash)
|
413
|
-
|
414
|
-
|
439
|
+
attributes = attributes.transform_keys(&:to_sym)
|
440
|
+
self.class.openapi_types.each_pair do |key, type|
|
441
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
442
|
+
self.send("#{key}=", nil)
|
443
|
+
elsif type =~ /\AArray<(.*)>/i
|
415
444
|
# check to ensure the input is an array given that the attribute
|
416
445
|
# is documented as an array but the input is not
|
417
446
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
@@ -419,7 +448,7 @@ module DocRaptor
|
|
419
448
|
end
|
420
449
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
421
450
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
422
|
-
end
|
451
|
+
end
|
423
452
|
end
|
424
453
|
|
425
454
|
self
|
@@ -431,8 +460,8 @@ module DocRaptor
|
|
431
460
|
# @return [Object] Deserialized data
|
432
461
|
def _deserialize(type, value)
|
433
462
|
case type.to_sym
|
434
|
-
when :
|
435
|
-
|
463
|
+
when :Time
|
464
|
+
Time.parse(value)
|
436
465
|
when :Date
|
437
466
|
Date.parse(value)
|
438
467
|
when :String
|
@@ -441,7 +470,7 @@ module DocRaptor
|
|
441
470
|
value.to_i
|
442
471
|
when :Float
|
443
472
|
value.to_f
|
444
|
-
when :
|
473
|
+
when :Boolean
|
445
474
|
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
446
475
|
true
|
447
476
|
else
|
@@ -462,8 +491,9 @@ module DocRaptor
|
|
462
491
|
end
|
463
492
|
end
|
464
493
|
else # model
|
465
|
-
|
466
|
-
|
494
|
+
# models (e.g. Pet) or oneOf
|
495
|
+
klass = DocRaptor.const_get(type)
|
496
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
467
497
|
end
|
468
498
|
end
|
469
499
|
|
@@ -485,7 +515,11 @@ module DocRaptor
|
|
485
515
|
hash = {}
|
486
516
|
self.class.attribute_map.each_pair do |attr, param|
|
487
517
|
value = self.send(attr)
|
488
|
-
|
518
|
+
if value.nil?
|
519
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
520
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
521
|
+
end
|
522
|
+
|
489
523
|
hash[param] = _to_hash(value)
|
490
524
|
end
|
491
525
|
hash
|
@@ -510,4 +544,5 @@ module DocRaptor
|
|
510
544
|
end
|
511
545
|
|
512
546
|
end
|
547
|
+
|
513
548
|
end
|
data/lib/docraptor/version.rb
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
|
4
4
|
#A native client library for the DocRaptor HTML to PDF/XLS service.
|
5
5
|
|
6
|
-
OpenAPI
|
6
|
+
The version of the OpenAPI document: 2.0.0
|
7
7
|
|
8
|
-
Generated by: https://
|
9
|
-
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 6.1.0-SNAPSHOT
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
13
|
module DocRaptor
|
14
|
-
VERSION = '
|
14
|
+
VERSION = '3.0.0'
|
15
15
|
end
|
data/lib/docraptor.rb
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
|
4
4
|
#A native client library for the DocRaptor HTML to PDF/XLS service.
|
5
5
|
|
6
|
-
OpenAPI
|
6
|
+
The version of the OpenAPI document: 2.0.0
|
7
7
|
|
8
|
-
Generated by: https://
|
9
|
-
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 6.1.0-SNAPSHOT
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
data/script/clean
CHANGED
data/script/console
ADDED
data/script/docker
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -e
|
3
|
+
cd "$(dirname "$0")/.."
|
4
|
+
|
5
|
+
OPTIND=1
|
6
|
+
|
7
|
+
image=""
|
8
|
+
|
9
|
+
while getopts "h?i:" opt; do
|
10
|
+
case "$opt" in
|
11
|
+
h|\?)
|
12
|
+
show_help
|
13
|
+
exit 0
|
14
|
+
;;
|
15
|
+
i) image="$OPTARG"
|
16
|
+
;;
|
17
|
+
esac
|
18
|
+
done
|
19
|
+
|
20
|
+
shift $((OPTIND-1))
|
21
|
+
|
22
|
+
if [[ "$image" == "" ]]; then
|
23
|
+
image="$(cat .runtime-environments | grep -v '^#' | tail -n 1)"
|
24
|
+
echo "docker image (-i) unset, defaulting to: $image"
|
25
|
+
fi
|
26
|
+
|
27
|
+
command="$1"
|
28
|
+
|
29
|
+
cache_dir="$(pwd)/tmp/cache_${image}"
|
30
|
+
mkdir -p "$cache_dir"
|
31
|
+
|
32
|
+
set -x
|
33
|
+
docker run --pull=always -it --rm \
|
34
|
+
--env-file .docker_env.list \
|
35
|
+
--env RUNTIME_ENV="${image}" \
|
36
|
+
--mount type=bind,source="$(pwd)",target=/app \
|
37
|
+
--mount type=bind,source="${cache_dir}",target=/app/tmp/cache \
|
38
|
+
"$image" \
|
39
|
+
"$command"
|
data/script/fix_gemspec.rb
CHANGED
@@ -1,28 +1,16 @@
|
|
1
|
-
#
|
1
|
+
# These, at least the first two, significantly increase speed of a test run by
|
2
|
+
# limiting the filesystem interaction that occurs with bundler installing and
|
3
|
+
# requiring files.
|
2
4
|
bad_files = %q{s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }}
|
3
5
|
good_files = %q{s.files = `git ls-files`.split("\n").uniq.sort.select { |f| !f.empty? }}
|
4
6
|
bad_test_files = %q{s.test_files = `find spec/*`.split("\n")}
|
5
7
|
good_test_files = %q{s.test_files = `git ls-files spec test`.split("\n")}
|
6
|
-
bad_ruby_version = %q{s.required_ruby_version = ">= 1.9"}
|
7
|
-
good_ruby_version = %q{s.required_ruby_version = ">= 2.3"}
|
8
|
-
|
9
|
-
development_dependency_marker = %q{ s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.12'}
|
10
|
-
development_dependency_marker_plus_injection =
|
11
|
-
" s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.12'
|
12
|
-
|
13
|
-
# added by script/fix_gemspec.rb.
|
14
|
-
s.add_development_dependency 'rake', '~>11.2', '>= 11.2.2'
|
15
|
-
s.add_development_dependency 'pry', '~>0.10', '>= 0.10.4'
|
16
|
-
# </added> : if the above lines are missing in the gemspec, then
|
17
|
-
# the matcher for autotest is probably broken"
|
18
8
|
|
19
9
|
filename = "docraptor.gemspec"
|
20
10
|
content = File.read(filename)
|
21
11
|
[
|
22
12
|
bad_files,
|
23
13
|
bad_test_files,
|
24
|
-
bad_ruby_version,
|
25
|
-
development_dependency_marker
|
26
14
|
].each do |bad_content_to_check|
|
27
15
|
unless content.include?(bad_content_to_check)
|
28
16
|
raise "Couldn't find content in docraptor.gemspec. Check matchers in there for: “#{bad_content_to_check}”"
|
@@ -31,9 +19,6 @@ end
|
|
31
19
|
updated_content = content.dup
|
32
20
|
updated_content.sub!(bad_files, good_files)
|
33
21
|
updated_content.sub!(bad_test_files, good_test_files)
|
34
|
-
updated_content.sub!(bad_ruby_version, good_ruby_version)
|
35
|
-
updated_content.sub!(development_dependency_marker,
|
36
|
-
development_dependency_marker_plus_injection)
|
37
22
|
|
38
23
|
File.open(filename, "w") do |file|
|
39
24
|
file.write(updated_content)
|
data/script/generate_language
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
#!/bin/
|
1
|
+
#!/bin/bash
|
2
2
|
set -e
|
3
3
|
cd "$(dirname "$0")/.."
|
4
4
|
|
5
|
-
LANGUAGE="$
|
6
|
-
CONFIG_FILE="
|
5
|
+
LANGUAGE="$(cat .generator-language-identifier)"
|
6
|
+
CONFIG_FILE="generator-config.json"
|
7
7
|
|
8
8
|
if [ "$LANGUAGE" = "" ]; then
|
9
9
|
./script/swagger # prints languages
|
@@ -18,12 +18,29 @@ fi
|
|
18
18
|
|
19
19
|
./script/clean
|
20
20
|
|
21
|
+
# See .review/README.md
|
22
|
+
echo "Facilitating generated content review"
|
23
|
+
tmp_dir=".review/tmp"
|
24
|
+
review_root=".review/generated_files"
|
25
|
+
rm -rf "$tmp_dir"
|
26
|
+
(cd "$review_root" && find . -type f) | while read file_path; do
|
27
|
+
mkdir -p "$(dirname "${tmp_dir}/$file_path")"
|
28
|
+
mv -v "$file_path" "${tmp_dir}/$file_path"
|
29
|
+
done
|
30
|
+
|
21
31
|
./script/swagger generate \
|
22
32
|
-i docraptor.yaml \
|
23
|
-
-
|
33
|
+
-g "$LANGUAGE" \
|
24
34
|
-c "$CONFIG_FILE"
|
25
35
|
|
26
36
|
# call a generator cleanup script
|
27
37
|
if [ -f "script/post_generate_language" ]; then
|
28
38
|
./script/post_generate_language
|
29
39
|
fi
|
40
|
+
|
41
|
+
# See .review/README.md
|
42
|
+
echo "Facilitating generated content review"
|
43
|
+
(cd "$review_root" && find . -type f) | while read file_path; do
|
44
|
+
mv -v "$file_path" "$review_root/$file_path"
|
45
|
+
mv -v "${tmp_dir}/$file_path" "$file_path"
|
46
|
+
done
|
@@ -0,0 +1,6 @@
|
|
1
|
+
This folder contains scripts that are only intended to be run inside
|
2
|
+
of a relevant docker container. For example, `script/test` may run
|
3
|
+
`script/inside_container/test` inside a container with particular
|
4
|
+
versions of libraries to make it easy to test the agent in multiple
|
5
|
+
settings. It's possible these scripts will work outside of any
|
6
|
+
particular container, but that may or may not mean anything.
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -e
|
3
|
+
cd "$(dirname "$0")/../.."
|
4
|
+
|
5
|
+
# check dependencies
|
6
|
+
ruby -v > /dev/null || (echo "ruby must be installed"; exit 1)
|
7
|
+
|
8
|
+
major_minor_version="$(ruby -e 'puts RUBY_VERSION.split(".")[0, 2].join(".")')"
|
9
|
+
gemfile_lock="gemfiles/Gemfile.${major_minor_version}.lock"
|
10
|
+
if [ -f "$gemfile_lock" ]; then
|
11
|
+
cp -v "$gemfile_lock" Gemfile.lock
|
12
|
+
else
|
13
|
+
rm -vf Gemfile.lock
|
14
|
+
fi
|
15
|
+
|
16
|
+
bundle -v > /dev/null || (echo "bundler must be installed"; exit 1)
|
17
|
+
|
18
|
+
# TODO: update to test against updates dependencies as well
|
19
|
+
bundle install
|
20
|
+
|
21
|
+
if [ ! -f "$gemfile_lock" ]; then
|
22
|
+
cp -v Gemfile.lock "$gemfile_lock"
|
23
|
+
fi
|
24
|
+
|
25
|
+
cd test
|
26
|
+
|
27
|
+
# runs a test file with PASS/FAIL message
|
28
|
+
run_test() {
|
29
|
+
ruby $1 && echo "PASS $1" || (echo "FAIL $1"; exit 1)
|
30
|
+
}
|
31
|
+
|
32
|
+
if [ "$1" == "" ]; then
|
33
|
+
for test in $(ls *.rb); do
|
34
|
+
run_test $test
|
35
|
+
done
|
36
|
+
else
|
37
|
+
run_test $1.rb
|
38
|
+
fi
|
@@ -1,9 +1,17 @@
|
|
1
|
-
#!/bin/
|
1
|
+
#!/bin/bash
|
2
2
|
set -e
|
3
|
-
cd "
|
3
|
+
cd "$(dirname "$0")/.."
|
4
|
+
|
5
|
+
echo "Removing unnecessary generated specs..."
|
6
|
+
rm -r spec
|
4
7
|
|
5
8
|
echo "Removing trailing whitespace..."
|
6
9
|
find lib -name "*.rb" -type f -exec sed -E -i '' 's/[[:space:]]+$//g' {} +
|
7
10
|
|
8
11
|
echo "Fixing gemspec to work around swagger..."
|
9
12
|
ruby script/fix_gemspec.rb
|
13
|
+
|
14
|
+
if compgen -G "patches/*.patch" > /dev/null; then
|
15
|
+
echo "Apply patches to generated code"
|
16
|
+
git apply --verbose patches/*.patch
|
17
|
+
fi
|
data/script/setup
CHANGED
@@ -2,24 +2,35 @@
|
|
2
2
|
set -e
|
3
3
|
cd "$(dirname "$0")/.."
|
4
4
|
|
5
|
-
|
5
|
+
setup_echo() {
|
6
|
+
echo "[script/setup] $1"
|
7
|
+
}
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
+
setup_error() {
|
10
|
+
echo "[script/setup][ERROR] $1"
|
11
|
+
}
|
9
12
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
13
|
+
brew_install() {
|
14
|
+
setup_echo "Installing $1..."
|
15
|
+
brew list --formula "$1" > /dev/null || brew install --formula "$1"
|
16
|
+
}
|
14
17
|
|
15
|
-
|
16
|
-
|
18
|
+
brew_cask_install() {
|
19
|
+
setup_echo "Installing cask $1..."
|
20
|
+
brew list --cask "$1" &> /dev/null || brew install --cask "$1"
|
21
|
+
}
|
22
|
+
|
23
|
+
brew_cask_install docker
|
24
|
+
brew_install docker
|
25
|
+
|
26
|
+
# Avoid a warning message (vs. --overwrite)
|
27
|
+
brew unlink docker && brew link docker
|
17
28
|
|
18
29
|
tput bold # bold text
|
19
30
|
tput setaf 2 # green text
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
31
|
+
setup_echo "****************************************************************"
|
32
|
+
setup_echo "* *"
|
33
|
+
setup_echo "* Good to go! *"
|
34
|
+
setup_echo "* *"
|
35
|
+
setup_echo "****************************************************************"
|
25
36
|
tput sgr0 # reset to default text
|