happymapper 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.1.4 2009-01-05
2
+ * 1 major enhancement:
3
+ * Fixed parsing when the object is the root node. (Garret Alfert)
4
+
1
5
  == 0.1.3 2008-12-31
2
6
  * 1 major enhancement:
3
7
  * Added parsing of attributes of elements that are also mapped, see current_weather.rb for example (jeremyf)
data/Manifest.txt CHANGED
@@ -23,6 +23,7 @@ script/destroy
23
23
  script/generate
24
24
  script/txt2html
25
25
  setup.rb
26
+ spec/fixtures/address.xml
26
27
  spec/fixtures/current_weather.xml
27
28
  spec/fixtures/pita.xml
28
29
  spec/fixtures/posts.xml
data/happymapper.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{happymapper}
5
- s.version = "0.1.3"
5
+ s.version = "0.1.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["John Nunemaker"]
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.description = %q{object to xml mapping library}
11
11
  s.email = ["nunemaker@gmail.com"]
12
12
  s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "PostInstall.txt", "README.txt", "TODO.txt"]
13
- s.files = ["History.txt", "License.txt", "Manifest.txt", "PostInstall.txt", "README.txt", "Rakefile", "TODO.txt", "config/hoe.rb", "config/requirements.rb", "examples/amazon.rb", "examples/current_weather.rb", "examples/post.rb", "examples/twitter.rb", "happymapper.gemspec", "lib/happymapper.rb", "lib/happymapper/attribute.rb", "lib/happymapper/element.rb", "lib/happymapper/item.rb", "lib/happymapper/version.rb", "lib/libxml_ext/libxml_helper.rb", "script/console", "script/destroy", "script/generate", "script/txt2html", "setup.rb", "spec/fixtures/current_weather.xml", "spec/fixtures/pita.xml", "spec/fixtures/posts.xml", "spec/fixtures/statuses.xml", "spec/happymapper_attribute_spec.rb", "spec/happymapper_element_spec.rb", "spec/happymapper_item_spec.rb", "spec/happymapper_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/deployment.rake", "tasks/environment.rake", "tasks/rspec.rake", "tasks/website.rake", "website/css/common.css", "website/index.html"]
13
+ s.files = ["History.txt", "License.txt", "Manifest.txt", "PostInstall.txt", "README.txt", "Rakefile", "TODO.txt", "config/hoe.rb", "config/requirements.rb", "examples/amazon.rb", "examples/current_weather.rb", "examples/post.rb", "examples/twitter.rb", "happymapper.gemspec", "lib/happymapper.rb", "lib/happymapper/attribute.rb", "lib/happymapper/element.rb", "lib/happymapper/item.rb", "lib/happymapper/version.rb", "lib/libxml_ext/libxml_helper.rb", "script/console", "script/destroy", "script/generate", "script/txt2html", "setup.rb", "spec/fixtures/address.xml", "spec/fixtures/current_weather.xml", "spec/fixtures/pita.xml", "spec/fixtures/posts.xml", "spec/fixtures/statuses.xml", "spec/happymapper_attribute_spec.rb", "spec/happymapper_element_spec.rb", "spec/happymapper_item_spec.rb", "spec/happymapper_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/deployment.rake", "tasks/environment.rake", "tasks/rspec.rake", "tasks/website.rake", "website/css/common.css", "website/index.html"]
14
14
  s.has_rdoc = true
15
15
  s.homepage = %q{http://happymapper.rubyforge.org}
16
16
  s.post_install_message = %q{}
@@ -2,7 +2,7 @@ module HappyMapper
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 3
5
+ TINY = 4
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/lib/happymapper.rb CHANGED
@@ -73,7 +73,7 @@ module HappyMapper
73
73
  node.register_default_namespace(namespace.chop)
74
74
  node.find("#{namespace}#{get_tag_name}")
75
75
  else
76
- doc.find(get_tag_name)
76
+ doc.find("//#{get_tag_name}")
77
77
  end
78
78
 
79
79
  collection = create_collection(nodes, namespace)
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <address>
3
+ <street>Milchstrasse</street>
4
+ <housenumber>23</housenumber>
5
+ <postcode>26131</postcode>
6
+ <city>Oldenburg</city>
7
+ <country code="de">Germany</country>
8
+ </address>
@@ -48,6 +48,15 @@ class CurrentWeather
48
48
  element :current_condition, String, :tag => 'aws:current-condition', :attributes => {:icon => String}
49
49
  end
50
50
 
51
+ class Address
52
+ include HappyMapper
53
+
54
+ element :street, String
55
+ element :postcode, String
56
+ element :housenumber, String
57
+ element :city, String
58
+ element :country, String
59
+ end
51
60
 
52
61
  module PITA
53
62
  class Item
@@ -202,6 +211,21 @@ describe HappyMapper do
202
211
  first.user.followers_count.should == 486
203
212
  end
204
213
  end
214
+
215
+ describe "#parse (with xml containing the desired element as root node)" do
216
+ before do
217
+ file_contents = File.read(File.dirname(__FILE__) + '/fixtures/address.xml')
218
+ @address = Address.parse(file_contents, :single => true)
219
+ end
220
+
221
+ it "should properly create objects" do
222
+ @address.street.should == 'Milchstrasse'
223
+ @address.postcode.should == '26131'
224
+ @address.housenumber.should == '23'
225
+ @address.city.should == 'Oldenburg'
226
+ @address.country.should == 'Germany'
227
+ end
228
+ end
205
229
 
206
230
  # TODO: someone please get xml with namespaces working, kthxbai
207
231
  describe "#parse (with xml that has namespace)" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: happymapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
@@ -62,6 +62,7 @@ files:
62
62
  - script/generate
63
63
  - script/txt2html
64
64
  - setup.rb
65
+ - spec/fixtures/address.xml
65
66
  - spec/fixtures/current_weather.xml
66
67
  - spec/fixtures/pita.xml
67
68
  - spec/fixtures/posts.xml