metanorma 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 947d211469e9b00b6d6826c47a94719b2f7beb9d
4
- data.tar.gz: de2ca04366db38eb1289e9ddf99697cac7f11526
3
+ metadata.gz: f58eea8d81a80f20ba3729359a18cbe7f8ab9796
4
+ data.tar.gz: 0a6ab0db7db9cf8df23d352d617ce2c3013b1e8d
5
5
  SHA512:
6
- metadata.gz: 644aa91a35ad74386701aea7d3291fb7ff075027c26c37a4a31bfd71213d571173063da81fba417f3eee719ff8ed9681bd7f048e5bae6ba341619926d3fb445f
7
- data.tar.gz: 59ebf97fec4aaadc2ef7323d66475f2422c25eab5d40aa9f5ba7fbffc3176ce523496a163bbdf27406ed44e131ae72811dc63ee4913725f52345b806f0a65c4b
6
+ metadata.gz: aded98acd0cf4d565ed8708677a0d0ec9edaffedd77897b252638b95be4539cb3aeeee935d3e474d91d44932a72c81f9f7de4c954ebfe95b7e030871ccae1d2f
7
+ data.tar.gz: 45c3a389ebdb0ed01c7e1da1ecd48da4d00aae2d40cc8a8766aa3fbae715ab0ea490ec606180de6b5eb614b25f8c37f0b4839a62036d2b52cf80df3b4fb4970e
data/exe/metanorma CHANGED
@@ -2,41 +2,119 @@
2
2
 
3
3
  require "optparse"
4
4
  require "asciidoctor/cli"
5
- require "asciidoctor/rfc/v2/converter"
6
- require "asciidoctor/rfc/v3/converter"
7
- require "asciidoctor/iso/converter"
8
- require "asciidoctor/gb/converter"
9
- require "asciidoctor/csd/converter"
10
5
 
11
- options = {}
12
- OptionParser.new do |opts|
13
- opts.banner = "Usage: metanorma --type XXX --format FORMAT file"
6
+ supported_backends = [
7
+ {
8
+ short: :rfc2,
9
+ load_path: "asciidoctor/rfc/v2/converter",
10
+ asciidoctor_backend: "rfc2"
11
+ },
14
12
 
15
- opts.on('-t', '--type TYPE', 'Type of standard to generate: rfc2, rfc3, iso, gb, csd') { |v| options[:type] = v }
16
- opts.on('-f', '--format FORMAT', 'Format of source file: asciidoc (current default, only format supported)') { |v| options[:format] = v }
13
+ {
14
+ short: :rfc3,
15
+ load_path: "asciidoctor/rfc/v3/converter",
16
+ asciidoctor_backend: "rfc3"
17
+ },
17
18
 
18
- end.parse!
19
+ {
20
+ short: :iso,
21
+ load_path: "asciidoctor/iso/converter",
22
+ asciidoctor_backend: "iso"
23
+ },
24
+
25
+ {
26
+ short: :gb,
27
+ load_path: "asciidoctor/gb/converter",
28
+ asciidoctor_backend: "gb"
29
+ },
30
+
31
+ {
32
+ short: :csd,
33
+ load_path: "asciidoctor/csd/converter",
34
+ asciidoctor_backend: "csd"
35
+ },
36
+
37
+ # {
38
+ # short: :rsd,
39
+ # load_path: "asciidoctor/rsd/converter",
40
+ # asciidoctor_backend: "rsd"
41
+ # },
42
+ ]
43
+
44
+ print "[metanorma] detecting backends: "
45
+ backends_enabled, backends_disabled = supported_backends.partition do |backend|
46
+ begin
47
+ print "#{backend[:short]} "
48
+ require backend[:load_path]
49
+ true
50
+ rescue LoadError
51
+ # puts "[metanorma] backend #{backend[:short]} not present"
52
+ false
53
+ end
54
+ end
55
+ puts
56
+
57
+ options = {
58
+ format: "asciidoc"
59
+ }
60
+
61
+ backend_keys = backends_enabled.map {|b| b[:short].to_s }
62
+
63
+ opt_parser = OptionParser.new do |opts|
64
+ opts.banner += " <file>"
65
+ opts.on(
66
+ '-t',
67
+ '--type TYPE',
68
+ "Type of standard to generate: #{backend_keys.join(", ")}"
69
+ ) { |v| options[:type] = v }
70
+
71
+ opts.on(
72
+ '-f',
73
+ '--format FORMAT',
74
+ 'Format of source file: asciidoc (current default, only format supported)'
75
+ ) { |v| options[:format] = v }
76
+
77
+ opts.on_tail("-h", "--help", "Show this message") do
78
+ puts opts
79
+ exit
80
+ end
81
+
82
+ end
83
+
84
+ opt_parser.parse!(ARGV)
85
+ options[:filename] = ARGV.pop
19
86
 
20
87
  unless options[:type]
21
- puts "You must specify a standard type (metanorma --type XXX file)"
88
+ puts "[metanorma] Error: Please specify a standard type."
89
+ puts opt_parser.help
22
90
  exit 0
23
91
  end
24
- options[:format] = "asciidoc" unless options[:format]
25
92
 
26
- unless %w{rfc2 rfc3 iso gb csd}.include? options[:type]
27
- puts "#{options[:type]} is not a supported standard type"
93
+ unless backend_keys.include? options[:type]
94
+ puts "[metanorma] Error: #{options[:type]} is not a supported standard type."
28
95
  exit 0
29
96
  end
97
+
30
98
  unless options[:format] == "asciidoc"
31
- puts "Only source file format currently supported is asciidoc"
99
+ puts "[metanorma] Error: Only source file format currently supported is 'asciidoc'."
100
+ exit 0
101
+ end
102
+
103
+ unless options[:filename]
104
+ puts "[metanorma] Error: Need to specify a file to process."
32
105
  exit 0
33
106
  end
34
107
 
35
- asciidoc_options = Asciidoctor::Cli::Options.new backend: options[:type], header_footer: true
36
- exit 0 if asciidoc_options.parse!(ARGV) == 0
108
+ asciidoc_options = Asciidoctor::Cli::Options.new(
109
+ backend: options[:type],
110
+ header_footer: true
111
+ )
112
+ if asciidoc_options.parse!([options[:filename]]) == 0
113
+ puts "[metanorma] Error: Backend process error."
114
+ exit 0
115
+ end
37
116
 
38
117
  invoker = Asciidoctor::Cli::Invoker.new asciidoc_options
39
118
  GC.start
40
119
  invoker.invoke!
41
120
  exit invoker.code
42
-
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-12 00:00:00.000000000 Z
11
+ date: 2018-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler