pretty_xml 0.0.2.1 → 0.0.2.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/sax/sax_printer.rb +19 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 578aa9d36b024370da16c72305da36292033ba7c
|
|
4
|
+
data.tar.gz: da002a5a557455a31b1efaa19a05612d1734bc14
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 98eaf3a93d453abe0a2af07ed64d3d01211381c23b28239f587a78dd0aeaa6b3e283c01033d5b1fed1b366eda982096208f90e0c8898698672ffb78e2ba9c72f
|
|
7
|
+
data.tar.gz: fd5caee63898b65329f561e769af3355ac855dc2d07dc51d1bd65594b7862c6f5b53c7aae1f1dda043f5e1fe1a2266a9490af5053b32383d143a69a3269e1798
|
data/lib/sax/sax_printer.rb
CHANGED
|
@@ -66,6 +66,10 @@ class SaxPrinter < Nokogiri::XML::SAX::Document
|
|
|
66
66
|
@compact.include?(name)
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
+
def block_or_compact?(name)
|
|
70
|
+
block?(name) or compact?(name)
|
|
71
|
+
end
|
|
72
|
+
|
|
69
73
|
def inline?(name)
|
|
70
74
|
@inline.include?(name)
|
|
71
75
|
end
|
|
@@ -111,6 +115,7 @@ class SaxPrinter < Nokogiri::XML::SAX::Document
|
|
|
111
115
|
pretty << "</#{name}>"
|
|
112
116
|
end
|
|
113
117
|
@depth -= 1
|
|
118
|
+
space_after_close(name)
|
|
114
119
|
@open_tag = nil
|
|
115
120
|
@opens.pop
|
|
116
121
|
end
|
|
@@ -123,6 +128,10 @@ class SaxPrinter < Nokogiri::XML::SAX::Document
|
|
|
123
128
|
increment_space if block?(name) and @depth != 0
|
|
124
129
|
end
|
|
125
130
|
|
|
131
|
+
def space_after_close(name)
|
|
132
|
+
increment_space if block_or_compact?(name) and compact?(@opens[-2])
|
|
133
|
+
end
|
|
134
|
+
|
|
126
135
|
def add_opening_tag(name, attrs)
|
|
127
136
|
tag = attrs.empty? ? "<#{name}>" : tag_with_attrs(name, attrs)
|
|
128
137
|
pretty << tag
|
|
@@ -167,16 +176,24 @@ class SaxPrinter < Nokogiri::XML::SAX::Document
|
|
|
167
176
|
string.gsub!(/^\s+|\s+$/, '') unless whitespace?
|
|
168
177
|
end
|
|
169
178
|
|
|
170
|
-
def
|
|
179
|
+
def nontextual_text(str, op, cl)
|
|
171
180
|
if in_block?
|
|
172
181
|
@depth += 1
|
|
173
182
|
increment_space
|
|
174
183
|
@depth -= 1
|
|
175
184
|
end
|
|
176
|
-
pretty << "
|
|
185
|
+
pretty << "#{op}#{str}#{cl}"
|
|
177
186
|
@open_tag = nil
|
|
178
187
|
end
|
|
179
188
|
|
|
189
|
+
def comment(string)
|
|
190
|
+
nontextual_text(string, '<!--', '-->')
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def cdata_block(string)
|
|
194
|
+
nontextual_text(string, '<![CDATA[', ']]>')
|
|
195
|
+
end
|
|
196
|
+
|
|
180
197
|
def sanitize(string)
|
|
181
198
|
string.gsub!(/&/, CCS[:amp][@ccs])
|
|
182
199
|
string.gsub!(/</, CCS[:lt][@ccs])
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pretty_xml
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.2.
|
|
4
|
+
version: 0.0.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dan Corrigan
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-08-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|