metanorma-cli 1.5.4 → 1.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/metanorma/cli/collection.rb +57 -0
- data/lib/metanorma/cli/command.rb +6 -6
- data/lib/metanorma/cli/site_generator.rb +23 -0
- data/lib/metanorma/cli/version.rb +1 -1
- data/lib/metanorma/cli.rb +4 -0
- data/metanorma-cli.gemspec +17 -17
- metadata +31 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92c6a8ea58f3a4792bad666250830dd2ddb645254763ef9a318ba3b81390e03a
|
4
|
+
data.tar.gz: e3afa8859565796dffb7944c2c3d9acd29aa69566fc49585a67000908901ad23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c675c7646add303082d35ab2837f02ce392e9ff852cb0cda32fe057f6a92581bdfe2ef3bfb315580acb31af283b542880ec8983a5eed873c20891acec890e291
|
7
|
+
data.tar.gz: e0f5f28517f6aba4990064c6c21015fa496665cdc8d532937a49eaf8206391a9bb815b71aa7475e00a11e6b8686a74f7da9c199630043ac06e8b70d25ea7a62b
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
module Metanorma
|
4
|
+
module Cli
|
5
|
+
class Collection
|
6
|
+
def initialize(file, options)
|
7
|
+
@file = file
|
8
|
+
@options = Cli.with_indifferent_access(options)
|
9
|
+
@compile_options = @options.delete(:compile)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.render(filename, options = {})
|
13
|
+
new(filename, options).render
|
14
|
+
end
|
15
|
+
|
16
|
+
def render
|
17
|
+
extract_options_from_file
|
18
|
+
collection_file.render(collection_options.compact)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
attr_reader :file, :options
|
24
|
+
|
25
|
+
def collection_file
|
26
|
+
@collection_file ||= Metanorma::Collection.parse(file)
|
27
|
+
end
|
28
|
+
|
29
|
+
def collection_options
|
30
|
+
{
|
31
|
+
compile: @compile_options,
|
32
|
+
coverpage: options.fetch(:coverpage, nil),
|
33
|
+
output_folder: options.fetch(:output_folder, nil),
|
34
|
+
format: collection_output_formats(options.fetch(:format, "")),
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
def collection_output_formats(formats)
|
39
|
+
if formats.is_a?(String)
|
40
|
+
formats = formats.split(",")
|
41
|
+
end
|
42
|
+
|
43
|
+
(formats || []).map { |extension| extension.strip.to_sym }
|
44
|
+
end
|
45
|
+
|
46
|
+
def extract_options_from_file
|
47
|
+
if options.empty?
|
48
|
+
yaml_file = YAML.safe_load(File.read(@file.to_s))
|
49
|
+
|
50
|
+
@options = Cli.with_indifferent_access(
|
51
|
+
yaml_file.slice("coverpage", "format", "output_folder"),
|
52
|
+
)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "metanorma/cli/compiler"
|
2
2
|
require "metanorma/cli/generator"
|
3
|
+
require "metanorma/cli/collection"
|
3
4
|
require "metanorma/cli/git_template"
|
4
5
|
require "metanorma/cli/thor_with_config"
|
5
6
|
require "metanorma/cli/commands/config"
|
@@ -67,12 +68,11 @@ module Metanorma
|
|
67
68
|
|
68
69
|
def collection(filename = nil)
|
69
70
|
if filename
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
else UI.say("Need to specify a file to process")
|
71
|
+
coll_options = options.dup
|
72
|
+
coll_options[:compile] = filter_compile_options(coll_options)
|
73
|
+
Metanorma::Cli::Collection.render(filename, coll_options)
|
74
|
+
else
|
75
|
+
UI.say("Need to specify a file to process")
|
76
76
|
end
|
77
77
|
rescue ArgumentError => e
|
78
78
|
UI.say e.message
|
@@ -6,6 +6,7 @@ module Metanorma
|
|
6
6
|
module Cli
|
7
7
|
class SiteGenerator
|
8
8
|
def initialize(source, options = {}, compile_options = {})
|
9
|
+
@collection_queue = []
|
9
10
|
@source = find_realpath(source)
|
10
11
|
@site_path = options.fetch(:output_dir, "site").to_s
|
11
12
|
@asset_folder = options.fetch(:asset_folder, "documents").to_s
|
@@ -31,6 +32,8 @@ module Metanorma
|
|
31
32
|
build_collection_file(collection_name)
|
32
33
|
convert_to_html_page(collection_name, "index.html")
|
33
34
|
end
|
35
|
+
|
36
|
+
dequeue_jobs
|
34
37
|
end
|
35
38
|
|
36
39
|
private
|
@@ -72,6 +75,10 @@ module Metanorma
|
|
72
75
|
end
|
73
76
|
|
74
77
|
def compile(source)
|
78
|
+
if collection_file?(source)
|
79
|
+
return
|
80
|
+
end
|
81
|
+
|
75
82
|
UI.info("Compiling #{source} ...")
|
76
83
|
|
77
84
|
options = @compile_options.merge(
|
@@ -158,6 +165,22 @@ module Metanorma
|
|
158
165
|
|
159
166
|
output_directory
|
160
167
|
end
|
168
|
+
|
169
|
+
def collection_file?(source)
|
170
|
+
ext = File.extname(source)&.downcase
|
171
|
+
|
172
|
+
if [".yml", ".yaml"].include?(ext)
|
173
|
+
@collection_queue << source
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def dequeue_jobs
|
178
|
+
job = @collection_queue.pop
|
179
|
+
|
180
|
+
if job
|
181
|
+
Cli::Collection.render(job, compile: @compile_options)
|
182
|
+
end
|
183
|
+
end
|
161
184
|
end
|
162
185
|
end
|
163
186
|
end
|
data/lib/metanorma/cli.rb
CHANGED
@@ -82,6 +82,10 @@ module Metanorma
|
|
82
82
|
Pathname.new(Cli.root).join("..")
|
83
83
|
end
|
84
84
|
|
85
|
+
def self.with_indifferent_access(options)
|
86
|
+
Thor::CoreExt::HashWithIndifferentAccess.new(options)
|
87
|
+
end
|
88
|
+
|
85
89
|
def self.find_command(arguments)
|
86
90
|
commands = Metanorma::Cli::Command.all_commands.keys
|
87
91
|
commands.select { |cmd| arguments.include?(cmd.gsub("_", "-")) == true }
|
data/metanorma-cli.gemspec
CHANGED
@@ -36,27 +36,27 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_development_dependency "sassc"
|
37
37
|
|
38
38
|
spec.add_runtime_dependency "mnconvert"
|
39
|
-
spec.add_runtime_dependency "metanorma-ietf", "~>
|
40
|
-
spec.add_runtime_dependency "metanorma-iso", "~>
|
39
|
+
spec.add_runtime_dependency "metanorma-ietf", "~> 3.0.0"
|
40
|
+
spec.add_runtime_dependency "metanorma-iso", "~> 2.0.0"
|
41
41
|
spec.add_runtime_dependency "thor", "~> 1.0"
|
42
42
|
# spec.add_runtime_dependency "metanorma-gb", "~> 1.5.0"
|
43
|
-
spec.add_runtime_dependency "metanorma-cc", "~>
|
44
|
-
spec.add_runtime_dependency "metanorma-csa", "~>
|
45
|
-
spec.add_runtime_dependency "metanorma-iec", "~>
|
46
|
-
# spec.add_runtime_dependency 'metanorma-ribose', "~>
|
47
|
-
spec.add_runtime_dependency "metanorma-bipm", "~>
|
48
|
-
spec.add_runtime_dependency "metanorma-generic", "~>
|
49
|
-
spec.add_runtime_dependency "metanorma-m3aawg", "~>
|
50
|
-
spec.add_runtime_dependency "metanorma-standoc", "~>
|
51
|
-
# spec.add_runtime_dependency 'metanorma-mpfa', "~> 0.
|
43
|
+
spec.add_runtime_dependency "metanorma-cc", "~> 2.0.0"
|
44
|
+
spec.add_runtime_dependency "metanorma-csa", "~> 2.0.0"
|
45
|
+
spec.add_runtime_dependency "metanorma-iec", "~> 2.0.0"
|
46
|
+
# spec.add_runtime_dependency 'metanorma-ribose', "~> 2.0.0"
|
47
|
+
spec.add_runtime_dependency "metanorma-bipm", "~> 2.0.0"
|
48
|
+
spec.add_runtime_dependency "metanorma-generic", "~> 2.0.0"
|
49
|
+
spec.add_runtime_dependency "metanorma-m3aawg", "~> 2.0.0"
|
50
|
+
spec.add_runtime_dependency "metanorma-standoc", "~> 2.0.0"
|
51
|
+
# spec.add_runtime_dependency 'metanorma-mpfa', "~> 0.8.0"
|
52
52
|
spec.add_runtime_dependency "git", "~> 1.5"
|
53
|
-
spec.add_runtime_dependency "isodoc", ">=
|
53
|
+
spec.add_runtime_dependency "isodoc", ">= 2.0.0"
|
54
54
|
spec.add_runtime_dependency "metanorma", "~> 1.4.0"
|
55
|
-
spec.add_runtime_dependency "metanorma-iho", "~> 0.
|
56
|
-
spec.add_runtime_dependency "metanorma-itu", "~>
|
57
|
-
# spec.add_runtime_dependency "metanorma-nist", "~>
|
58
|
-
spec.add_runtime_dependency "metanorma-ogc", "~>
|
59
|
-
spec.add_runtime_dependency "metanorma-un", "~> 0.
|
55
|
+
spec.add_runtime_dependency "metanorma-iho", "~> 0.5.0"
|
56
|
+
spec.add_runtime_dependency "metanorma-itu", "~> 2.0.0"
|
57
|
+
# spec.add_runtime_dependency "metanorma-nist", "~> 2.0.0"
|
58
|
+
spec.add_runtime_dependency "metanorma-ogc", "~> 2.0.0"
|
59
|
+
spec.add_runtime_dependency "metanorma-un", "~> 0.8.0"
|
60
60
|
spec.add_runtime_dependency "relaton-cli", ">= 0.8.2"
|
61
61
|
|
62
62
|
spec.add_runtime_dependency "socksify"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: debug
|
@@ -170,28 +170,28 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version:
|
173
|
+
version: 3.0.0
|
174
174
|
type: :runtime
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version:
|
180
|
+
version: 3.0.0
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: metanorma-iso
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
185
|
- - "~>"
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version:
|
187
|
+
version: 2.0.0
|
188
188
|
type: :runtime
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
192
|
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
|
-
version:
|
194
|
+
version: 2.0.0
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
196
|
name: thor
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -212,98 +212,98 @@ dependencies:
|
|
212
212
|
requirements:
|
213
213
|
- - "~>"
|
214
214
|
- !ruby/object:Gem::Version
|
215
|
-
version:
|
215
|
+
version: 2.0.0
|
216
216
|
type: :runtime
|
217
217
|
prerelease: false
|
218
218
|
version_requirements: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
220
|
- - "~>"
|
221
221
|
- !ruby/object:Gem::Version
|
222
|
-
version:
|
222
|
+
version: 2.0.0
|
223
223
|
- !ruby/object:Gem::Dependency
|
224
224
|
name: metanorma-csa
|
225
225
|
requirement: !ruby/object:Gem::Requirement
|
226
226
|
requirements:
|
227
227
|
- - "~>"
|
228
228
|
- !ruby/object:Gem::Version
|
229
|
-
version:
|
229
|
+
version: 2.0.0
|
230
230
|
type: :runtime
|
231
231
|
prerelease: false
|
232
232
|
version_requirements: !ruby/object:Gem::Requirement
|
233
233
|
requirements:
|
234
234
|
- - "~>"
|
235
235
|
- !ruby/object:Gem::Version
|
236
|
-
version:
|
236
|
+
version: 2.0.0
|
237
237
|
- !ruby/object:Gem::Dependency
|
238
238
|
name: metanorma-iec
|
239
239
|
requirement: !ruby/object:Gem::Requirement
|
240
240
|
requirements:
|
241
241
|
- - "~>"
|
242
242
|
- !ruby/object:Gem::Version
|
243
|
-
version:
|
243
|
+
version: 2.0.0
|
244
244
|
type: :runtime
|
245
245
|
prerelease: false
|
246
246
|
version_requirements: !ruby/object:Gem::Requirement
|
247
247
|
requirements:
|
248
248
|
- - "~>"
|
249
249
|
- !ruby/object:Gem::Version
|
250
|
-
version:
|
250
|
+
version: 2.0.0
|
251
251
|
- !ruby/object:Gem::Dependency
|
252
252
|
name: metanorma-bipm
|
253
253
|
requirement: !ruby/object:Gem::Requirement
|
254
254
|
requirements:
|
255
255
|
- - "~>"
|
256
256
|
- !ruby/object:Gem::Version
|
257
|
-
version:
|
257
|
+
version: 2.0.0
|
258
258
|
type: :runtime
|
259
259
|
prerelease: false
|
260
260
|
version_requirements: !ruby/object:Gem::Requirement
|
261
261
|
requirements:
|
262
262
|
- - "~>"
|
263
263
|
- !ruby/object:Gem::Version
|
264
|
-
version:
|
264
|
+
version: 2.0.0
|
265
265
|
- !ruby/object:Gem::Dependency
|
266
266
|
name: metanorma-generic
|
267
267
|
requirement: !ruby/object:Gem::Requirement
|
268
268
|
requirements:
|
269
269
|
- - "~>"
|
270
270
|
- !ruby/object:Gem::Version
|
271
|
-
version:
|
271
|
+
version: 2.0.0
|
272
272
|
type: :runtime
|
273
273
|
prerelease: false
|
274
274
|
version_requirements: !ruby/object:Gem::Requirement
|
275
275
|
requirements:
|
276
276
|
- - "~>"
|
277
277
|
- !ruby/object:Gem::Version
|
278
|
-
version:
|
278
|
+
version: 2.0.0
|
279
279
|
- !ruby/object:Gem::Dependency
|
280
280
|
name: metanorma-m3aawg
|
281
281
|
requirement: !ruby/object:Gem::Requirement
|
282
282
|
requirements:
|
283
283
|
- - "~>"
|
284
284
|
- !ruby/object:Gem::Version
|
285
|
-
version:
|
285
|
+
version: 2.0.0
|
286
286
|
type: :runtime
|
287
287
|
prerelease: false
|
288
288
|
version_requirements: !ruby/object:Gem::Requirement
|
289
289
|
requirements:
|
290
290
|
- - "~>"
|
291
291
|
- !ruby/object:Gem::Version
|
292
|
-
version:
|
292
|
+
version: 2.0.0
|
293
293
|
- !ruby/object:Gem::Dependency
|
294
294
|
name: metanorma-standoc
|
295
295
|
requirement: !ruby/object:Gem::Requirement
|
296
296
|
requirements:
|
297
297
|
- - "~>"
|
298
298
|
- !ruby/object:Gem::Version
|
299
|
-
version:
|
299
|
+
version: 2.0.0
|
300
300
|
type: :runtime
|
301
301
|
prerelease: false
|
302
302
|
version_requirements: !ruby/object:Gem::Requirement
|
303
303
|
requirements:
|
304
304
|
- - "~>"
|
305
305
|
- !ruby/object:Gem::Version
|
306
|
-
version:
|
306
|
+
version: 2.0.0
|
307
307
|
- !ruby/object:Gem::Dependency
|
308
308
|
name: git
|
309
309
|
requirement: !ruby/object:Gem::Requirement
|
@@ -324,14 +324,14 @@ dependencies:
|
|
324
324
|
requirements:
|
325
325
|
- - ">="
|
326
326
|
- !ruby/object:Gem::Version
|
327
|
-
version:
|
327
|
+
version: 2.0.0
|
328
328
|
type: :runtime
|
329
329
|
prerelease: false
|
330
330
|
version_requirements: !ruby/object:Gem::Requirement
|
331
331
|
requirements:
|
332
332
|
- - ">="
|
333
333
|
- !ruby/object:Gem::Version
|
334
|
-
version:
|
334
|
+
version: 2.0.0
|
335
335
|
- !ruby/object:Gem::Dependency
|
336
336
|
name: metanorma
|
337
337
|
requirement: !ruby/object:Gem::Requirement
|
@@ -352,56 +352,56 @@ dependencies:
|
|
352
352
|
requirements:
|
353
353
|
- - "~>"
|
354
354
|
- !ruby/object:Gem::Version
|
355
|
-
version: 0.
|
355
|
+
version: 0.5.0
|
356
356
|
type: :runtime
|
357
357
|
prerelease: false
|
358
358
|
version_requirements: !ruby/object:Gem::Requirement
|
359
359
|
requirements:
|
360
360
|
- - "~>"
|
361
361
|
- !ruby/object:Gem::Version
|
362
|
-
version: 0.
|
362
|
+
version: 0.5.0
|
363
363
|
- !ruby/object:Gem::Dependency
|
364
364
|
name: metanorma-itu
|
365
365
|
requirement: !ruby/object:Gem::Requirement
|
366
366
|
requirements:
|
367
367
|
- - "~>"
|
368
368
|
- !ruby/object:Gem::Version
|
369
|
-
version:
|
369
|
+
version: 2.0.0
|
370
370
|
type: :runtime
|
371
371
|
prerelease: false
|
372
372
|
version_requirements: !ruby/object:Gem::Requirement
|
373
373
|
requirements:
|
374
374
|
- - "~>"
|
375
375
|
- !ruby/object:Gem::Version
|
376
|
-
version:
|
376
|
+
version: 2.0.0
|
377
377
|
- !ruby/object:Gem::Dependency
|
378
378
|
name: metanorma-ogc
|
379
379
|
requirement: !ruby/object:Gem::Requirement
|
380
380
|
requirements:
|
381
381
|
- - "~>"
|
382
382
|
- !ruby/object:Gem::Version
|
383
|
-
version:
|
383
|
+
version: 2.0.0
|
384
384
|
type: :runtime
|
385
385
|
prerelease: false
|
386
386
|
version_requirements: !ruby/object:Gem::Requirement
|
387
387
|
requirements:
|
388
388
|
- - "~>"
|
389
389
|
- !ruby/object:Gem::Version
|
390
|
-
version:
|
390
|
+
version: 2.0.0
|
391
391
|
- !ruby/object:Gem::Dependency
|
392
392
|
name: metanorma-un
|
393
393
|
requirement: !ruby/object:Gem::Requirement
|
394
394
|
requirements:
|
395
395
|
- - "~>"
|
396
396
|
- !ruby/object:Gem::Version
|
397
|
-
version: 0.
|
397
|
+
version: 0.8.0
|
398
398
|
type: :runtime
|
399
399
|
prerelease: false
|
400
400
|
version_requirements: !ruby/object:Gem::Requirement
|
401
401
|
requirements:
|
402
402
|
- - "~>"
|
403
403
|
- !ruby/object:Gem::Version
|
404
|
-
version: 0.
|
404
|
+
version: 0.8.0
|
405
405
|
- !ruby/object:Gem::Dependency
|
406
406
|
name: relaton-cli
|
407
407
|
requirement: !ruby/object:Gem::Requirement
|
@@ -474,6 +474,7 @@ files:
|
|
474
474
|
- i18n.yaml
|
475
475
|
- lib/metanorma-cli.rb
|
476
476
|
- lib/metanorma/cli.rb
|
477
|
+
- lib/metanorma/cli/collection.rb
|
477
478
|
- lib/metanorma/cli/command.rb
|
478
479
|
- lib/metanorma/cli/commands/config.rb
|
479
480
|
- lib/metanorma/cli/commands/site.rb
|