nokogiri-happymapper 0.5.4 → 0.5.5

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.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.5.5 / 2012-09-30
2
+
3
+ * Fix for Boolean attributes to ensure that they parse correctly (zrob)
4
+
1
5
  ## 0.5.4/ 2012-09-25
2
6
 
3
7
  * #wrap method allows you to better model xml content that is buried deep
data/lib/happymapper.rb CHANGED
@@ -7,7 +7,7 @@ class XmlContent; end
7
7
 
8
8
  module HappyMapper
9
9
 
10
- VERSION = "0.5.4"
10
+ VERSION = "0.5.5"
11
11
 
12
12
  DEFAULT_NS = "happymapper"
13
13
 
@@ -479,7 +479,7 @@ module HappyMapper
479
479
  # Attributes that have a nil value should be ignored unless they explicitly
480
480
  # state that they should be expressed in the output.
481
481
  #
482
- if value || attribute.options[:state_when_nil]
482
+ if not value.nil? || attribute.options[:state_when_nil]
483
483
  attribute_namespace = attribute.options[:namespace] || default_namespace
484
484
  [ "#{attribute_namespace ? "#{attribute_namespace}:" : ""}#{attribute.tag}", value ]
485
485
  else
@@ -53,6 +53,8 @@ module ToXML
53
53
  # Class composition
54
54
  #
55
55
  element :country, 'Country', :tag => 'country'
56
+
57
+ attribute :occupied, Boolean
56
58
 
57
59
  def initialize(parameters)
58
60
  parameters.each_pair do |property,value|
@@ -110,7 +112,8 @@ module ToXML
110
112
  'city' => 'Seattle',
111
113
  'country' => Country.new(:name => 'USA', :code => 'us', :empty_code => nil,
112
114
  :description => Country::Description.new("A lovely country") ),
113
- 'date_created' => '2011-01-01 15:00:00')
115
+ 'date_created' => '2011-01-01 15:00:00',
116
+ 'occupied' => false)
114
117
 
115
118
 
116
119
  address.dates_updated = ["2011-01-01 16:01:00","2011-01-02 11:30:01"]
@@ -144,6 +147,10 @@ module ToXML
144
147
  @address_xml.xpath("@modified").should be_empty
145
148
  end
146
149
 
150
+ it 'should save attributes that are Boolean and have a value of false' do
151
+ @address_xml.xpath('@occupied').text.should == "false"
152
+ end
153
+
147
154
  context "state_when_nil option" do
148
155
 
149
156
  it "should save an empty element" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokogiri-happymapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -106,12 +106,9 @@ files:
106
106
  - spec/xpath_spec.rb
107
107
  homepage: http://github.com/dam5s/happymapper
108
108
  licenses: []
109
- post_install_message: ! "\n Thank you for installing nokogiri-happymapper 0.5.4 /
110
- 2012-09-25.\n \n Changes:\n \n * #wrap method allows you to better model xml
111
- content that is buried deep\n within the xml. This implementation addresses issues
112
- with calling #to_xml\n with content that was parsed from an xpath. (zrob)\n \n
113
- \ * Parent HappyMapper classes may dictate the name of the tag for the child\n HappyMapper
114
- instances. (zrob)\n \n\n\n"
109
+ post_install_message: ! "\n Thank you for installing nokogiri-happymapper 0.5.5 /
110
+ 2012-09-30.\n \n Changes:\n \n * Fix for Boolean attributes to ensure that
111
+ they parse correctly (zrob)\n \n\n\n"
115
112
  rdoc_options: []
116
113
  require_paths:
117
114
  - lib