nori 2.5.0 → 2.6.0
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/CHANGELOG.md +4 -0
- data/lib/nori.rb +7 -6
- data/lib/nori/version.rb +1 -1
- data/lib/nori/xml_utility_node.rb +2 -2
- data/spec/nori/api_spec.rb +8 -1
- 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: ce24e4ca1eb5a8846a08a53e2c5cf2546f089e80
|
4
|
+
data.tar.gz: 8acd1d710a66271b0d5569a2e29fc8ac8c0ac327
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0634651055d9bc0eabce81d4738fa723ffa3eaddf9ac1eaff83c2948fc28757aa730abeeac600dbb00fac37fc489690e8ec26533a98d81555f5a1582646c8293
|
7
|
+
data.tar.gz: 94d9edcd5d7f745500d7f89d497c5b2fe50226a5b005280b3bfaf728d23e8c12f7f66b6041a33abf25281d0ddafaf3524ecb964c19b18d9023cd9d262eb4861f
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# 2.6.0 (2015-05-06)
|
2
|
+
|
3
|
+
* Feature: [#69](https://github.com/savonrb/nori/pull/69) Add option to convert empty tags to a value other than nil.
|
4
|
+
|
1
5
|
# 2.5.0 (2015-03-31)
|
2
6
|
|
3
7
|
* Formally drop support for ruby 1.8.7. Installing Nori from rubygems for that version should no longer attempt to install versions that will not work.
|
data/lib/nori.rb
CHANGED
@@ -15,13 +15,14 @@ class Nori
|
|
15
15
|
|
16
16
|
def initialize(options = {})
|
17
17
|
defaults = {
|
18
|
-
:strip_namespaces
|
19
|
-
:delete_namespace_attributes
|
20
|
-
:convert_tags_to
|
21
|
-
:convert_attributes_to
|
22
|
-
:
|
18
|
+
:strip_namespaces => false,
|
19
|
+
:delete_namespace_attributes => false,
|
20
|
+
:convert_tags_to => nil,
|
21
|
+
:convert_attributes_to => nil,
|
22
|
+
:empty_tag_value => nil,
|
23
|
+
:advanced_typecasting => true,
|
23
24
|
:convert_dashes_to_underscores => true,
|
24
|
-
:parser
|
25
|
+
:parser => :nokogiri
|
25
26
|
}
|
26
27
|
|
27
28
|
validate_options! defaults.keys, options.keys
|
data/lib/nori/version.rb
CHANGED
@@ -171,7 +171,7 @@ class Nori
|
|
171
171
|
end
|
172
172
|
end
|
173
173
|
out.merge! prefixed_attributes unless attributes.empty?
|
174
|
-
out = out.empty? ?
|
174
|
+
out = out.empty? ? @options[:empty_tag_value] : out
|
175
175
|
end
|
176
176
|
|
177
177
|
if @type && out.nil?
|
@@ -247,7 +247,7 @@ class Nori
|
|
247
247
|
end
|
248
248
|
alias to_s to_html
|
249
249
|
|
250
|
-
|
250
|
+
private
|
251
251
|
def try_to_convert(value, &block)
|
252
252
|
block.call(value)
|
253
253
|
rescue ArgumentError
|
data/spec/nori/api_spec.rb
CHANGED
@@ -170,8 +170,15 @@ describe Nori do
|
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
173
|
+
context "#parse with :empty_tag_value set to empty string" do
|
174
|
+
it "can be configured to convert empty tags to given value" do
|
175
|
+
xml = "<parentTag><tag/></parentTag>"
|
176
|
+
hash = nori(:empty_tag_value => "").parse(xml)
|
177
|
+
expect(hash).to eq("parentTag" => { "tag" => "" })
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
173
181
|
def nori(options = {})
|
174
182
|
Nori.new(options)
|
175
183
|
end
|
176
|
-
|
177
184
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nori
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Harrington
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-05-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|