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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5734d4c7a672d830ea4199339b869da468bc2eab
4
- data.tar.gz: d590616887899c0c17739e95b4f46e64ba12a367
3
+ metadata.gz: ce24e4ca1eb5a8846a08a53e2c5cf2546f089e80
4
+ data.tar.gz: 8acd1d710a66271b0d5569a2e29fc8ac8c0ac327
5
5
  SHA512:
6
- metadata.gz: ce4642320270373612e945d7912269e45541954ca9b1f163c81e9527333994aa6f1c2f289d11fc61c3768aea76dffcd3d64923f830e2439e995c2d305a6140e5
7
- data.tar.gz: 0f3b03f4ffda5f874fd5a5780de08bbb891167351ea67c69d2f8b86f49e0a65f8b11582e0070343731398641afda5ae9b881f6ea308556f9ff1bdb98af3576b6
6
+ metadata.gz: 0634651055d9bc0eabce81d4738fa723ffa3eaddf9ac1eaff83c2948fc28757aa730abeeac600dbb00fac37fc489690e8ec26533a98d81555f5a1582646c8293
7
+ data.tar.gz: 94d9edcd5d7f745500d7f89d497c5b2fe50226a5b005280b3bfaf728d23e8c12f7f66b6041a33abf25281d0ddafaf3524ecb964c19b18d9023cd9d262eb4861f
@@ -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.
@@ -15,13 +15,14 @@ class Nori
15
15
 
16
16
  def initialize(options = {})
17
17
  defaults = {
18
- :strip_namespaces => false,
19
- :delete_namespace_attributes => false,
20
- :convert_tags_to => nil,
21
- :convert_attributes_to => nil,
22
- :advanced_typecasting => true,
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 => :nokogiri
25
+ :parser => :nokogiri
25
26
  }
26
27
 
27
28
  validate_options! defaults.keys, options.keys
@@ -1,3 +1,3 @@
1
1
  class Nori
2
- VERSION = '2.5.0'
2
+ VERSION = '2.6.0'
3
3
  end
@@ -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? ? nil : out
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
- private
250
+ private
251
251
  def try_to_convert(value, &block)
252
252
  block.call(value)
253
253
  rescue ArgumentError
@@ -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.5.0
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-04-01 00:00:00.000000000 Z
13
+ date: 2015-05-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake