metanorma-cli 1.0.10 → 1.1.0

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
  SHA256:
3
- metadata.gz: 90c858bc93e81710dc43eb24db299fa904c44d83cb8dc730d64a0aab4b77e1fc
4
- data.tar.gz: df422215603206c9bb1d1ea54deb1eab7bc80022f9d837af65904a48b6e15d8d
3
+ metadata.gz: 4f4ec2501edab351ae644b2b9a58173c482f9afa69892bdb4e860b3f1afd42ef
4
+ data.tar.gz: 1d5abdfa595f65625ba3a72ab72ec7be76ce446753a0c670c51e9960dfb6b55d
5
5
  SHA512:
6
- metadata.gz: 961c8c87d11e4e0d76cab2bd554968667a4d994d1d0043336cd392ee9e287ed2645e353dc597ea1fe289ef6652f2aaa2edb1fd10e2573a3caef631b3b4bd0709
7
- data.tar.gz: e163041d83221671afb73b2fb377d608c0f0923b044965bbe65fef66cffed1ef93e7640fd2eb3891a3e7a5a7b1451ba7df0b35de2a2d27c0b4c1b934bd2bb179
6
+ metadata.gz: f29dc0e5db47e3945d5923e2b417bc48b60c1b5b6b71044e668c6755a23195f7f15364bfdcf4a10f270cb1cbc208a1c36e6591b1922c435000ec1a4de7c8f5b8
7
+ data.tar.gz: 1e6e5420e59feb41f877a765a779c1636173e40619a544df45e2d9f37aacb5021c246398db82d76e79d42f5dcb6ea7bdb02f324f4823090da300c79d19d5d24e
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at ronald.tse@ribose.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
@@ -0,0 +1,253 @@
1
+ GIT
2
+ remote: https://github.com/asciidoctor/asciimath.git
3
+ revision: c4b00e4667fd68ab7d169fd5204e4a17d1707163
4
+ specs:
5
+ asciimath (1.0.7.pre1)
6
+
7
+ PATH
8
+ remote: .
9
+ specs:
10
+ metanorma-cli (1.0.10)
11
+ isodoc (~> 0.9.0)
12
+ metanorma (~> 0.3.5)
13
+ metanorma-acme (~> 1.0.1)
14
+ metanorma-csand (~> 1.0.5)
15
+ metanorma-csd (~> 1.0.5)
16
+ metanorma-gb (~> 1.0.5)
17
+ metanorma-ietf (~> 1.0)
18
+ metanorma-iso (~> 1.0.6)
19
+ metanorma-m3d (~> 1.0.6)
20
+ metanorma-mpfd (~> 0.1.0)
21
+ metanorma-rsd (~> 1.0.5)
22
+ metanorma-standoc (~> 1.0.6)
23
+ metanorma-unece (~> 0.0.1)
24
+ nokogiri
25
+
26
+ GEM
27
+ remote: https://rubygems.org/
28
+ specs:
29
+ addressable (2.5.2)
30
+ public_suffix (>= 2.0.2, < 4.0)
31
+ algoliasearch (1.25.2)
32
+ httpclient (~> 2.8, >= 2.8.3)
33
+ json (>= 1.5.1)
34
+ asciidoctor (1.5.8)
35
+ byebug (10.0.2)
36
+ camertron-eprun (1.1.1)
37
+ cldr-plurals-runtime-rb (1.0.1)
38
+ cnccs (0.1.3)
39
+ concurrent-ruby (1.1.4)
40
+ diff-lcs (1.3)
41
+ equivalent-xml (0.6.0)
42
+ nokogiri (>= 1.4.3)
43
+ ffi (1.9.25)
44
+ gb-agencies (0.0.5)
45
+ gbbib (0.4.3)
46
+ cnccs (~> 0.1.1)
47
+ gb-agencies (~> 0.0.1)
48
+ iso-bib-item (~> 0.4.2)
49
+ html2doc (0.8.6)
50
+ asciimath
51
+ htmlentities (~> 4.3.4)
52
+ image_size
53
+ mime-types
54
+ nokogiri
55
+ ruby-xslt
56
+ thread_safe
57
+ uuidtools
58
+ htmlentities (4.3.4)
59
+ httpclient (2.8.3)
60
+ iecbib (0.2.2)
61
+ addressable
62
+ iso-bib-item (~> 0.4.2)
63
+ ietfbib (0.4.5)
64
+ iso-bib-item (~> 0.4.2)
65
+ iev (0.2.0)
66
+ nokogiri
67
+ image_size (2.0.0)
68
+ iso-639 (0.2.8)
69
+ iso-bib-item (0.4.4)
70
+ isoics (~> 0.1.6)
71
+ nokogiri (~> 1.8.4)
72
+ ruby_deep_clone (~> 0.8.0)
73
+ isobib (0.4.2)
74
+ algoliasearch
75
+ iecbib (~> 0.2.1)
76
+ iso-bib-item (~> 0.4.2)
77
+ isodoc (0.9.13)
78
+ asciimath
79
+ html2doc (~> 0.8.6)
80
+ htmlentities (~> 4.3.4)
81
+ liquid
82
+ metanorma (~> 0.3.0)
83
+ nokogiri
84
+ rake (~> 12.0)
85
+ roman-numerals
86
+ ruby-xslt
87
+ sassc (~> 1.12.1)
88
+ thread_safe
89
+ uuidtools
90
+ isoics (0.1.7)
91
+ json (2.1.0)
92
+ liquid (4.0.1)
93
+ metanorma (0.3.5)
94
+ asciidoctor
95
+ metanorma-acme (1.0.8)
96
+ asciidoctor (~> 1.5.7)
97
+ htmlentities (~> 4.3.4)
98
+ isodoc (~> 0.9.0)
99
+ metanorma-standoc (~> 1.0.8)
100
+ ruby-jing
101
+ metanorma-csand (1.0.11)
102
+ asciidoctor (~> 1.5.7)
103
+ asciimath
104
+ htmlentities (~> 4.3.4)
105
+ image_size
106
+ isodoc (~> 0.9.0)
107
+ metanorma-standoc (~> 1.0.0)
108
+ mime-types
109
+ nokogiri
110
+ ruby-jing
111
+ ruby-xslt
112
+ thread_safe
113
+ uuidtools
114
+ metanorma-csd (1.0.13)
115
+ isodoc (~> 0.9.6)
116
+ metanorma-standoc (~> 1.0.0)
117
+ metanorma-gb (1.0.11)
118
+ gb-agencies (~> 0.0.4)
119
+ isodoc (~> 0.9.1)
120
+ metanorma-iso (~> 1.0.1)
121
+ twitter_cldr
122
+ metanorma-ietf (1.0.0)
123
+ isodoc (~> 0.9.6)
124
+ metanorma-standoc (~> 1.0.0)
125
+ metanorma-iso (1.0.12)
126
+ asciidoctor (~> 1.5.7)
127
+ iev (~> 0.2.0)
128
+ isodoc (~> 0.9.8)
129
+ metanorma-standoc (~> 1.0.0)
130
+ ruby-jing
131
+ metanorma-m3d (1.0.12)
132
+ asciidoctor (~> 1.5.7)
133
+ asciimath
134
+ htmlentities (~> 4.3.4)
135
+ image_size
136
+ isodoc (~> 0.9.0)
137
+ metanorma-standoc (~> 1.0.0)
138
+ mime-types
139
+ nokogiri
140
+ ruby-jing
141
+ ruby-xslt
142
+ thread_safe
143
+ uuidtools
144
+ metanorma-mpfd (0.1.4)
145
+ asciidoctor (~> 1.5.7)
146
+ htmlentities (~> 4.3.4)
147
+ isodoc (~> 0.9.0)
148
+ metanorma-standoc (~> 1.0.0)
149
+ nokogiri
150
+ twitter_cldr
151
+ metanorma-rsd (1.0.12)
152
+ asciidoctor (~> 1.5.7)
153
+ htmlentities (~> 4.3.4)
154
+ isodoc (~> 0.9.0)
155
+ metanorma-standoc (~> 1.0.0)
156
+ nokogiri
157
+ metanorma-standoc (1.0.13)
158
+ asciidoctor (~> 1.5.7)
159
+ concurrent-ruby
160
+ iev (~> 0.2.0)
161
+ isodoc (~> 0.9.0)
162
+ relaton (~> 0.3.1)
163
+ ruby-jing
164
+ sterile
165
+ metanorma-unece (0.0.7)
166
+ asciidoctor (~> 1.5.7)
167
+ htmlentities (~> 4.3.4)
168
+ iso-639
169
+ isodoc (~> 0.9.0)
170
+ metanorma-standoc (~> 1.0.0)
171
+ roman-numerals
172
+ ruby-jing
173
+ twitter_cldr
174
+ mime-types (3.2.2)
175
+ mime-types-data (~> 3.2015)
176
+ mime-types-data (3.2018.0812)
177
+ mini_portile2 (2.3.0)
178
+ mixlib-shellout (2.4.4)
179
+ nokogiri (1.8.5)
180
+ mini_portile2 (~> 2.3.0)
181
+ optout (0.0.2)
182
+ public_suffix (3.0.3)
183
+ rake (12.3.2)
184
+ rb-fsevent (0.10.3)
185
+ rb-inotify (0.10.0)
186
+ ffi (~> 1.0)
187
+ relaton (0.3.1)
188
+ algoliasearch
189
+ gbbib (~> 0.4.0)
190
+ iecbib (~> 0.2.0)
191
+ ietfbib (~> 0.4.2)
192
+ iso-bib-item (~> 0.4.2)
193
+ isobib (~> 0.4.0)
194
+ roman-numerals (0.3.0)
195
+ rspec (3.8.0)
196
+ rspec-core (~> 3.8.0)
197
+ rspec-expectations (~> 3.8.0)
198
+ rspec-mocks (~> 3.8.0)
199
+ rspec-command (1.0.3)
200
+ mixlib-shellout (~> 2.0)
201
+ rspec (~> 3.2)
202
+ rspec-its (~> 1.2)
203
+ rspec-core (3.8.0)
204
+ rspec-support (~> 3.8.0)
205
+ rspec-expectations (3.8.2)
206
+ diff-lcs (>= 1.2.0, < 2.0)
207
+ rspec-support (~> 3.8.0)
208
+ rspec-its (1.2.0)
209
+ rspec-core (>= 3.0.0)
210
+ rspec-expectations (>= 3.0.0)
211
+ rspec-mocks (3.8.0)
212
+ diff-lcs (>= 1.2.0, < 2.0)
213
+ rspec-support (~> 3.8.0)
214
+ rspec-support (3.8.0)
215
+ ruby-jing (0.0.1)
216
+ optout (>= 0.0.2)
217
+ ruby-xslt (0.9.10)
218
+ ruby_deep_clone (0.8.0)
219
+ sass (3.7.2)
220
+ sass-listen (~> 4.0.0)
221
+ sass-listen (4.0.0)
222
+ rb-fsevent (~> 0.9, >= 0.9.4)
223
+ rb-inotify (~> 0.9, >= 0.9.7)
224
+ sassc (1.12.1)
225
+ ffi (~> 1.9.6)
226
+ sass (>= 3.3.0)
227
+ sterile (1.0.13)
228
+ nokogiri
229
+ thread_safe (0.3.6)
230
+ twitter_cldr (4.4.3)
231
+ camertron-eprun
232
+ cldr-plurals-runtime-rb (~> 1.0)
233
+ tzinfo
234
+ tzinfo (2.0.0)
235
+ concurrent-ruby (~> 1.0)
236
+ uuidtools (2.1.5)
237
+
238
+ PLATFORMS
239
+ ruby
240
+
241
+ DEPENDENCIES
242
+ asciimath!
243
+ bundler (~> 1.16)
244
+ byebug (~> 10.0)
245
+ equivalent-xml (~> 0.6)
246
+ metanorma-cli!
247
+ rake (~> 12.0)
248
+ rspec (~> 3.0)
249
+ rspec-command (~> 1.0.3)
250
+ rspec-core (~> 3.4)
251
+
252
+ BUNDLED WITH
253
+ 1.17.3
data/a ADDED
@@ -0,0 +1 @@
1
+ git add lib/metanorma/cli/version.rb metanorma-cli.gemspec
data/a.rb ADDED
@@ -0,0 +1,13 @@
1
+ def a
2
+ validate or return nil
3
+ puts "OK"
4
+ end
5
+
6
+ def validate
7
+ unless false
8
+ return nil
9
+ end
10
+ true
11
+ end
12
+
13
+ a
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "metanorma/cli"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
Binary file
Binary file
@@ -7,17 +7,7 @@ require "nokogiri"
7
7
  require "metanorma-cli"
8
8
 
9
9
  registry = Metanorma::Registry.instance
10
-
11
- puts "[metanorma] detecting backends:"
12
- Metanorma::CLI::SUPPORTED_GEMS.each do |backend|
13
- begin
14
- # puts backend
15
- require backend
16
- rescue LoadError
17
- puts "[metanorma] Error: backend #{backend} not present"
18
- end
19
- end
20
- # puts
10
+ Metanorma::Cli.load_flavors
21
11
 
22
12
  options = {
23
13
  format: :asciidoc
@@ -5,23 +5,14 @@ require "optparse"
5
5
  require "metanorma"
6
6
  require "uuidtools"
7
7
  require "uri"
8
+ require "metanorma-cli"
8
9
 
9
10
  registry = Metanorma::Registry.instance
10
-
11
- puts "[metanorma] detecting backends:"
12
- Metanorma::CLI::SUPPORTED_GEMS.each do |backend|
13
- begin
14
- puts backend
15
- require backend
16
- rescue LoadError
17
- puts "[metanorma] backend #{backend} not present"
18
- end
19
- end
20
- puts
11
+ Metanorma::Cli.load_flavors
21
12
 
22
13
  options = {}
23
14
 
24
- def uuid()
15
+ def uuid
25
16
  UUIDTools::UUID.random_create
26
17
  end
27
18
 
@@ -0,0 +1,178 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "optparse"
4
+ require "metanorma"
5
+ require "fileutils"
6
+ require "nokogiri"
7
+
8
+ registry = Metanorma::Registry.instance
9
+
10
+ supported_gem_paths = [
11
+ "asciidoctor-rfc",
12
+ "metanorma-iso",
13
+ "metanorma-gb",
14
+ "metanorma-csd",
15
+ "metanorma-csand",
16
+ "metanorma-m3d",
17
+ "metanorma-rsd",
18
+ "metanorma-acme",
19
+ "metanorma-standoc",
20
+ ]
21
+
22
+ puts "[metanorma] detecting backends:"
23
+ supported_gem_paths.each do |backend|
24
+ begin
25
+ puts backend
26
+ require backend
27
+ rescue LoadError
28
+ puts "[metanorma] backend #{backend} not present"
29
+ end
30
+ end
31
+ puts
32
+
33
+ options = {
34
+ format: :asciidoc
35
+ }
36
+ opt_parser = OptionParser.new do |opts|
37
+ opts.banner += " <file>"
38
+ opts.on(
39
+ '-t',
40
+ '--type TYPE',
41
+ "Type of standard to generate: #{registry.supported_backends.join(", ")}"
42
+ ) { |v| options[:type] = v.to_sym }
43
+
44
+ opts.on(
45
+ '-x',
46
+ '--extensions EXT1,EXT2,... | all',
47
+ Array,
48
+ "Type of extension to generate per type: #{registry.output_formats}\n"
49
+ ) { |v| options[:extension_keys] = v.map(&:to_sym) }
50
+
51
+ opts.on(
52
+ '-f',
53
+ '--format FORMAT',
54
+ 'Format of source file: asciidoc (current default, only format supported)'
55
+ ) { |v| options[:format] = v.to_sym }
56
+
57
+ opts.on(
58
+ '-r',
59
+ '--require LIBRARY',
60
+ 'Require LIBRARY prior to execution'
61
+ ) { |v|
62
+ options[:require] ||= []
63
+ options[:require] << v
64
+ }
65
+
66
+ opts.on(
67
+ '-v',
68
+ '--version',
69
+ "Print version of code (accompanied with -t)",
70
+ ) { options[:version] = true }
71
+
72
+ opts.on(
73
+ '-w',
74
+ '--wrapper',
75
+ 'Create wrapper folder for HTML output'
76
+ ) { options[:wrapper] = true }
77
+
78
+ opts.on(
79
+ '-d',
80
+ '--data-uri-image',
81
+ 'Encode HTML output images as data URIs'
82
+ ) { options[:datauriimage] = true }
83
+
84
+ opts.on(
85
+ '-R',
86
+ '--relaton FILENAME',
87
+ 'Export Relaton XML for document to nominated filename'
88
+ ) { |v| options[:relaton] = v }
89
+
90
+ opts.on_tail("-h", "--help", "Show this message") do
91
+ puts opts
92
+ exit
93
+ end
94
+
95
+ end
96
+
97
+ opt_parser.parse!(ARGV)
98
+
99
+ if options[:require]
100
+ options[:require].each do |r|
101
+ require r
102
+ end
103
+ end
104
+
105
+ if options[:version]
106
+ case options[:format]
107
+ when :asciidoc
108
+ processor = registry.find_processor(options[:type].to_sym)
109
+ puts processor.version
110
+ exit
111
+ end
112
+ end
113
+
114
+ options[:filename] = ARGV.pop
115
+
116
+ unless options[:type]
117
+ puts "[metanorma] Error: Please specify a standard type."
118
+ puts opt_parser.help
119
+ exit 0
120
+ end
121
+
122
+ unless registry.supported_backends.include? options[:type]
123
+ puts "[metanorma] Error: #{options[:type]} is not a supported standard type."
124
+ exit 0
125
+ end
126
+
127
+ unless options[:format] == :asciidoc
128
+ puts "[metanorma] Error: Only source file format currently supported is 'asciidoc'."
129
+ exit 0
130
+ end
131
+
132
+ unless options[:filename]
133
+ puts "[metanorma] Error: Need to specify a file to process."
134
+ exit 0
135
+ end
136
+
137
+ options[:extension_keys] = nil if options[:extension_keys] == [:all]
138
+
139
+ case options[:format]
140
+ when :asciidoc
141
+ processor = registry.find_processor(options[:type].to_sym)
142
+ options[:extension_keys] ||= processor.output_formats.inject([]) do |memo, (k, _)|
143
+ memo << k; memo
144
+ end
145
+ extensions = options[:extension_keys].inject([]) do |memo, e|
146
+ if processor.output_formats[e]
147
+ memo << e
148
+ else
149
+ warn "[metanorma] Error: #{e} format is not supported for this standard"
150
+ end
151
+ memo
152
+ end
153
+ exit 0 if extensions.empty?
154
+
155
+ file = File.read(options[:filename], encoding: "utf-8")
156
+ isodoc = processor.input_to_isodoc(file)
157
+ if options[:relaton]
158
+ xml = Nokogiri::XML(isodoc)
159
+ bibdata = xml.at("//xmlns:bibdata")
160
+ #docid = bibdata&.at("./xmlns:docidentifier")&.text || options[:filename]
161
+ #outname = docid.sub(/^\s+/, "").sub(/\s+$/, "").gsub(/\s+/, "-") + ".xml"
162
+ File.open(options[:relaton], "w:UTF-8") { |f| f.write bibdata.to_xml }
163
+ end
164
+ isodoc_options = processor.extract_options(file)
165
+ isodoc_options[:datauriimage] = true if options[:datauriimage]
166
+ extensions.each do |ext|
167
+ file_extension = processor.output_formats[ext]
168
+ outfilename = options[:filename].sub(/\.[^.]+$/, ".#{file_extension}")
169
+ processor.output(isodoc, outfilename, ext, isodoc_options)
170
+ if options[:wrapper] and /html$/.match file_extension
171
+ outfilename = outfilename.sub(/\.html$/, "")
172
+ FileUtils.mkdir_p outfilename
173
+ FileUtils.mv "#{outfilename}.html", outfilename
174
+ FileUtils.mv "#{outfilename}_images", outfilename
175
+ end
176
+ end
177
+ end
178
+