metanorma-cli 1.5.7pre → 1.5.9pre

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: f6dd95f11d2b1b1b3fe5ecdd8b2a83ad710dbeeb4aece431067cb803896d3920
4
- data.tar.gz: c9afada264289ab145371159a18fbbacb6a8e85e32ee183096ac5871cae196ba
3
+ metadata.gz: 5580b948d0d190232adc2a1977a8ce0fcfa2a2c7ad26385de1ac33e717bb56dd
4
+ data.tar.gz: 62932c33266289b60da258d1ae203ad4726145396b991b36203d328fbe67fb5d
5
5
  SHA512:
6
- metadata.gz: 7f437418c07b33498e5f9dc622d84d6ea785343e7e59a897d1c059e3b821e6256285a6b0d4254b72dbb805cebf4700016be36c5e22d3d7444435b7cecaa45869
7
- data.tar.gz: 8ce387495535642cda7a771110ea33d87f153285f11534f841b148f4fe244c26d9c5ce83eeaaad9ea85b858e8d3669d7423c80fdc8cf21ea07b7d5055448f9e0
6
+ metadata.gz: 10b5780f1b8aa3220ec4087f103b8d710d452a49e1eddb63dc50199150c39b08b1ef74e0c5347599f82fab87fa76010df3e50d98ba174276d2816bd2c453f7fd
7
+ data.tar.gz: 1b0d9eb8dba65202ad10f9077d26d0b5639c9df8de59a17e1cc5f1e9a083c70789b0881ca0b085feca147ccf99b1ac7e82870930138573f0682bd6479f9af61f
@@ -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.7pre".freeze
3
+ VERSION = "1.5.9pre".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.7pre
4
+ version: 1.5.9pre
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