metanorma-utils 1.10.1 → 1.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/utils/log.rb +33 -3
- data/lib/utils/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f44541a6cf6b2c8a2ddb65412981c68516f37ebacda4bc7c1cec364c46a4530
|
4
|
+
data.tar.gz: e775ca9ed734be1acdbd7e6275143fe61f43e4403510eb768e552d89cfc084e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b38ccf0cf8e92485d94d6af2389d32f2cc6fa9582167ee96d0a3a2388b8e4336cad2df1f9257bb97430a71ab1d4a030291b05a078e246bdab63d1d7e6061f3e3
|
7
|
+
data.tar.gz: 43a6945199cdc8f8303e97ebcce4e6c3508e517745247bbf362b7c334ed3e600223e3fd6cd0a8a98e06723d3efe158721f6ff4945c91a5ec3b965247c1a62e79
|
data/lib/utils/log.rb
CHANGED
@@ -3,12 +3,17 @@ require "htmlentities"
|
|
3
3
|
module Metanorma
|
4
4
|
module Utils
|
5
5
|
class Log
|
6
|
-
attr_writer :xml
|
6
|
+
attr_writer :xml, :suppress_log
|
7
7
|
|
8
8
|
def initialize
|
9
9
|
@log = {}
|
10
10
|
@c = HTMLEntities.new
|
11
11
|
@mapid = {}
|
12
|
+
@suppress_log = { severity: 4, category: [] }
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_ncname(tag)
|
16
|
+
::Metanorma::Utils.to_ncname(tag)
|
12
17
|
end
|
13
18
|
|
14
19
|
def save_to(filename, dir = nil)
|
@@ -21,7 +26,7 @@ module Metanorma
|
|
21
26
|
|
22
27
|
# severity: 0: abort; 1: serious; 2: not serious; 3: info only
|
23
28
|
def add(category, loc, msg, severity: 2, display: true)
|
24
|
-
@novalid and return
|
29
|
+
@novalid || suppress_log?(category, severity, msg) and return
|
25
30
|
@log[category] ||= []
|
26
31
|
item = create_entry(loc, msg, severity)
|
27
32
|
@log[category] << item
|
@@ -38,6 +43,12 @@ module Metanorma
|
|
38
43
|
end
|
39
44
|
end
|
40
45
|
|
46
|
+
def suppress_log?(category, severity, msg)
|
47
|
+
category == "Relaton" && /^Fetching /.match?(msg) ||
|
48
|
+
@suppress_log[:severity] <= severity ||
|
49
|
+
@suppress_log[:category].include?(category)
|
50
|
+
end
|
51
|
+
|
41
52
|
def suppress_display?(category, _loc, _msg, display)
|
42
53
|
["Metanorma XML Syntax", "Relaton"].include?(category) ||
|
43
54
|
!display
|
@@ -127,9 +138,28 @@ module Metanorma
|
|
127
138
|
.severity3 { font-style: italic; color: grey; }
|
128
139
|
</style>
|
129
140
|
</head><body><h1>#{file} errors</h1>
|
141
|
+
<ul>#{log_index}</ul>
|
130
142
|
HTML
|
131
143
|
end
|
132
144
|
|
145
|
+
def log_index
|
146
|
+
@log.each_with_object([]) do |(k, v), m|
|
147
|
+
m << <<~HTML
|
148
|
+
<li><p><b><a href="##{to_ncname(k)}">#{k}</a></b>: #{index_severities(v)}</p></li>
|
149
|
+
HTML
|
150
|
+
end.join("\n")
|
151
|
+
end
|
152
|
+
|
153
|
+
def index_severities(entries)
|
154
|
+
s = entries.each_with_object({}) do |e, m|
|
155
|
+
m[e[:severity]] ||= 0
|
156
|
+
m[e[:severity]] += 1
|
157
|
+
end.compact
|
158
|
+
s.keys.sort.map do |k|
|
159
|
+
"Severity #{k}: <b>#{s[k]}</b> errors"
|
160
|
+
end.join("; ")
|
161
|
+
end
|
162
|
+
|
133
163
|
def write(file = nil)
|
134
164
|
(!file && @filename) or save_to(file || "metanorma", nil)
|
135
165
|
File.open(@filename, "w:UTF-8") do |f|
|
@@ -141,7 +171,7 @@ module Metanorma
|
|
141
171
|
|
142
172
|
def write_key(file, key)
|
143
173
|
file.puts <<~HTML
|
144
|
-
<h2>#{key}</h2>\n<table border="1">
|
174
|
+
<h2 id="#{to_ncname(key)}">#{key}</h2>\n<table border="1">
|
145
175
|
<thead><th width="5%">Line</th><th width="20%">ID</th>
|
146
176
|
<th width="30%">Message</th><th width="40%">Context</th><th width="5%">Severity</th></thead>
|
147
177
|
<tbody>
|
data/lib/utils/version.rb
CHANGED
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.10.
|
4
|
+
version: 1.10.2
|
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-
|
11
|
+
date: 2024-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|