nokogiri-happymapper 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/lib/happymapper.rb CHANGED
@@ -1,9 +1,6 @@
1
- dir = File.dirname(__FILE__)
2
-
1
+ require 'nokogiri'
3
2
  require 'date'
4
3
  require 'time'
5
- require 'rubygems'
6
- require 'nokogiri'
7
4
 
8
5
  class Boolean; end
9
6
  class XmlContent; end
@@ -49,7 +46,7 @@ module HappyMapper
49
46
  def has_xml_content
50
47
  attr_accessor :xml_content
51
48
  end
52
-
49
+
53
50
  def has_one(name, type, options={})
54
51
  element name, type, {:single => true}.merge(options)
55
52
  end
@@ -96,7 +93,6 @@ module HappyMapper
96
93
  namespaces = options[:namespaces]
97
94
  namespaces ||= {}
98
95
  namespaces = namespaces.merge(xml.collect_namespaces) if xml.respond_to?(:collect_namespaces)
99
- namespaces = namespaces.merge(xml.namespaces)
100
96
 
101
97
  if namespaces.has_key?("xmlns")
102
98
  namespace ||= DEFAULT_NS
@@ -134,18 +130,18 @@ module HappyMapper
134
130
  end
135
131
 
136
132
  elements.each do |elem|
137
- obj.send("#{elem.method_name}=",
133
+ obj.send("#{elem.method_name}=",
138
134
  elem.from_xml_node(n, namespace, namespaces))
139
135
  end
140
136
 
141
- obj.send("#{@text_node.method_name}=",
137
+ obj.send("#{@text_node.method_name}=",
142
138
  @text_node.from_xml_node(n, namespace, namespaces)) if @text_node
143
139
 
144
140
  if obj.respond_to?('xml_content=')
145
141
  n = n.children if n.respond_to?(:children)
146
- obj.xml_content = n.to_xml
142
+ obj.xml_content = n.to_xml
147
143
  end
148
-
144
+
149
145
  obj
150
146
  end
151
147
 
@@ -161,7 +157,7 @@ module HappyMapper
161
157
  end
162
158
  end
163
159
 
164
- require File.join(dir, 'happymapper/item')
165
- require File.join(dir, 'happymapper/attribute')
166
- require File.join(dir, 'happymapper/element')
167
- require File.join(dir, 'happymapper/text_node')
160
+ require 'happymapper/item'
161
+ require 'happymapper/attribute'
162
+ require 'happymapper/element'
163
+ require 'happymapper/text_node'
@@ -5,16 +5,16 @@ require 'uri'
5
5
  module Analytics
6
6
  class Property
7
7
  include HappyMapper
8
-
8
+
9
9
  tag 'property'
10
10
  namespace 'dxp'
11
11
  attribute :name, String
12
12
  attribute :value, String
13
13
  end
14
-
14
+
15
15
  class Entry
16
16
  include HappyMapper
17
-
17
+
18
18
  tag 'entry'
19
19
  element :id, String
20
20
  element :updated, DateTime
@@ -22,10 +22,10 @@ module Analytics
22
22
  element :table_id, String, :namespace => 'dxp', :tag => 'tableId'
23
23
  has_many :properties, Property
24
24
  end
25
-
25
+
26
26
  class Feed
27
27
  include HappyMapper
28
-
28
+
29
29
  tag 'feed'
30
30
  element :id, String
31
31
  element :updated, DateTime
@@ -227,14 +227,14 @@ class Status
227
227
 
228
228
  element :id, Integer
229
229
  element :text, String
230
- element :created_at, Time
231
- element :source, String
232
- element :truncated, Boolean
233
- element :in_reply_to_status_id, Integer
234
- element :in_reply_to_user_id, Integer
235
- element :favorited, Boolean
236
- element :non_existent, String, :tag => 'dummy', :namespace => 'fake'
237
- has_one :user, User
230
+ element :created_at, Time
231
+ element :source, String
232
+ element :truncated, Boolean
233
+ element :in_reply_to_status_id, Integer
234
+ element :in_reply_to_user_id, Integer
235
+ element :favorited, Boolean
236
+ element :non_existent, String, :tag => 'dummy', :namespace => 'fake'
237
+ has_one :user, User
238
238
  end
239
239
 
240
240
  class CurrentWeather
@@ -256,7 +256,7 @@ end
256
256
 
257
257
  class Address
258
258
  include HappyMapper
259
-
259
+
260
260
  tag 'address'
261
261
  element :street, String
262
262
  element :postcode, String
@@ -323,7 +323,7 @@ module QuarterTest
323
323
  # in an ideal world, the following elements would all be
324
324
  # called 'quarter' with an attribute indicating which quarter
325
325
  # it represented, but the refactoring that allows a single class
326
- # to be used for all these differently named elements is the next
326
+ # to be used for all these differently named elements is the next
327
327
  # best thing
328
328
  has_one :details, QuarterTest::Details
329
329
  has_one :q1, QuarterTest::Quarter, :tag => 'q1'
@@ -344,7 +344,7 @@ end
344
344
 
345
345
  class Location
346
346
  include HappyMapper
347
-
347
+
348
348
  tag 'point'
349
349
  namespace "geo"
350
350
  element :latitude, String, :tag => "lat"
@@ -394,7 +394,7 @@ describe HappyMapper do
394
394
  before do
395
395
  @klass = Class.new do
396
396
  include HappyMapper
397
-
397
+
398
398
  def self.to_s
399
399
  'Boo'
400
400
  end
@@ -672,35 +672,35 @@ describe HappyMapper do
672
672
  last_event.address.zip.should == '327506398'
673
673
  track.tran_detail.cust_tran_id.should == '20090102-111321'
674
674
  end
675
-
675
+
676
676
  it "should be able to parse google analytics api xml" do
677
677
  data = Analytics::Feed.parse(fixture_file('analytics.xml'))
678
678
  data.id.should == 'http://www.google.com/analytics/feeds/accounts/nunemaker@gmail.com'
679
679
  data.entries.size.should == 4
680
-
680
+
681
681
  entry = data.entries[0]
682
682
  entry.title.should == 'addictedtonew.com'
683
683
  entry.properties.size.should == 4
684
-
684
+
685
685
  property = entry.properties[0]
686
686
  property.name.should == 'ga:accountId'
687
687
  property.value.should == '85301'
688
688
  end
689
-
689
+
690
690
  it "should allow instantiating with a string" do
691
691
  module StringFoo
692
692
  class Bar
693
693
  include HappyMapper
694
694
  has_many :things, 'StringFoo::Thing'
695
695
  end
696
-
696
+
697
697
  class Thing
698
698
  include HappyMapper
699
699
  end
700
700
  end
701
701
  end
702
-
703
- xit "should parse family search xml" do
702
+
703
+ it "should parse family search xml" do
704
704
  tree = FamilySearch::FamilyTree.parse(fixture_file('family_tree.xml'))
705
705
  tree.version.should == '1.0.20071213.942'
706
706
  tree.status_message.should == 'OK'
data/spec/spec_helper.rb CHANGED
@@ -1,13 +1,7 @@
1
- begin
2
- require 'spec'
3
- rescue LoadError
4
- require 'rubygems'
5
- gem 'rspec'
6
- require 'spec'
7
- end
1
+ require 'spec'
8
2
 
9
3
  require File.join(File.dirname(__FILE__), '..', 'lib', 'happymapper')
10
4
 
11
5
  def fixture_file(filename)
12
6
  File.read(File.dirname(__FILE__) + "/fixtures/#{filename}")
13
- end
7
+ end
metadata CHANGED
@@ -5,24 +5,29 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 4
9
- version: 0.3.4
8
+ - 5
9
+ version: 0.3.5
10
10
  platform: ruby
11
11
  authors:
12
- - Damien Le Berrigaud, John Nunemaker, David Bolton, Roland Swingler, Etienne Vallette d'Osia
12
+ - Damien Le Berrigaud
13
+ - John Nunemaker
14
+ - David Bolton
15
+ - Roland Swingler
16
+ - Etienne Vallette d'Osia
13
17
  autorequire:
14
18
  bindir: bin
15
19
  cert_chain: []
16
20
 
17
- date: 2010-06-24 00:00:00 +10:00
21
+ date: 2010-12-21 00:00:00 +01:00
18
22
  default_executable:
19
23
  dependencies:
20
24
  - !ruby/object:Gem::Dependency
21
25
  name: nokogiri
22
26
  prerelease: false
23
27
  requirement: &id001 !ruby/object:Gem::Requirement
28
+ none: false
24
29
  requirements:
25
- - - ">="
30
+ - - ~>
26
31
  - !ruby/object:Gem::Version
27
32
  segments:
28
33
  - 1
@@ -31,6 +36,21 @@ dependencies:
31
36
  version: 1.4.0
32
37
  type: :runtime
33
38
  version_requirements: *id001
39
+ - !ruby/object:Gem::Dependency
40
+ name: rspec
41
+ prerelease: false
42
+ requirement: &id002 !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ segments:
48
+ - 1
49
+ - 2
50
+ - 9
51
+ version: 1.2.9
52
+ type: :development
53
+ version_requirements: *id002
34
54
  description: Object to XML Mapping Library, using Nokogiri (fork from John Nunemaker's Happymapper)
35
55
  email: damien@meliondesign.com
36
56
  executables: []
@@ -40,32 +60,14 @@ extensions: []
40
60
  extra_rdoc_files:
41
61
  - README
42
62
  - TODO
63
+ files:
43
64
  - lib/happymapper.rb
44
65
  - lib/happymapper/attribute.rb
45
66
  - lib/happymapper/element.rb
46
67
  - lib/happymapper/item.rb
47
68
  - lib/happymapper/text_node.rb
48
- - lib/happymapper/version.rb
49
- files:
50
- - History
51
- - License
52
- - Manifest
53
69
  - README
54
- - Rakefile
55
70
  - TODO
56
- - examples/amazon.rb
57
- - examples/current_weather.rb
58
- - examples/dashed_elements.rb
59
- - examples/family_tree.rb
60
- - examples/post.rb
61
- - examples/twitter.rb
62
- - lib/happymapper.rb
63
- - lib/happymapper/attribute.rb
64
- - lib/happymapper/element.rb
65
- - lib/happymapper/item.rb
66
- - lib/happymapper/text_node.rb
67
- - lib/happymapper/version.rb
68
- - nokogiri-happymapper.gemspec
69
71
  - spec/fixtures/address.xml
70
72
  - spec/fixtures/ambigous_items.xml
71
73
  - spec/fixtures/analytics.xml
@@ -91,23 +93,17 @@ files:
91
93
  - spec/happymapper_text_node_spec.rb
92
94
  - spec/spec.opts
93
95
  - spec/spec_helper.rb
94
- - website/css/common.css
95
- - website/index.html
96
96
  has_rdoc: true
97
97
  homepage: http://github.com/dam5s/happymapper
98
98
  licenses: []
99
99
 
100
- post_install_message: May you have many happy mappings!
101
- rdoc_options:
102
- - --line-numbers
103
- - --inline-source
104
- - --title
105
- - Nokogiri-happymapper
106
- - --main
107
- - README
100
+ post_install_message:
101
+ rdoc_options: []
102
+
108
103
  require_paths:
109
104
  - lib
110
105
  required_ruby_version: !ruby/object:Gem::Requirement
106
+ none: false
111
107
  requirements:
112
108
  - - ">="
113
109
  - !ruby/object:Gem::Version
@@ -115,19 +111,43 @@ required_ruby_version: !ruby/object:Gem::Requirement
115
111
  - 0
116
112
  version: "0"
117
113
  required_rubygems_version: !ruby/object:Gem::Requirement
114
+ none: false
118
115
  requirements:
119
116
  - - ">="
120
117
  - !ruby/object:Gem::Version
121
118
  segments:
122
- - 1
123
- - 2
124
- version: "1.2"
119
+ - 0
120
+ version: "0"
125
121
  requirements: []
126
122
 
127
- rubyforge_project: nokogiri-happymapper
128
- rubygems_version: 1.3.6
123
+ rubyforge_project:
124
+ rubygems_version: 1.3.7
129
125
  signing_key:
130
126
  specification_version: 3
131
- summary: Object to XML Mapping Library, using Nokogiri (fork from John Nunemaker's Happymapper)
132
- test_files: []
133
-
127
+ summary: Provides a simple way to map XML to Ruby Objects
128
+ test_files:
129
+ - spec/fixtures/address.xml
130
+ - spec/fixtures/ambigous_items.xml
131
+ - spec/fixtures/analytics.xml
132
+ - spec/fixtures/commit.xml
133
+ - spec/fixtures/current_weather.xml
134
+ - spec/fixtures/dictionary.xml
135
+ - spec/fixtures/family_tree.xml
136
+ - spec/fixtures/lastfm.xml
137
+ - spec/fixtures/multiple_namespaces.xml
138
+ - spec/fixtures/multiple_primitives.xml
139
+ - spec/fixtures/pita.xml
140
+ - spec/fixtures/posts.xml
141
+ - spec/fixtures/product_default_namespace.xml
142
+ - spec/fixtures/product_no_namespace.xml
143
+ - spec/fixtures/product_single_namespace.xml
144
+ - spec/fixtures/quarters.xml
145
+ - spec/fixtures/radar.xml
146
+ - spec/fixtures/statuses.xml
147
+ - spec/happymapper_attribute_spec.rb
148
+ - spec/happymapper_element_spec.rb
149
+ - spec/happymapper_item_spec.rb
150
+ - spec/happymapper_spec.rb
151
+ - spec/happymapper_text_node_spec.rb
152
+ - spec/spec.opts
153
+ - spec/spec_helper.rb
data/History DELETED
@@ -1,59 +0,0 @@
1
- == 0.2.5
2
- * 1 minor tweak
3
- * Classes can now be strings instead of constants so you don't have to worry about class definition order (this was all for technicalpickles, enjoy!)
4
-
5
- == 0.2.4
6
- * 1 minor tweak
7
- * Added a patch that allows even crazy namespaces to work
8
-
9
- == 0.2.3
10
- * 1 minor tweak
11
- * bumped the version of libxml-ruby to 1.1.3
12
-
13
- == 0.2.2
14
- * 2 minor tweaks
15
- * removed GC.start (libxml recommended this) as setting nodes to nil should be enough, specs run 3-4x faster (Brandon Keepers)
16
- * renamed get_tag_name to tag_name (Brandon Keepers)
17
- * removed libxml helpers as they are no longer needed
18
-
19
- == 0.2.1
20
- * 1 minor fix, 3 major enhancements
21
- * fixed warnings about using XML::Parser (mojodna)
22
- * Improved namespace support, now handles multiple namespaces and allows namespaces to be set item wide or on a per element basis (mojodna)
23
- * Auto detect root nodes (mojodna)
24
- * Type coercion (mojodna)
25
-
26
- == 0.2.0
27
- * 1 major enhancement, 2 minor ehancements
28
- * Automatic handling of namespaces (part by Robert Lowrey and rest by John Nunemaker)
29
- * Added :root option to tag method. This allows setting an object as the root element, which sets xpath to use / and sets single to true
30
- * Now defaulting tag names for classes in modules to last constant downcased
31
-
32
- == 0.1.7 2009-01-29
33
- * 1 minor enhancement
34
- * Support dashes in elements (Josh Nichols)
35
-
36
- == 0.1.6 2009-01-17
37
- * 1 minor enhancement:
38
- * added support for nested collection elements (Justin Marney)
39
-
40
- == 0.1.5 2009-01-05
41
- * 1 major enhancement:
42
- * Updated to latest version of libxml-ruby (lightningdb)
43
-
44
- == 0.1.4 2009-01-05
45
- * 1 major enhancement:
46
- * Fixed parsing when the object is the root node. (Garret Alfert)
47
-
48
- == 0.1.3 2008-12-31
49
- * 1 major enhancement:
50
- * Added parsing of attributes of elements that are also mapped, see current_weather.rb for example (jeremyf)
51
-
52
- == 0.1.2 2008-12-12
53
- * 1 major enhancement:
54
- * Fixed that :deep only worked for first item (dvrensk)
55
-
56
- == 0.1.0 2008-11-16
57
-
58
- * 1 major enhancement:
59
- * Initial release
data/License DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2008 John Nunemaker
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest DELETED
@@ -1,46 +0,0 @@
1
- History
2
- License
3
- Manifest
4
- README
5
- Rakefile
6
- TODO
7
- examples/amazon.rb
8
- examples/current_weather.rb
9
- examples/dashed_elements.rb
10
- examples/family_tree.rb
11
- examples/post.rb
12
- examples/twitter.rb
13
- lib/happymapper.rb
14
- lib/happymapper/attribute.rb
15
- lib/happymapper/element.rb
16
- lib/happymapper/item.rb
17
- lib/happymapper/text_node.rb
18
- lib/happymapper/version.rb
19
- nokogiri-happymapper.gemspec
20
- spec/fixtures/address.xml
21
- spec/fixtures/ambigous_items.xml
22
- spec/fixtures/analytics.xml
23
- spec/fixtures/commit.xml
24
- spec/fixtures/current_weather.xml
25
- spec/fixtures/dictionary.xml
26
- spec/fixtures/family_tree.xml
27
- spec/fixtures/lastfm.xml
28
- spec/fixtures/multiple_namespaces.xml
29
- spec/fixtures/multiple_primitives.xml
30
- spec/fixtures/pita.xml
31
- spec/fixtures/posts.xml
32
- spec/fixtures/product_default_namespace.xml
33
- spec/fixtures/product_no_namespace.xml
34
- spec/fixtures/product_single_namespace.xml
35
- spec/fixtures/quarters.xml
36
- spec/fixtures/radar.xml
37
- spec/fixtures/statuses.xml
38
- spec/happymapper_attribute_spec.rb
39
- spec/happymapper_element_spec.rb
40
- spec/happymapper_item_spec.rb
41
- spec/happymapper_spec.rb
42
- spec/happymapper_text_node_spec.rb
43
- spec/spec.opts
44
- spec/spec_helper.rb
45
- website/css/common.css
46
- website/index.html
data/Rakefile DELETED
@@ -1,28 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require 'echoe'
4
- require 'spec/rake/spectask'
5
- require "lib/happymapper/version"
6
-
7
- Echoe.new('nokogiri-happymapper', HappyMapper::Version) do |p|
8
- p.description = "Object to XML Mapping Library, using Nokogiri (fork from John Nunemaker's Happymapper)"
9
- p.install_message = "May you have many happy mappings!"
10
- p.url = "http://github.com/dam5s/happymapper"
11
- p.author = "Damien Le Berrigaud, John Nunemaker, David Bolton, Roland Swingler, Etienne Vallette d'Osia"
12
- p.email = "damien@meliondesign.com"
13
- p.extra_deps = ['nokogiri >=1.4.0']
14
- p.need_tar_gz = false
15
- end
16
-
17
- desc 'Preps the gem for a new release'
18
- task :prepare do
19
- %w[manifest build_gemspec].each do |task|
20
- Rake::Task[task].invoke
21
- end
22
- end
23
-
24
- Rake::Task[:default].prerequisites.clear
25
- task :default => :spec
26
- Spec::Rake::SpecTask.new do |t|
27
- t.spec_files = FileList["spec/**/*_spec.rb"]
28
- end
data/examples/amazon.rb DELETED
@@ -1,34 +0,0 @@
1
- dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- require File.join(dir, 'happymapper')
3
-
4
- file_contents = File.read(dir + '/../spec/fixtures/pita.xml')
5
-
6
- # The document `pita.xml` contains both a default namespace and the 'georss'
7
- # namespace (for the 'point' element).
8
- module PITA
9
- class Item
10
- include HappyMapper
11
-
12
- tag 'Item' # if you put class in module you need tag
13
- element :asin, String, :tag => 'ASIN'
14
- element :detail_page_url, String, :tag => 'DetailPageURL'
15
- element :manufacturer, String, :tag => 'Manufacturer', :deep => true
16
- # this is the only element that exists in a different namespace, so it
17
- # must be explicitly specified
18
- element :point, String, :tag => 'point', :namespace => 'georss'
19
- end
20
-
21
- class Items
22
- include HappyMapper
23
-
24
- tag 'Items' # if you put class in module you need tag
25
- element :total_results, Integer, :tag => 'TotalResults'
26
- element :total_pages, Integer, :tag => 'TotalPages'
27
- has_many :items, Item
28
- end
29
- end
30
-
31
- item = PITA::Items.parse(file_contents, :single => true)
32
- item.items.each do |i|
33
- puts i.asin, i.detail_page_url, i.manufacturer, ''
34
- end
@@ -1,21 +0,0 @@
1
- dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- require File.join(dir, 'happymapper')
3
-
4
- file_contents = File.read(dir + '/../spec/fixtures/current_weather.xml')
5
-
6
- class CurrentWeather
7
- include HappyMapper
8
-
9
- tag 'ob'
10
- namespace 'aws'
11
- element :temperature, Integer, :tag => 'temp'
12
- element :feels_like, Integer, :tag => 'feels-like'
13
- element :current_condition, String, :tag => 'current-condition', :attributes => {:icon => String}
14
- end
15
-
16
- CurrentWeather.parse(file_contents).each do |current_weather|
17
- puts "temperature: #{current_weather.temperature}"
18
- puts "feels_like: #{current_weather.feels_like}"
19
- puts "current_condition: #{current_weather.current_condition}"
20
- puts "current_condition.icon: #{current_weather.current_condition.icon}"
21
- end
@@ -1,20 +0,0 @@
1
- dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- require File.join(dir, 'happymapper')
3
-
4
- file_contents = File.read(dir + '/../spec/fixtures/commit.xml')
5
-
6
- module GitHub
7
- class Commit
8
- include HappyMapper
9
-
10
- tag "commit"
11
- element :url, String
12
- element :tree, String
13
- element :message, String
14
- element :id, String
15
- element :'committed-date', Date
16
- end
17
- end
18
-
19
- commit = GitHub::Commit.parse(file_contents)
20
- puts commit.committed_date, commit.url, commit.id
@@ -1,48 +0,0 @@
1
- dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- require File.join(dir, 'happymapper')
3
-
4
- file_contents = File.read(dir + '/../spec/fixtures/family_tree.xml')
5
-
6
- module FamilySearch
7
- class AlternateIds
8
- include HappyMapper
9
-
10
- tag 'alternateIds'
11
- has_many :ids, String, :tag => 'id'
12
- end
13
-
14
- class Information
15
- include HappyMapper
16
-
17
- has_one :alternateIds, AlternateIds
18
- end
19
-
20
- class Person
21
- include HappyMapper
22
-
23
- attribute :version, String
24
- attribute :modified, Time
25
- attribute :id, String
26
- has_one :information, Information
27
- end
28
-
29
- class Persons
30
- include HappyMapper
31
- has_many :person, Person
32
- end
33
-
34
- class FamilyTree
35
- include HappyMapper
36
-
37
- tag 'familytree'
38
- attribute :version, String
39
- attribute :status_message, String, :tag => 'statusMessage'
40
- attribute :status_code, String, :tag => 'statusCode'
41
- has_one :persons, Persons
42
- end
43
- end
44
-
45
- familytree = FamilySearch::FamilyTree.parse(file_contents)
46
- familytree.persons.person.each do |p|
47
- puts p.id, p.information.alternateIds.ids, ''
48
- end
data/examples/post.rb DELETED
@@ -1,19 +0,0 @@
1
- dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- require File.join(dir, 'happymapper')
3
-
4
- file_contents = File.read(dir + '/../spec/fixtures/posts.xml')
5
-
6
- class Post
7
- include HappyMapper
8
-
9
- attribute :href, String
10
- attribute :hash, String
11
- attribute :description, String
12
- attribute :tag, String
13
- attribute :time, DateTime
14
- attribute :others, Integer
15
- attribute :extended, String
16
- end
17
-
18
- posts = Post.parse(file_contents)
19
- posts.each { |post| puts post.description, post.href, post.extended, '' }
data/examples/twitter.rb DELETED
@@ -1,37 +0,0 @@
1
- dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- require File.join(dir, 'happymapper')
3
-
4
- file_contents = File.read(dir + '/../spec/fixtures/statuses.xml')
5
-
6
- class User
7
- include HappyMapper
8
-
9
- element :id, Integer
10
- element :name, String
11
- element :screen_name, String
12
- element :location, String
13
- element :description, String
14
- element :profile_image_url, String
15
- element :url, String
16
- element :protected, Boolean
17
- element :followers_count, Integer
18
- end
19
-
20
- class Status
21
- include HappyMapper
22
-
23
- element :id, Integer
24
- element :text, String
25
- element :created_at, Time
26
- element :source, String
27
- element :truncated, Boolean
28
- element :in_reply_to_status_id, Integer
29
- element :in_reply_to_user_id, Integer
30
- element :favorited, Boolean
31
- has_one :user, User
32
- end
33
-
34
- statuses = Status.parse(file_contents)
35
- statuses.each do |status|
36
- puts status.user.name, status.user.screen_name, status.text, status.source, ''
37
- end
@@ -1,3 +0,0 @@
1
- module HappyMapper
2
- Version = '0.3.4'
3
- end
@@ -1,34 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{nokogiri-happymapper}
5
- s.version = "0.3.4"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Damien Le Berrigaud, John Nunemaker, David Bolton, Roland Swingler, Etienne Vallette d'Osia"]
9
- s.date = %q{2010-06-24}
10
- s.description = %q{Object to XML Mapping Library, using Nokogiri (fork from John Nunemaker's Happymapper)}
11
- s.email = %q{damien@meliondesign.com}
12
- s.extra_rdoc_files = ["README", "TODO", "lib/happymapper.rb", "lib/happymapper/attribute.rb", "lib/happymapper/element.rb", "lib/happymapper/item.rb", "lib/happymapper/text_node.rb", "lib/happymapper/version.rb"]
13
- s.files = ["History", "License", "Manifest", "README", "Rakefile", "TODO", "examples/amazon.rb", "examples/current_weather.rb", "examples/dashed_elements.rb", "examples/family_tree.rb", "examples/post.rb", "examples/twitter.rb", "lib/happymapper.rb", "lib/happymapper/attribute.rb", "lib/happymapper/element.rb", "lib/happymapper/item.rb", "lib/happymapper/text_node.rb", "lib/happymapper/version.rb", "nokogiri-happymapper.gemspec", "spec/fixtures/address.xml", "spec/fixtures/ambigous_items.xml", "spec/fixtures/analytics.xml", "spec/fixtures/commit.xml", "spec/fixtures/current_weather.xml", "spec/fixtures/dictionary.xml", "spec/fixtures/family_tree.xml", "spec/fixtures/lastfm.xml", "spec/fixtures/multiple_namespaces.xml", "spec/fixtures/multiple_primitives.xml", "spec/fixtures/pita.xml", "spec/fixtures/posts.xml", "spec/fixtures/product_default_namespace.xml", "spec/fixtures/product_no_namespace.xml", "spec/fixtures/product_single_namespace.xml", "spec/fixtures/quarters.xml", "spec/fixtures/radar.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/happymapper_text_node_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "website/css/common.css", "website/index.html"]
14
- s.homepage = %q{http://github.com/dam5s/happymapper}
15
- s.post_install_message = %q{May you have many happy mappings!}
16
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Nokogiri-happymapper", "--main", "README"]
17
- s.require_paths = ["lib"]
18
- s.rubyforge_project = %q{nokogiri-happymapper}
19
- s.rubygems_version = %q{1.3.6}
20
- s.summary = %q{Object to XML Mapping Library, using Nokogiri (fork from John Nunemaker's Happymapper)}
21
-
22
- if s.respond_to? :specification_version then
23
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
- s.specification_version = 3
25
-
26
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
- s.add_runtime_dependency(%q<nokogiri>, [">= 1.4.0"])
28
- else
29
- s.add_dependency(%q<nokogiri>, [">= 1.4.0"])
30
- end
31
- else
32
- s.add_dependency(%q<nokogiri>, [">= 1.4.0"])
33
- end
34
- end
@@ -1,47 +0,0 @@
1
- @media screen, projection {
2
- /*
3
- Copyright (c) 2007, Yahoo! Inc. All rights reserved.
4
- Code licensed under the BSD License:
5
- http://developer.yahoo.net/yui/license.txt
6
- version: 2.2.0
7
- */
8
- body {font:13px arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}table {font-size:inherit;font:100%;}select, input, textarea {font:99% arial,helvetica,clean,sans-serif;}pre, code {font:115% monospace;*font-size:100%;}body * {line-height:1.22em;}
9
- body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}/*ol,ul {list-style:none;}*/caption,th {text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym {border:0;}
10
- /* end of yahoo reset and fonts */
11
-
12
- body {color:#333; background:#4b1a1a; line-height:1.3;}
13
- p {margin:0 0 20px;}
14
- a {color:#4b1a1a;}
15
- a:hover {text-decoration:none;}
16
- strong {font-weight:bold;}
17
- em {font-style:italics;}
18
- h1,h2,h3,h4,h5,h6 {font-weight:bold;}
19
- h1 {font-size:197%; margin:30px 0; color:#4b1a1a;}
20
- h2 {font-size:174%; margin:20px 0; color:#b8111a;}
21
- h3 {font-size:152%; margin:10px 0;}
22
- h4 {font-size:129%; margin:10px 0;}
23
- pre {background:#eee; margin:0 0 20px; padding:20px; border:1px solid #ccc; font-size:100%; overflow:auto;}
24
- code {font-size:100%; margin:0; padding:0;}
25
- ul, ol {margin:10px 0 10px 25px;}
26
- ol li {margin:0 0 10px;}
27
-
28
-
29
-
30
-
31
-
32
- div#wrapper {background:#fff; width:560px; margin:0 auto; padding:20px; border:10px solid #bc8c46; border-width:0 10px;}
33
- div#header {position:relative; border-bottom:1px dotted; margin:0 0 10px; padding:0 0 10px;}
34
- div#header p {margin:0; padding:0;}
35
- div#header h1 {margin:0; padding:0;}
36
- ul#nav {position:absolute; top:0; right:0; list-style:none; margin:0; padding:0;}
37
- ul#nav li {display:inline; padding:0 0 0 5px;}
38
- ul#nav li a {}
39
- div#content {}
40
- div#footer {margin:40px 0 0; border-top:1px dotted; padding:10px 0 0;}
41
-
42
-
43
-
44
-
45
-
46
-
47
- }
data/website/index.html DELETED
@@ -1,98 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
- <head>
4
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5
- <title>HappyMapper by John Nunemaker</title>
6
- <link rel="stylesheet" href="css/common.css" type="text/css" />
7
- </head>
8
- <body>
9
-
10
- <div id="wrapper">
11
- <div id="header">
12
- <h1>HappyMapper</h1>
13
- <p>Object to xml mapping library.</p>
14
-
15
- <ul id="nav">
16
- <li><a href="rdoc/">Docs</a></li>
17
- <li><a href="http://github.com/jnunemaker/happymapper">Github</a></li>
18
- <li><a href="http://jnunemaker.lighthouseapp.com/projects/20014-happy-mapper/overview">Lighthouse</a></li>
19
- <li><a href="http://rubyforge.org/projects/happymapper/">Rubyforge</a></li>
20
- </ul>
21
- </div>
22
-
23
- <div id="content">
24
- <h2>Install</h2>
25
- <pre><code>$ sudo gem install happymapper</code></pre>
26
-
27
- <h2>Examples</h2>
28
-
29
- <h3>Given the following xml:</h3>
30
- <pre><code>&lt;statuses type="array">
31
- &lt;status>
32
- &lt;created_at>Sat Aug 09 05:38:12 +0000 2008&lt;/created_at>
33
- &lt;id>882281424&lt;/id>
34
- &lt;text>I so just thought the guy lighting the Olympic torch was falling when he began to run on the wall. Wow that would have been catastrophic.&lt;/text>
35
- &lt;source>web&lt;/source>
36
- &lt;truncated>false&lt;/truncated>
37
- &lt;in_reply_to_status_id>1234&lt;/in_reply_to_status_id>
38
- &lt;in_reply_to_user_id>12345&lt;/in_reply_to_user_id>
39
- &lt;favorited>&lt;/favorited>
40
- &lt;user>
41
- &lt;id>4243&lt;/id>
42
- &lt;name>John Nunemaker&lt;/name>
43
- &lt;screen_name>jnunemaker&lt;/screen_name>
44
- &lt;location>Mishawaka, IN, US&lt;/location>
45
- &lt;description>Loves his wife, ruby, notre dame football and iu basketball&lt;/description>
46
- &lt;profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/53781608/Photo_75_normal.jpg&lt;/profile_image_url>
47
- &lt;url>http://addictedtonew.com&lt;/url>
48
- &lt;protected>false&lt;/protected>
49
- &lt;followers_count>486&lt;/followers_count>
50
- &lt;/user>
51
- &lt;/status>
52
- &lt;/statuses></code></pre>
53
-
54
- <h3>You could have the following objects:</h3>
55
-
56
- <pre><code>class User
57
- include HappyMapper
58
-
59
- element :id, Integer
60
- element :name, String
61
- element :screen_name, String
62
- element :location, String
63
- element :description, String
64
- element :profile_image_url, String
65
- element :url, String
66
- element :protected, Boolean
67
- element :followers_count, Integer
68
- end
69
-
70
- class Status
71
- include HappyMapper
72
-
73
- element :id, Integer
74
- element :text, String
75
- element :created_at, Time
76
- element :source, String
77
- element :truncated, Boolean
78
- element :in_reply_to_status_id, Integer
79
- element :in_reply_to_user_id, Integer
80
- element :favorited, Boolean
81
- has_one :user, User
82
- end
83
-
84
- statuses = Status.parse(file_contents)
85
- statuses.each do |status|
86
- puts status.user.name, status.user.screen_name, status.text, status.source, ''
87
- end</code></pre>
88
-
89
- <h2>Support</h2>
90
- <p>Conversations welcome in the <a href="http://groups.google.com/group/happymapper">google group</a> and bugs/features over at <a href="http://github.com/jnunemaker/happymapper/issues/">Github</a>.</p>
91
- </div>
92
-
93
- <div id="footer">
94
- <p>Created by <a href="http://addictedtonew.com/about/">John Nunemaker</a></p>
95
- </div>
96
- </div>
97
- </body>
98
- </html>