canon 0.3.11 → 0.3.12
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/canon/pretty_printer/xml.rb +19 -9
- data/lib/canon/version.rb +1 -1
- 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: cb5f47fd1b5759edefe57276d19baec565e015cebc47c683125875dad10122b2
|
|
4
|
+
data.tar.gz: e21fe66a481474c041add458fdbf2e7bcb39dfc910d5fe58f3c6394f33929426
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a28e38753f0ac126563f37bdea72adec9f605885c25320f09407b4367495ee17c72b60f014615bc7bad6c352640eda067ece20ef4e04361632ae7fd8323f644d
|
|
7
|
+
data.tar.gz: 6db620f6c3ccdb828102c7b80489b302396e8bdda96c07b0a11abb65b4e2cc09b08ea7ea221cb9bfced71eaaaad829ccc37c1e47d0a88036e2f8c25e5d6b15c4
|
|
@@ -12,14 +12,16 @@ module Canon
|
|
|
12
12
|
|
|
13
13
|
def format(xml_string)
|
|
14
14
|
# Output parity: pretty-printed bytes are canon's product. The
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
# leptris serializer matches Nokogiri byte-for-byte for space
|
|
16
|
+
# and tab indentation (moxml#153/#155/#156) and runs faster
|
|
17
|
+
# since moxml#158, with the #167 escaping race fixed in 0.5.28
|
|
18
|
+
# — the fixture integrity suite and the CI performance gate are
|
|
19
|
+
# the standing gates. Nokogiri serves the fallback engine and
|
|
20
|
+
# Opal.
|
|
21
|
+
if RUBY_ENGINE == "opal" || Canon::XmlBackend.moxml?
|
|
22
22
|
moxml_format(xml_string)
|
|
23
|
+
else
|
|
24
|
+
nokogiri_format(xml_string)
|
|
23
25
|
end
|
|
24
26
|
end
|
|
25
27
|
|
|
@@ -35,8 +37,16 @@ module Canon
|
|
|
35
37
|
end
|
|
36
38
|
|
|
37
39
|
def moxml_format(xml_string)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
# noblanks mutates the tree (strips whitespace-only text), so
|
|
41
|
+
# the document cannot be readonly.
|
|
42
|
+
doc = Canon::XmlParsing.moxml_context.parse(xml_string, noblanks: true)
|
|
43
|
+
if @indent_type == "tab"
|
|
44
|
+
doc.to_xml(declaration: true, encoding: "UTF-8",
|
|
45
|
+
indent: 1, indent_text: "\t", expand_empty: false)
|
|
46
|
+
else
|
|
47
|
+
doc.to_xml(declaration: true, encoding: "UTF-8",
|
|
48
|
+
indent: @indent, expand_empty: false)
|
|
49
|
+
end
|
|
40
50
|
end
|
|
41
51
|
end
|
|
42
52
|
end
|
data/lib/canon/version.rb
CHANGED