unhappymapper 0.4.1 → 0.4.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.
- data/lib/happymapper.rb +6 -0
- data/lib/happymapper/item.rb +1 -1
- data/spec/fixtures/optional_attributes.xml +6 -0
- data/spec/happymapper_spec.rb +26 -0
- metadata +7 -5
data/lib/happymapper.rb
CHANGED
@@ -598,6 +598,12 @@ module HappyMapper
|
|
598
598
|
|
599
599
|
end
|
600
600
|
|
601
|
+
# Write out to XML, this value was set above, based on whether or not an XML
|
602
|
+
# builder object was passed to it as a parameter. When there was no parameter
|
603
|
+
# we assume we are at the root level of the #to_xml call and want the actual
|
604
|
+
# xml generated from the object. If an XML builder instance was specified
|
605
|
+
# then we assume that has been called recursively to generate a larger
|
606
|
+
# XML document.
|
601
607
|
write_out_to_xml ? builder.to_xml : builder
|
602
608
|
|
603
609
|
end
|
data/lib/happymapper/item.rb
CHANGED
data/spec/happymapper_spec.rb
CHANGED
@@ -530,6 +530,13 @@ class Video
|
|
530
530
|
|
531
531
|
end
|
532
532
|
|
533
|
+
class OptionalAttribute
|
534
|
+
include HappyMapper
|
535
|
+
tag 'address'
|
536
|
+
|
537
|
+
attribute :street, String
|
538
|
+
end
|
539
|
+
|
533
540
|
|
534
541
|
describe HappyMapper do
|
535
542
|
|
@@ -882,6 +889,25 @@ describe HappyMapper do
|
|
882
889
|
l = Location.parse(fixture_file('lastfm.xml'))
|
883
890
|
l.first.latitude.should == "51.53469"
|
884
891
|
end
|
892
|
+
|
893
|
+
describe "Parse optional attributes" do
|
894
|
+
|
895
|
+
it "should parse an empty String as empty" do
|
896
|
+
a = OptionalAttribute.parse(fixture_file('optional_attributes.xml'))
|
897
|
+
a[0].street.should == ""
|
898
|
+
end
|
899
|
+
|
900
|
+
it "should parse a String with value" do
|
901
|
+
a = OptionalAttribute.parse(fixture_file('optional_attributes.xml'))
|
902
|
+
a[1].street.should == "Milchstrasse"
|
903
|
+
end
|
904
|
+
|
905
|
+
it "should parse a String with value" do
|
906
|
+
a = OptionalAttribute.parse(fixture_file('optional_attributes.xml'))
|
907
|
+
a[2].street.should be_nil
|
908
|
+
end
|
909
|
+
|
910
|
+
end
|
885
911
|
|
886
912
|
describe 'Xml Content' do
|
887
913
|
before(:each) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unhappymapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -18,7 +18,7 @@ date: 2011-08-22 00:00:00.000000000Z
|
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: nokogiri
|
21
|
-
requirement: &
|
21
|
+
requirement: &70233821937220 !ruby/object:Gem::Requirement
|
22
22
|
none: false
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
@@ -26,10 +26,10 @@ dependencies:
|
|
26
26
|
version: 1.4.2
|
27
27
|
type: :runtime
|
28
28
|
prerelease: false
|
29
|
-
version_requirements: *
|
29
|
+
version_requirements: *70233821937220
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rspec
|
32
|
-
requirement: &
|
32
|
+
requirement: &70233821936180 !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
@@ -37,7 +37,7 @@ dependencies:
|
|
37
37
|
version: 1.3.0
|
38
38
|
type: :development
|
39
39
|
prerelease: false
|
40
|
-
version_requirements: *
|
40
|
+
version_requirements: *70233821936180
|
41
41
|
description: Object to XML Mapping Library, using Nokogiri (fork from John Nunemaker's
|
42
42
|
Happymapper)
|
43
43
|
email: franklin.webber@gmail.com
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- spec/fixtures/lastfm.xml
|
68
68
|
- spec/fixtures/multiple_namespaces.xml
|
69
69
|
- spec/fixtures/multiple_primitives.xml
|
70
|
+
- spec/fixtures/optional_attributes.xml
|
70
71
|
- spec/fixtures/pita.xml
|
71
72
|
- spec/fixtures/posts.xml
|
72
73
|
- spec/fixtures/product_default_namespace.xml
|
@@ -124,6 +125,7 @@ test_files:
|
|
124
125
|
- spec/fixtures/lastfm.xml
|
125
126
|
- spec/fixtures/multiple_namespaces.xml
|
126
127
|
- spec/fixtures/multiple_primitives.xml
|
128
|
+
- spec/fixtures/optional_attributes.xml
|
127
129
|
- spec/fixtures/pita.xml
|
128
130
|
- spec/fixtures/posts.xml
|
129
131
|
- spec/fixtures/product_default_namespace.xml
|