metanorma-cli 1.5.7 → 1.5.9

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: 7fff90bbd2871ac0894c95bb3eb6b51edac50da064be9e9a9b3aca24e228551b
4
- data.tar.gz: f544433d2ea4baa4fa797ff1becfc0af7ab2dcdfb9922ae9733e643b6c3e37c3
3
+ metadata.gz: 6282445acbd814d5fe7561a6c2f0aa79ebdc3e783c6fc18b79a3ea5b458484ac
4
+ data.tar.gz: 52f15df8bcb0817ab747f7224866a8099251fcf48a86c6a820558fbb567bdde5
5
5
  SHA512:
6
- metadata.gz: 5d8b653c3835af4b0ccf246cfce504dab1302fd77fdb83841fe350e90cd6c451946bb744c80abf541880517696317b4bf02f24cc6797be7d33db4ada2f2486ec
7
- data.tar.gz: cae6562fd87902efe8a9aca1ab063793bcfcf08d39bc9ab2e416e85e42795e8d6b65d250691b38c61df320bd6f1c8906a2fd9ff1ff6d809dd81f144084848115
6
+ metadata.gz: 05a4a3e14905e1768ae10abdb5bf153896b55ccc73911b2b22d3013dea6d04c8719121aa4f24b315932b7522450935aa634217fd6f995b1b21356f377cdebc8a
7
+ data.tar.gz: 5e04c708242ce2917d62887920aa966aafa285ff7829006bef98101a49bf3321820c7db73db3a662c216aea7765231cb009c3e323ccf67b594a2933ea98acad0
@@ -18,12 +18,12 @@ module Metanorma
18
18
  if Cli.writable_templates_path?
19
19
  if name && document_path.exist?
20
20
  return unless overwrite?(document_path)
21
+
21
22
  document_path.rmtree
22
23
  end
23
24
 
24
25
  create_metanorma_document
25
26
  end
26
-
27
27
  rescue Errno::EACCES
28
28
  permission_missing_error
29
29
  end
@@ -53,17 +53,24 @@ module Metanorma
53
53
  def create_metanorma_document
54
54
  type_template = type_specific_template
55
55
 
56
- unless type_template.empty?
57
- templates = base_templates.merge(type_template)
58
- templates.each { |source, dest| create_file(source, dest) }
59
- else
56
+ if type_template.empty?
60
57
  UI.say(
61
- "Unable to generate document:\n" \
62
- "Templates for type #{type.to_s} cannot be found -- please provide a valid `type` or a template URL"
58
+ "Unable to generate document:\n#{create_metanorma_document_error}",
63
59
  )
60
+ else
61
+ templates = base_templates.merge(type_template)
62
+ templates.each { |source, dest| create_file(source, dest) }
64
63
  end
65
64
  end
66
65
 
66
+ def create_metanorma_document_error
67
+ type == "ogc" && doctype == "charter" and return <<~ERR
68
+ The template for OGC charter documents can be downloaded from https://github.com/opengeospatial/templates/tree/master/charter_templates
69
+ ERR
70
+ "Templates for type #{type} cannot be found -- "\
71
+ "please provide a valid `type` or a template URL"
72
+ end
73
+
67
74
  def find_standard_template(type)
68
75
  Cli::GitTemplate.find_or_download_by(type)
69
76
  end
@@ -85,7 +92,7 @@ module Metanorma
85
92
 
86
93
  def custom_template
87
94
  if template
88
- if template !~ URI::regexp
95
+ if !template&.match?(URI::DEFAULT_PARSER.make_regexp)
89
96
  return Pathname.new(template)
90
97
  end
91
98
 
@@ -124,13 +131,13 @@ module Metanorma
124
131
 
125
132
  def ask_to_confirm(document)
126
133
  UI.ask(
127
- "You've an existing document with the #{document.to_s}\n" \
134
+ "You've an existing document with the #{document}\n" \
128
135
  "Still want to continue, and overwrite the existing one? (yes/no):",
129
136
  ).downcase
130
137
  end
131
138
 
132
139
  def file_creation_message(document, destination)
133
- UI.say("Creating #{[document, destination].join("/").gsub("//", "/")}")
140
+ UI.say("Creating #{[document, destination].join('/').gsub('//', '/')}")
134
141
  end
135
142
 
136
143
  def permission_missing_error
@@ -139,7 +146,7 @@ module Metanorma
139
146
  "The current user does not have permission to write to this path:\n" \
140
147
  "#{Cli.templates_path}\n" \
141
148
  "Please ensure the path is writable by the current user, or\n" \
142
- "run Metanorma using a different user with write permissions."
149
+ "run Metanorma using a different user with write permissions.",
143
150
  )
144
151
  end
145
152
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Cli
3
- VERSION = "1.5.7".freeze
3
+ VERSION = "1.5.9".freeze
4
4
  end
5
5
  end
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.5.7
4
+ version: 1.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-17 00:00:00.000000000 Z
11
+ date: 2022-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debug