metanorma-cli 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6f642e30214c4676fe626fb02c64327b2b1839f818bcdd932bf5153ede74ae7e
4
+ data.tar.gz: 65c927fde19bdfd476c1b080d75a77116883fe7ab985a2461a7b949aa2a5a066
5
+ SHA512:
6
+ metadata.gz: f992a7bdaeac4a5804f2cdedf3410f98c376835067c6d68adb31d7220b43b5a29d866c3f0dd4d383cf660caac7b628dcc877620e8bdd1021ad75cbdf8c767a4a
7
+ data.tar.gz: fa25c5d7e52904aae5349908dcec7732a1024f423934a1d3b7873df689bad107fd806fb81b4ad49a94b3075cf2a7095d2326b7b2282e4ec8f5a48ced2934689d
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ BSD 2-Clause License
2
+
3
+ Copyright (c) 2018, Ribose
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,9 @@
1
+ = metanorma-cli
2
+ Command line script for Metanorma
3
+
4
+ image:https://img.shields.io/gem/v/metanorma-cli.svg["Gem Version", link="https://rubygems.org/gems/metanorma-cli"]
5
+ image:https://img.shields.io/travis/riboseinc/metanorma-cli/master.svg["Build Status", link="https://travis-ci.org/riboseinc/metanorma-cli"]
6
+ image:https://codeclimate.com/github/riboseinc/metanorma-cli/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/riboseinc/metanorma-cli"]
7
+
8
+
9
+ Refer https://github.com/riboseinc/metanorma
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "optparse"
4
+ require "metanorma"
5
+
6
+ registry = Metanorma::Registry.instance
7
+
8
+ supported_gem_paths = [
9
+ "asciidoctor-rfc",
10
+ "asciidoctor-iso",
11
+ "asciidoctor-gb",
12
+ "asciidoctor-csd",
13
+ "asciidoctor-csand",
14
+ "asciidoctor-m3d",
15
+ "asciidoctor-rsd"
16
+ ]
17
+
18
+ puts "[metanorma] detecting backends:"
19
+ supported_gem_paths.each do |backend|
20
+ begin
21
+ puts backend
22
+ require backend
23
+ rescue LoadError
24
+ puts "[metanorma] backend #{backend} not present"
25
+ end
26
+ end
27
+ puts
28
+
29
+ options = {
30
+ format: :asciidoc
31
+ }
32
+ opt_parser = OptionParser.new do |opts|
33
+ opts.banner += " <file>"
34
+ opts.on(
35
+ '-t',
36
+ '--type TYPE',
37
+ "Type of standard to generate: #{registry.supported_backends.join(", ")}"
38
+ ) { |v| options[:type] = v.to_sym }
39
+
40
+ opts.on(
41
+ '-x',
42
+ '--extensions EXT1,EXT2,...',
43
+ Array,
44
+ "Type of extension to generate per type: #{registry.output_formats}\n"
45
+ ) { |v| options[:extension_keys] = v.map(&:to_sym) }
46
+
47
+ opts.on(
48
+ '-f',
49
+ '--format FORMAT',
50
+ 'Format of source file: asciidoc (current default, only format supported)'
51
+ ) { |v| options[:format] = v.to_sym }
52
+
53
+ opts.on(
54
+ '-r',
55
+ '--require LIBRARY',
56
+ 'Require LIBRARY prior to execution'
57
+ ) { |v|
58
+ options[:require] ||= []
59
+ options[:require] << v
60
+ }
61
+
62
+ opts.on(
63
+ '-v',
64
+ '--version',
65
+ "Print version of code (accompanied with -t)",
66
+ ) { options[:version] = true }
67
+
68
+ opts.on_tail("-h", "--help", "Show this message") do
69
+ puts opts
70
+ exit
71
+ end
72
+
73
+ end
74
+
75
+ opt_parser.parse!(ARGV)
76
+
77
+ if options[:version]
78
+ case options[:format]
79
+ when :asciidoc
80
+ processor = registry.find_processor(options[:type].to_sym)
81
+ puts processor.version
82
+ exit
83
+ end
84
+ end
85
+
86
+ options[:filename] = ARGV.pop
87
+
88
+ unless options[:type]
89
+ puts "[metanorma] Error: Please specify a standard type."
90
+ puts opt_parser.help
91
+ exit 0
92
+ end
93
+
94
+ unless registry.supported_backends.include? options[:type]
95
+ puts "[metanorma] Error: #{options[:type]} is not a supported standard type."
96
+ exit 0
97
+ end
98
+
99
+ unless options[:format] == :asciidoc
100
+ puts "[metanorma] Error: Only source file format currently supported is 'asciidoc'."
101
+ exit 0
102
+ end
103
+
104
+ unless options[:filename]
105
+ puts "[metanorma] Error: Need to specify a file to process."
106
+ exit 0
107
+ end
108
+
109
+ if options[:require]
110
+ options[:require].each do |r|
111
+ require r
112
+ end
113
+ end
114
+
115
+ case options[:format]
116
+ when :asciidoc
117
+ processor = registry.find_processor(options[:type].to_sym)
118
+ options[:extension_keys] ||= processor.output_formats.inject([]) do |memo, (k, _)|
119
+ memo << k; memo
120
+ end
121
+ extensions = options[:extension_keys].inject([]) do |memo, e|
122
+ if processor.output_formats[e]
123
+ memo << e
124
+ else
125
+ warn "[metanorma] Error: #{e} format is not supported for this standard"
126
+ end
127
+ memo
128
+ end
129
+ exit 0 if extensions.empty?
130
+
131
+ file = File.read(options[:filename], encoding: "utf-8")
132
+ isodoc = processor.input_to_isodoc(file)
133
+ isodoc_options = processor.extract_options(file)
134
+ extensions.each do |ext|
135
+ file_extension = processor.output_formats[ext]
136
+ outfilename = options[:filename].sub(/\.[^.]+$/, ".#{file_extension}")
137
+ processor.output(isodoc, outfilename, ext, isodoc_options)
138
+ end
139
+ end
140
+
@@ -0,0 +1,6 @@
1
+ require "metanorma-cli/version"
2
+
3
+ module Metanorma
4
+ module CLI
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Metanorma
2
+ module CLI
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,42 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "metanorma-cli/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "metanorma-cli"
8
+ spec.version = Metanorma::CLI::VERSION
9
+ spec.authors = ['Ribose Inc.']
10
+ spec.email = ['open.source@ribose.com']
11
+
12
+ spec.summary = %q{Metanorma is the standard of standards; the metanorma gem allows you to create any standard document type supported by Metanorma.}
13
+ spec.description = %q{Executable to process any Metanorma standard.}
14
+ spec.homepage = "https://github.com/riboseinc/metanorma"
15
+ spec.license = "BSD-2-Clause"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.extra_rdoc_files = %w[README.adoc LICENSE]
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.required_ruby_version = '>= 2.4.0'
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.16"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "rspec", "~> 3.0"
30
+ spec.add_development_dependency "byebug", "~> 10.0"
31
+ spec.add_development_dependency "rspec-command", "~> 1.0.3"
32
+ spec.add_development_dependency "equivalent-xml", "~> 0.6"
33
+
34
+ spec.add_runtime_dependency 'asciidoctor-iso', ">= 0.9.1"
35
+ spec.add_runtime_dependency 'asciidoctor-rfc', ">= 0.9.0"
36
+ spec.add_runtime_dependency 'asciidoctor-gb', ">= 0.3.0"
37
+ spec.add_runtime_dependency 'asciidoctor-csd', ">= 0.4.0"
38
+ spec.add_runtime_dependency 'asciidoctor-csand', ">= 0.3.0"
39
+ spec.add_runtime_dependency 'asciidoctor-rsd', ">= 0.3.0"
40
+ spec.add_runtime_dependency 'asciidoctor-m3d', ">= 0.3.1"
41
+ spec.add_runtime_dependency 'isodoc', ">= 0.8.0"
42
+ end
metadata ADDED
@@ -0,0 +1,250 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: metanorma-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ribose Inc.
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-07-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-command
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.0.3
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.0.3
83
+ - !ruby/object:Gem::Dependency
84
+ name: equivalent-xml
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.6'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.6'
97
+ - !ruby/object:Gem::Dependency
98
+ name: asciidoctor-iso
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 0.9.1
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 0.9.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: asciidoctor-rfc
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 0.9.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 0.9.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: asciidoctor-gb
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: 0.3.0
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: 0.3.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: asciidoctor-csd
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: 0.4.0
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: 0.4.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: asciidoctor-csand
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: 0.3.0
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: 0.3.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: asciidoctor-rsd
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: 0.3.0
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: 0.3.0
181
+ - !ruby/object:Gem::Dependency
182
+ name: asciidoctor-m3d
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: 0.3.1
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: 0.3.1
195
+ - !ruby/object:Gem::Dependency
196
+ name: isodoc
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: 0.8.0
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: 0.8.0
209
+ description: Executable to process any Metanorma standard.
210
+ email:
211
+ - open.source@ribose.com
212
+ executables:
213
+ - metanorma
214
+ extensions: []
215
+ extra_rdoc_files:
216
+ - README.adoc
217
+ - LICENSE
218
+ files:
219
+ - LICENSE
220
+ - README.adoc
221
+ - exe/metanorma
222
+ - lib/metanorma-cli.rb
223
+ - lib/metanorma-cli/version.rb
224
+ - metanorma-cli.gemspec
225
+ homepage: https://github.com/riboseinc/metanorma
226
+ licenses:
227
+ - BSD-2-Clause
228
+ metadata: {}
229
+ post_install_message:
230
+ rdoc_options: []
231
+ require_paths:
232
+ - lib
233
+ required_ruby_version: !ruby/object:Gem::Requirement
234
+ requirements:
235
+ - - ">="
236
+ - !ruby/object:Gem::Version
237
+ version: 2.4.0
238
+ required_rubygems_version: !ruby/object:Gem::Requirement
239
+ requirements:
240
+ - - ">="
241
+ - !ruby/object:Gem::Version
242
+ version: '0'
243
+ requirements: []
244
+ rubyforge_project:
245
+ rubygems_version: 2.7.6
246
+ signing_key:
247
+ specification_version: 4
248
+ summary: Metanorma is the standard of standards; the metanorma gem allows you to create
249
+ any standard document type supported by Metanorma.
250
+ test_files: []