metanorma-cli 1.1.6 → 1.1.7

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: d6a9cbd149506055cfacef18d4d480b75c749ef06581c37a2f3867e5cb3c7efe
4
- data.tar.gz: a5cb8f93eea8b289bcfb078a33f4469b7de71ae9177d547bb310e03915490675
3
+ metadata.gz: 8fa38ce1860b4256de0f9b4ce25208f31163d83868104767c173f506297613fa
4
+ data.tar.gz: 90b8fbd71d13c04c842152a4c3e398e2a8764f9e146ca108c060554248e82f60
5
5
  SHA512:
6
- metadata.gz: b1132b67a377d9102dde1f195de27ae799e72d4129a613fcf81a662b6a75841935267a2777cc784f9f7964a9d176c8cffed9133367573f5b8942af01296f30f7
7
- data.tar.gz: a778b63c1890eada45ab18be45a612caa23bf83aa02803fa9a89d5cf389ed404302f81cff9b866ecb430fb924ad228fdc34025276c0000c6049b4b52ad91a41b
6
+ metadata.gz: bcd81d875a2284810beb475c6034968119c135a8bc972ca5d09a57157c9d22c7c3e9c780867a6b1bf37675c1fc81cb6c1291460e868dd2e34b3e3a088be83815
7
+ data.tar.gz: 3019e193d3e6d9ece09644a965419f49470f6404de69e1c5e8726536cbc0581649f7ebaa6f7bec40798867c0f2f2a4b37b61a89586dd4212f6a391c5c168e1b1
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- metanorma-cli (1.1.6)
4
+ metanorma-cli (1.1.7)
5
+ git (~> 1.5)
5
6
  isodoc (~> 0.9.0)
6
7
  metanorma (~> 0.3.9)
7
8
  metanorma-acme (~> 1.1.0)
@@ -18,6 +19,7 @@ PATH
18
19
  metanorma-standoc (~> 1.1.0)
19
20
  metanorma-unece (~> 0.0.1)
20
21
  nokogiri (>= 1)
22
+ thor (~> 0.20.3)
21
23
 
22
24
  GEM
23
25
  remote: https://rubygems.org/
@@ -39,17 +41,17 @@ GEM
39
41
  nokogiri (>= 1.4.3)
40
42
  ffi (1.9.25)
41
43
  gb-agencies (0.0.5)
42
- gbbib (0.4.3)
44
+ gbbib (0.4.4)
43
45
  cnccs (~> 0.1.1)
44
46
  gb-agencies (~> 0.0.1)
45
47
  iso-bib-item (~> 0.4.2)
46
- html2doc (0.8.9)
48
+ git (1.5.0)
49
+ html2doc (0.8.10)
47
50
  asciimath (~> 1.0.7)
48
51
  htmlentities (~> 4.3.4)
49
52
  image_size
50
53
  mime-types
51
54
  nokogiri
52
- ruby-xslt
53
55
  thread_safe
54
56
  uuidtools
55
57
  htmlentities (4.3.4)
@@ -57,21 +59,21 @@ GEM
57
59
  iecbib (0.2.2)
58
60
  addressable
59
61
  iso-bib-item (~> 0.4.2)
60
- ietfbib (0.4.5)
62
+ ietfbib (0.4.6)
61
63
  iso-bib-item (~> 0.4.2)
62
- iev (0.2.1)
64
+ iev (0.2.2)
63
65
  nokogiri
64
66
  image_size (2.0.0)
65
67
  iso-639 (0.2.8)
66
- iso-bib-item (0.4.4)
68
+ iso-bib-item (0.4.5)
67
69
  isoics (~> 0.1.6)
68
70
  nokogiri (~> 1.8.4)
69
71
  ruby_deep_clone (~> 0.8.0)
70
- isobib (0.4.3)
72
+ isobib (0.4.4)
71
73
  algoliasearch
72
74
  iecbib (~> 0.2.1)
73
75
  iso-bib-item (~> 0.4.2)
74
- isodoc (0.9.19)
76
+ isodoc (0.9.22)
75
77
  asciimath
76
78
  html2doc (~> 0.8.6)
77
79
  htmlentities (~> 4.3.4)
@@ -80,23 +82,22 @@ GEM
80
82
  nokogiri (>= 1)
81
83
  rake (~> 12.0)
82
84
  roman-numerals
83
- ruby-xslt
84
85
  sassc (~> 1.12.1)
85
86
  thread_safe
86
87
  uuidtools
87
88
  isoics (0.1.7)
88
89
  json (2.2.0)
89
90
  liquid (4.0.3)
90
- metanorma (0.3.10)
91
+ metanorma (0.3.11)
91
92
  asciidoctor
92
93
  htmlentities
93
- metanorma-acme (1.1.3)
94
+ metanorma-acme (1.1.4)
94
95
  asciidoctor (~> 1.5.7)
95
96
  htmlentities (~> 4.3.4)
96
97
  isodoc (~> 0.9.0)
97
98
  metanorma-standoc (~> 1.1.0)
98
99
  ruby-jing
99
- metanorma-csand (1.1.3)
100
+ metanorma-csand (1.1.5)
100
101
  asciidoctor (~> 1.5.7)
101
102
  asciimath
102
103
  htmlentities (~> 4.3.4)
@@ -106,27 +107,27 @@ GEM
106
107
  mime-types
107
108
  nokogiri
108
109
  ruby-jing
109
- ruby-xslt
110
110
  thread_safe
111
111
  uuidtools
112
- metanorma-csd (1.1.3)
112
+ metanorma-csd (1.1.4)
113
113
  isodoc (~> 0.9.6)
114
114
  metanorma-standoc (~> 1.1.0)
115
- metanorma-gb (1.1.4)
115
+ metanorma-gb (1.1.5)
116
116
  gb-agencies (~> 0.0.4)
117
+ htmlentities (~> 4.3.4)
117
118
  isodoc (~> 0.9.1)
118
119
  metanorma-iso (~> 1.1.0)
119
- twitter_cldr
120
+ twitter_cldr (~> 4.4.4)
120
121
  metanorma-ietf (1.0.1)
121
122
  isodoc (~> 0.9.6)
122
123
  metanorma-standoc (~> 1.1.0)
123
- metanorma-iso (1.1.4)
124
+ metanorma-iso (1.1.5)
124
125
  asciidoctor (~> 1.5.7)
125
126
  iev (~> 0.2.0)
126
127
  isodoc (~> 0.9.8)
127
128
  metanorma-standoc (~> 1.1.0)
128
129
  ruby-jing
129
- metanorma-m3d (1.1.3)
130
+ metanorma-m3d (1.1.5)
130
131
  asciidoctor (~> 1.5.7)
131
132
  asciimath
132
133
  htmlentities (~> 4.3.4)
@@ -136,37 +137,36 @@ GEM
136
137
  mime-types
137
138
  nokogiri
138
139
  ruby-jing
139
- ruby-xslt
140
140
  thread_safe
141
141
  uuidtools
142
- metanorma-mpfd (0.1.9)
142
+ metanorma-mpfd (0.1.10)
143
143
  asciidoctor (~> 1.5.7)
144
144
  htmlentities (~> 4.3.4)
145
145
  isodoc (~> 0.9.0)
146
146
  metanorma-standoc (~> 1.1.0)
147
147
  nokogiri
148
148
  twitter_cldr
149
- metanorma-nist (0.0.5)
149
+ metanorma-nist (0.0.8)
150
150
  asciidoctor (~> 1.5.7)
151
151
  htmlentities (~> 4.3.4)
152
152
  isodoc (~> 0.9.0)
153
153
  metanorma-standoc (~> 1.1.0)
154
154
  ruby-jing
155
155
  twitter_cldr
156
- metanorma-ogc (0.0.7)
156
+ metanorma-ogc (0.0.9)
157
157
  asciidoctor (~> 1.5.7)
158
158
  htmlentities (~> 4.3.4)
159
159
  iso-639
160
160
  isodoc (~> 0.9.0)
161
161
  metanorma-standoc (~> 1.1.0)
162
162
  ruby-jing
163
- metanorma-rsd (1.1.3)
163
+ metanorma-rsd (1.1.4)
164
164
  asciidoctor (~> 1.5.7)
165
165
  htmlentities (~> 4.3.4)
166
166
  isodoc (~> 0.9.0)
167
167
  metanorma-standoc (~> 1.1.0)
168
168
  nokogiri
169
- metanorma-standoc (1.1.5)
169
+ metanorma-standoc (1.1.8)
170
170
  asciidoctor (~> 1.5.7)
171
171
  concurrent-ruby
172
172
  html2doc (~> 0.8.0)
@@ -176,7 +176,7 @@ GEM
176
176
  ruby-jing
177
177
  sterile (~> 1.0.14)
178
178
  unicode2latex (~> 0.0.1)
179
- metanorma-unece (0.0.13)
179
+ metanorma-unece (0.0.14)
180
180
  asciidoctor (~> 1.5.7)
181
181
  htmlentities (~> 4.3.4)
182
182
  iso-639
@@ -187,9 +187,11 @@ GEM
187
187
  twitter_cldr
188
188
  mime-types (3.2.2)
189
189
  mime-types-data (~> 3.2015)
190
- mime-types-data (3.2018.0812)
190
+ mime-types-data (3.2019.0331)
191
191
  mini_portile2 (2.3.0)
192
192
  mixlib-shellout (2.4.4)
193
+ nistbib (0.1.2)
194
+ iso-bib-item (~> 0.4.2)
193
195
  nokogiri (1.8.5)
194
196
  mini_portile2 (~> 2.3.0)
195
197
  optout (0.0.2)
@@ -198,13 +200,14 @@ GEM
198
200
  rb-fsevent (0.10.3)
199
201
  rb-inotify (0.10.0)
200
202
  ffi (~> 1.0)
201
- relaton (0.3.2)
203
+ relaton (0.3.4)
202
204
  algoliasearch
203
205
  gbbib (~> 0.4.0)
204
206
  iecbib (~> 0.2.0)
205
207
  ietfbib (~> 0.4.2)
206
208
  iso-bib-item (~> 0.4.2)
207
209
  isobib (~> 0.4.0)
210
+ nistbib (~> 0.1.1)
208
211
  roman-numerals (0.3.0)
209
212
  rspec (3.8.0)
210
213
  rspec-core (~> 3.8.0)
@@ -216,10 +219,10 @@ GEM
216
219
  rspec-its (~> 1.2)
217
220
  rspec-core (3.8.0)
218
221
  rspec-support (~> 3.8.0)
219
- rspec-expectations (3.8.2)
222
+ rspec-expectations (3.8.3)
220
223
  diff-lcs (>= 1.2.0, < 2.0)
221
224
  rspec-support (~> 3.8.0)
222
- rspec-its (1.2.0)
225
+ rspec-its (1.3.0)
223
226
  rspec-core (>= 3.0.0)
224
227
  rspec-expectations (>= 3.0.0)
225
228
  rspec-mocks (3.8.0)
@@ -228,9 +231,8 @@ GEM
228
231
  rspec-support (3.8.0)
229
232
  ruby-jing (0.0.1)
230
233
  optout (>= 0.0.2)
231
- ruby-xslt (0.9.10)
232
234
  ruby_deep_clone (0.8.0)
233
- sass (3.7.3)
235
+ sass (3.7.4)
234
236
  sass-listen (~> 4.0.0)
235
237
  sass-listen (4.0.0)
236
238
  rb-fsevent (~> 0.9, >= 0.9.4)
@@ -240,8 +242,9 @@ GEM
240
242
  sass (>= 3.3.0)
241
243
  sterile (1.0.14)
242
244
  nokogiri
245
+ thor (0.20.3)
243
246
  thread_safe (0.3.6)
244
- twitter_cldr (4.4.3)
247
+ twitter_cldr (4.4.4)
245
248
  camertron-eprun
246
249
  cldr-plurals-runtime-rb (~> 1.0)
247
250
  tzinfo
@@ -1,5 +1,8 @@
1
1
  version: '{build}'
2
2
 
3
+ cache:
4
+ - vendor/bundle
5
+
3
6
  environment:
4
7
  matrix:
5
8
  - RUBY_VERSION: 25
@@ -17,6 +20,8 @@ install:
17
20
 
18
21
  build_script:
19
22
  - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
23
+ - set GIT_TERMINAL_PROMPT=0
24
+ - bundle config --local path vendor/bundle
20
25
  - bundle update
21
26
  - bundle install
22
27
 
@@ -26,4 +31,4 @@ before_test:
26
31
  - bundle -v
27
32
 
28
33
  test_script:
29
- - bundle exec rake
34
+ - bundle exec rake
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
@@ -1,5 +1,20 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # Note
4
+ #
5
+ # Currently, we are developing a new version for this CLI, and
6
+ # to test it out we adding this environment variable. When the
7
+ # `METANORMA_DEV_MODE` set to `true` then it will revert to the
8
+ # old version of the CLI.
9
+ #
10
+ unless ENV.fetch("METANORMA_DEV_MODE", false) == "true"
11
+ require "bundler/setup"
12
+ require "metanorma/cli"
13
+
14
+ Metanorma::Cli.start(ARGV)
15
+ exit 0
16
+ end
17
+
3
18
  require "optparse"
4
19
  require "metanorma"
5
20
  require "fileutils"
@@ -133,5 +148,4 @@ unless options[:filename]
133
148
  end
134
149
 
135
150
  filename = options[:filename]
136
-
137
151
  Metanorma::Compile.new().compile(filename, options)
@@ -1,5 +1,6 @@
1
- require "metanorma/cli/version"
2
1
  require "metanorma"
2
+ require "metanorma/cli/version"
3
+ require "metanorma/cli/command"
3
4
 
4
5
  module Metanorma
5
6
  module Cli
@@ -21,10 +22,8 @@ module Metanorma
21
22
  ]
22
23
 
23
24
  def self.load_flavors(flavor_names = SUPPORTED_GEMS)
24
- # puts "[metanorma] detecting flavors:"
25
25
  flavor_names.each do |flavor|
26
26
  begin
27
- # puts flavor
28
27
  require flavor
29
28
  rescue LoadError
30
29
  $stderr.puts "[metanorma] Error: flavor gem #{flavor} not present"
@@ -40,5 +39,38 @@ module Metanorma
40
39
  load_flavors(flavor_names)
41
40
  end
42
41
 
42
+ # Invoking commands
43
+ #
44
+ # In the Metanorma CLI, we've included some custom behavior,
45
+ # like exposing the compiation directly from the root command.
46
+ #
47
+ # So, for this use case we first check if the user is actually
48
+ # trying to compile a document or not, and based on that we'll
49
+ # compile the document or show the help documentation.
50
+ #
51
+ def self.start(arguments)
52
+ if find_command(arguments).empty?
53
+ arguments.unshift("compile")
54
+ end
55
+
56
+ Metanorma::Cli::Command.start(arguments)
57
+ end
58
+
59
+ def self.root
60
+ File.dirname(__dir__)
61
+ end
62
+
63
+ def self.templates_path
64
+ root_path.join("templates")
65
+ end
66
+
67
+ def self.root_path
68
+ Pathname.new(Cli.root).join("..")
69
+ end
70
+
71
+ def self.find_command(arguments)
72
+ commands = Metanorma::Cli::Command.all_commands.keys
73
+ commands.select { |cmd| arguments.include?(cmd) == true }
74
+ end
43
75
  end
44
76
  end
@@ -0,0 +1,75 @@
1
+ require "thor"
2
+ require "metanorma/cli/compiler"
3
+ require "metanorma/cli/generator"
4
+ require "metanorma/cli/git_template"
5
+
6
+ module Metanorma
7
+ module Cli
8
+ class Command < Thor
9
+ desc "new NAME", "Create new Metanorma document"
10
+ option :type, aliases: "-t", required: true, desc: "Document type"
11
+ option :doctype, aliases: "-d", required: true, desc: "Metanorma doctype"
12
+ option :overwrite, aliases: "-r", desc: "Overwrite existing document"
13
+ option :template, aliases: "-g", desc: "Git hosted remote template skeleton"
14
+
15
+ def new(name)
16
+ create_new_document(name, options.dup)
17
+ end
18
+
19
+ desc "compile FILENAME", "Compile to a metanorma document"
20
+ option :type, aliases: "-t", desc: "Type of standard to generate"
21
+ option :extensions, aliases: "-x", type: :string, desc: "Type of extension to generate per type"
22
+ option :format, aliases: "-f", default: :asciidoc, desc: "Format of source file: eg. asciidoc"
23
+ option :require, aliases: "-r", type: :array, desc: "Require LIBRARY prior to execution"
24
+ option :wrapper, aliases: "-w", type: :boolean, desc: "Create wrapper folder for HTML output"
25
+ option :asciimath, aliases: "-a", type: :boolean, desc: "Keep Asciimath in XML output instead of converting it to MathM"
26
+ option :datauriimage, aliases: "-d", type: :boolean, desc: "Encode HTML output images as data URIs"
27
+ option :relaton, aliases: "-R", desc: "Export Relaton XML for document to nominated filename"
28
+ option :extract, aliases: "-e", desc: "Export sourcecode fragments from this document to nominated directory"
29
+ option :version, aliases: "-v", desc: "Print version of code (accompanied with -t)"
30
+
31
+ def compile(file_name = nil)
32
+ if file_name && !options[:version]
33
+ Metanorma::Cli::Compiler.compile(file_name, options.dup)
34
+
35
+ elsif options[:version]
36
+ invoke(:version, [], type: options[:type] || :iso, format: options[:format])
37
+
38
+ elsif options.keys.size >= 2
39
+ UI.say("Need to specify a file to process")
40
+
41
+ else
42
+ invoke :help
43
+ end
44
+ end
45
+
46
+ desc "version", "Version of the code"
47
+ option :type, aliases: "-t", required: true, desc: "Type of standard to generate"
48
+ option :format, aliases: "-f", default: :asciidoc, desc: "Format of source file: eg. asciidoc"
49
+
50
+ def version
51
+ if options[:format] == :asciidoc
52
+ UI.say(find_version(options[:type]))
53
+ end
54
+ end
55
+
56
+ private
57
+
58
+ def find_version(type)
59
+ require "metanorma-#{type}"
60
+ processor = Metanorma::Registry.instance.find_processor(type.to_sym)
61
+ processor.version
62
+ end
63
+
64
+ def create_new_document(name, options)
65
+ Metanorma::Cli::Generator.run(
66
+ name,
67
+ type: options[:type],
68
+ doctype: options[:doctype],
69
+ template: options[:template],
70
+ overwrite: options[:overwrite],
71
+ )
72
+ end
73
+ end
74
+ end
75
+ end