metanorma-utils 1.7.4 → 1.7.6

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: 1f7377666098d56db030c9e66dc77ecb43177c7d704a771ddef7edfafcb577d8
4
- data.tar.gz: 1a07cb301bfe424d82c348cdb4ef63a0bb70dfb5a93aaf122acb7576ab1c5547
3
+ metadata.gz: 763172a604af9c8aa2041735e905ba799c1dc2c1d30884d729a745466ee2bd04
4
+ data.tar.gz: 350815e7f0ed225a291411b467fe234c269ad037fa7d7b5b78db3768115d7029
5
5
  SHA512:
6
- metadata.gz: 81879f9f490554bcf36767235e933568d204c42c40f009afc658434b2c45a16834889e99555be4f4e245eaa5b20bc9cd4c969bf19a38c312ac0668fefbc0cbe6
7
- data.tar.gz: a18a86441dc5a2976c434e1b34e80674135fd70634faa9dda076c3f14af47141ff9b1d6c5eb47572af473c1d38296a299784281da5620fcf9f66d11a5b1f60bc
6
+ metadata.gz: 844194eb8dcf4e1c95b2911ee2b20a6637bb098c713f46f9e16ca1bad369a70795e8edfc139df9dadbf38127e8685e86e6f23d485781b495de4b822cbb460bfa
7
+ data.tar.gz: 4b1ec3c894633fa98d31c53b38f3c4d7b0632bf1e3178e427b5f2eb65cb3d6415a76140a05ee1e21185dd0384919a349aed520fb8f56f59d205115e69186c1ea
data/lib/utils/log.rb CHANGED
@@ -11,6 +11,14 @@ module Metanorma
11
11
  @mapid = {}
12
12
  end
13
13
 
14
+ def save_to(filename, dir = nil)
15
+ dir ||= File.dirname(filename)
16
+ new_fn = filename.sub(/\.err\.html$/, ".html")
17
+ b = File.join(dir, File.basename(new_fn, ".*"))
18
+ @filename = "#{b}.err.html"
19
+ @htmlfilename = "#{b}.html"
20
+ end
21
+
14
22
  # severity: 0: abort; 1: serious; 2: not serious; 3: info only
15
23
  def add(category, loc, msg, severity: 2)
16
24
  @novalid and return
@@ -121,10 +129,10 @@ module Metanorma
121
129
  HTML
122
130
  end
123
131
 
124
- def write(file)
125
- @filename = file.sub(".err.html", ".html")
126
- File.open(file, "w:UTF-8") do |f|
127
- f.puts log_hdr(file)
132
+ def write(file = nil)
133
+ (!file && @filename) or save_to(file || "metanorma", nil)
134
+ File.open(@filename, "w:UTF-8") do |f|
135
+ f.puts log_hdr(@filename)
128
136
  @log.each_key { |key| write_key(f, key) }
129
137
  f.puts "</body></html>\n"
130
138
  end
@@ -167,16 +175,20 @@ module Metanorma
167
175
  def loc_link(entry)
168
176
  loc = entry[:location]
169
177
  loc.nil? || loc.empty? and loc = "--"
170
- if /^ID /.match?(loc)
171
- loc.sub!(/^ID /, "")
172
- loc = @mapid[loc] while @mapid[loc]
173
- url = "#{@filename}##{loc}"
174
- end
178
+ loc, url = loc_to_url(loc)
175
179
  loc &&= break_up_long_str(loc, 10, 2)
176
180
  url and loc = "<a href='#{url}'>#{loc}</a>"
177
181
  loc
178
182
  end
179
183
 
184
+ def loc_to_url(loc)
185
+ /^ID /.match?(loc) or return [loc, nil]
186
+ loc.sub!(/^ID /, "")
187
+ loc = @mapid[loc] while @mapid[loc]
188
+ url = "#{@htmlfilename}##{loc}"
189
+ [loc, url]
190
+ end
191
+
180
192
  def break_up_long_str(str, threshold, punct)
181
193
  Metanorma::Utils.break_up_long_str(str, threshold, punct)
182
194
  end
data/lib/utils/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Utils
3
- VERSION = "1.7.4".freeze
3
+ VERSION = "1.7.6".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.4
4
+ version: 1.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-10 00:00:00.000000000 Z
11
+ date: 2024-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor