metanorma-cli 1.4.7.2 → 1.4.8pre

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: 9fb9df9ff0531390c198459ae93a5e9e84bffeccdbbc25c658e273226d534c40
4
- data.tar.gz: 23f6d32b5379e25dbbe42f4ece44f92df84cbba21030554355a68d7e202dc31f
3
+ metadata.gz: 8a632364391b754ad5f857c03f05c09033ff8e4a12e9df7ed58b2ee1fb5be3df
4
+ data.tar.gz: c59747e473154462b14c76d66368463449c00339499a0a56b7d864c4941db09a
5
5
  SHA512:
6
- metadata.gz: '092b6a410fa3505bd9594d3be2ff69d761905465f50741593819b1d1509363b3eb842df2b6beec7fee64d07592852494b5f4cbb26c8884ed15d46009fab8d3bc'
7
- data.tar.gz: 9d97996a4ce0b5b6b186f4d76d6c549f9466447dd6a0621ef725c4b384a5b05ab3b51d68d9c551a5ab174abb679352ef0dbb1a7e5c07f88d3c887d1030734e1c
6
+ metadata.gz: 9b3e142318165929042fbfc0b1860f8db811832324490a20f7a37a0c0f1f7b08cb919e3149bcd0ed83448eccaf006a26aeeabc77bd2c0632ece107689f92a24b
7
+ data.tar.gz: d76798f134f962b5b331d500e4c845f712bb5396ce4ea69698592cf8abf62e45c04d00c08b4301fcca6f4244cf9760f8429c398e654e0953e645de94f091ae22
data/lib/metanorma/cli.rb CHANGED
@@ -1,53 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "metanorma"
4
+ require "metanorma/flavor"
5
+
4
6
  require "metanorma/cli/version"
5
7
  require "metanorma/cli/errors"
6
8
  require "metanorma/cli/command"
7
9
 
8
10
  module Metanorma
9
11
  module Cli
10
- SUPPORTED_GEMS = [
11
- "metanorma-iso",
12
- "metanorma-iec",
13
- "metanorma-ietf",
14
- #"metanorma-gb",
15
- "metanorma-bipm",
16
- "metanorma-cc",
17
- "metanorma-csa",
18
- "metanorma-iho",
19
- "metanorma-m3aawg",
20
- "metanorma-generic",
21
- "metanorma-standoc",
22
- "metanorma-un",
23
- "metanorma-nist",
24
- "metanorma-ogc",
25
- "metanorma-itu",
26
- ]
27
12
 
28
13
  CONFIG_DIRNAME = ".metanorma"
29
14
  CONFIG_FILENAME = "config.yml"
30
15
 
31
- PRIVATE_SUPPORTED_GEMS = ["metanorma-ribose", "metanorma-mpfa"]
32
-
33
- def self.load_flavors(flavor_names = SUPPORTED_GEMS + PRIVATE_SUPPORTED_GEMS)
34
- flavor_names.each do |flavor|
35
- begin
36
- require flavor
37
- rescue LoadError
38
- unless PRIVATE_SUPPORTED_GEMS.include?(flavor)
39
- $stderr.puts "[metanorma] Error: flavor gem #{flavor} not present"
40
- end
41
- end
42
- end
43
- end
44
-
45
- def self.load_all_flavors
46
- flavor_names = Gem::Specification.find_all do |g|
47
- g.name =~ /\Ametanorma-.*\Z/
48
- end.map(&:name)
49
-
50
- load_flavors(flavor_names)
16
+ def self.load_flavors
17
+ Metanorma::Flavor.load_flavors
51
18
  end
52
19
 
53
20
  # Invoking commands
@@ -5,7 +5,6 @@ require "metanorma/cli/thor_with_config"
5
5
  require "metanorma/cli/commands/config"
6
6
  require "metanorma/cli/commands/template_repo"
7
7
  require "metanorma/cli/commands/site"
8
- require "metanorma"
9
8
 
10
9
  module Metanorma
11
10
  module Cli
@@ -15,6 +15,12 @@ module Metanorma
15
15
  new.say(["[info]", message].join(": "))
16
16
  end
17
17
 
18
+ def self.debug(message, enabled: false)
19
+ if enabled
20
+ new.say(["[debug]", message].join(": "))
21
+ end
22
+ end
23
+
18
24
  def self.error(message)
19
25
  new.error(message)
20
26
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Cli
3
- VERSION = "1.4.7.2".freeze
3
+ VERSION = "1.4.8pre".freeze
4
4
  end
5
5
  end
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "metanorma/cli/ui"
4
+
5
+ module Metanorma
6
+ class Flavor
7
+ SUPPORTED_GEMS = [
8
+ "metanorma-iso",
9
+ "metanorma-iec",
10
+ "metanorma-ietf",
11
+ "metanorma-bipm",
12
+ "metanorma-cc",
13
+ "metanorma-csa",
14
+ "metanorma-iho",
15
+ "metanorma-m3aawg",
16
+ "metanorma-generic",
17
+ "metanorma-standoc",
18
+ "metanorma-un",
19
+ "metanorma-ogc",
20
+ "metanorma-itu",
21
+ ].freeze
22
+
23
+ PRIVATE_SUPPORTED_GEMS = [
24
+ "metanorma-ribose",
25
+ "metanorma-mpfa",
26
+ "metanorma-nist",
27
+ ].freeze
28
+
29
+ def self.activate
30
+ new.activate
31
+ end
32
+
33
+ def self.load_flavors
34
+ new.load_flavors
35
+ end
36
+
37
+ def activate
38
+ flavors.each do |flavor_name|
39
+ begin
40
+ gem(flavor_name)
41
+ rescue LoadError, MissingSpecError => _e
42
+ Metanorma::Cli::UI.debug("#{flavor_name} is not present!")
43
+ end
44
+ end
45
+ end
46
+
47
+ def load_flavors
48
+ flavors.each do |flavor_name|
49
+ begin
50
+ require(flavor_name)
51
+ rescue LoadError => _e
52
+ gem_loading_error(flavor_name)
53
+ end
54
+ end
55
+ end
56
+
57
+ private
58
+
59
+ def flavors
60
+ @flavors ||= [SUPPORTED_GEMS + PRIVATE_SUPPORTED_GEMS].flatten.uniq
61
+ end
62
+
63
+ def gem_loading_error(flavor_name)
64
+ unless PRIVATE_SUPPORTED_GEMS.include?(flavor_name)
65
+ Metanorma::Cli::UI.error(
66
+ "[metanorma] Error: flavor gem #{flavor_name} not present",
67
+ )
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ # Activate flavors
74
+ Metanorma::Flavor.activate
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.4.7.2
4
+ version: 1.4.8pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-27 00:00:00.000000000 Z
11
+ date: 2021-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -488,6 +488,7 @@ files:
488
488
  - lib/metanorma/cli/thor_with_config.rb
489
489
  - lib/metanorma/cli/ui.rb
490
490
  - lib/metanorma/cli/version.rb
491
+ - lib/metanorma/flavor.rb
491
492
  - metanorma-cli.gemspec
492
493
  - templates/base/Gemfile
493
494
  - templates/base/Makefile
@@ -508,9 +509,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
508
509
  version: 2.4.0
509
510
  required_rubygems_version: !ruby/object:Gem::Requirement
510
511
  requirements:
511
- - - ">="
512
+ - - ">"
512
513
  - !ruby/object:Gem::Version
513
- version: '0'
514
+ version: 1.3.1
514
515
  requirements: []
515
516
  rubygems_version: 3.1.4
516
517
  signing_key: