metanorma-utils 1.7.3 → 1.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8859c7c376fcc8c72a3f492ac15f1fef0fdea7ccfb5f89b7a14198869b88a22
4
- data.tar.gz: b59f14b602e440c9b07d633d75bfff7b2676b9b4b1f210265cc1b24a90a4aa02
3
+ metadata.gz: 9ecb0b154a431e671be11e34203984515b6638ac06dc0855840ee8266f20228a
4
+ data.tar.gz: 7989d425b7275e4c314bbf22d49b68e709ed197735029dde9c88edf87f0ebd43
5
5
  SHA512:
6
- metadata.gz: 947c9670404264d0438aea515efd39b169b3cf9e8672007104c4147894e35771657c33892980b25e7cfb2c59d0f97d68988a8a02113eb0659eac57bc61d1b5ef
7
- data.tar.gz: 6a2835e86e05939eb3f82abb374ecbb36b3245c27a8d19b068a3cb6dde2de7307920b022192fcedafbdc4d092cdd469db55c1ed86d21e12e43b5a971a255aa03
6
+ metadata.gz: 8bb4f60d626491b4df43ec3bdea3a02e6ad3c53ce3a4b23298ada95230b77f65c9ce03c3e599292b153e4cbe0e187546a52b4bed46d2fe26e895919932d7f3dd
7
+ data.tar.gz: d8457936acff8e32052ed0e5959a65757f48d8164f11a74d4c8cb20725d3165a3d7cdab8d330e6678b4869ec46504e61df4c620116b0d1fe6e19c65666e08dae
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
+ filename.sub!(/\.err\.html$/, ".html")
17
+ b = File.join(dir, File.basename(filename, ".*"))
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.3".freeze
3
+ VERSION = "1.7.5".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.3
4
+ version: 1.7.5
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-02-17 00:00:00.000000000 Z
11
+ date: 2024-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor