metanorma-utils 1.4.1 → 1.4.2
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 +4 -4
- data/lib/utils/log.rb +1 -0
- data/lib/utils/version.rb +1 -1
- data/spec/utils_spec.rb +17 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd1e58ea4dadd1ad26ad1b254805c2c831914a1177b0e75ea166117a3c1a4e99
|
4
|
+
data.tar.gz: 1479bd090933fc9e861f3b9aba780fa18fe863ddfa923ddcee7caa148956f754
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4578a2d2450368c92cec783b297ab5c5ba921e3644dc6078b6df66af58b0a74f56e6e800d2d01322f8af6b95ebf3c2834076528308845aaca612ed851108990
|
7
|
+
data.tar.gz: 343f2b25137e40335e56ce82f00297294f6f33a956d7bec3ccb76ad012d31a8594d78a31143919060d05fe6edfa2a3a39f06183548e2b9a671cb3f97a310d6c8
|
data/lib/utils/log.rb
CHANGED
@@ -59,6 +59,7 @@ module Metanorma
|
|
59
59
|
def write1(file, entry)
|
60
60
|
loc = entry[:location] ? "(#{entry[:location]}): " : ""
|
61
61
|
file.puts "#{loc}#{entry[:message]}"
|
62
|
+
.encode("UTF-8", invalid: :replace, undef: :replace)
|
62
63
|
entry[:context]&.split(/\n/)&.first(5)&.each do |l|
|
63
64
|
file.puts "\t#{l}"
|
64
65
|
end
|
data/lib/utils/version.rb
CHANGED
data/spec/utils_spec.rb
CHANGED
@@ -126,6 +126,23 @@ RSpec.describe Metanorma::Utils do
|
|
126
126
|
OUTPUT
|
127
127
|
end
|
128
128
|
|
129
|
+
it "deals with illegal characters in log" do
|
130
|
+
FileUtils.rm_f("log.txt")
|
131
|
+
log = Metanorma::Utils::Log.new
|
132
|
+
log.add("Category 1", nil, "é\xc2")
|
133
|
+
log.write("log.txt")
|
134
|
+
expect(File.exist?("log.txt")).to be true
|
135
|
+
file = File.read("log.txt", encoding: "utf-8")
|
136
|
+
expect(file).to eq <<~OUTPUT
|
137
|
+
log.txt errors
|
138
|
+
|
139
|
+
|
140
|
+
== Category 1
|
141
|
+
|
142
|
+
(): é�
|
143
|
+
OUTPUT
|
144
|
+
end
|
145
|
+
|
129
146
|
it "parses CSV" do
|
130
147
|
expect(Metanorma::Utils.csv_split("A;'B;C'")).to eq ["A", "'B", "C'"]
|
131
148
|
expect(Metanorma::Utils.csv_split('A;"B;C"')).to eq ["A", "B;C"]
|