roxml 3.2.1 → 3.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,8 +6,6 @@
6
6
  (fixes gh issue #27)
7
7
  * change the way we monkey patch Nokogiri to leave the original
8
8
  behaviour of the search() method unchanged (fixes gh issue #16)
9
- * Unofficial release by James Healy, empact has stepped back from maintaining
10
- roxml
11
9
 
12
10
  == 3.1.5 (December 18, 2009)
13
11
 
data/Rakefile CHANGED
@@ -32,8 +32,8 @@ task :libxml => ['test:libxml', 'spec:libxml']
32
32
  task :nokogiri => ['test:nokogiri', 'spec:nokogiri']
33
33
 
34
34
 
35
- require 'rake/rdoctask'
36
- Rake::RDocTask.new do |rdoc|
35
+ require 'rdoc/task'
36
+ RDoc::Task.new do |rdoc|
37
37
  if File.exist?('VERSION')
38
38
  version = File.read('VERSION')
39
39
  else
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.2.1
1
+ 3.2.2
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative './../spec/spec_helper'
3
+
4
+ class Person
5
+ include ROXML
6
+
7
+ xml_accessor :name, :from => 'name'
8
+
9
+ xml_accessor :lat, :from => 'latitude', :in => 'location/coordinates'
10
+ xml_accessor :long, :from => 'longitude', :in => 'location/coordinates'
11
+
12
+ xml_accessor :street, :from => 'street', :in => 'location/address'
13
+ xml_accessor :city, :from => 'city', :in => 'location/address'
14
+ xml_accessor :zip, :from => 'zip', :in => 'location/address'
15
+ end
16
+
17
+ unless defined?(RSpec)
18
+ p = Person.new
19
+ p.name = 'John Doe'
20
+
21
+ p.lat = '40.715224'
22
+ p.long = '-74.005966'
23
+ p.street = 'Evergreen Terrace'
24
+ p.city = 'Springfield'
25
+ p.zip = '2342'
26
+
27
+ puts p.to_xml.to_s
28
+ end
@@ -0,0 +1,14 @@
1
+ <person>
2
+ <name>John Doe</name>
3
+ <location>
4
+ <coordinates>
5
+ <latitude>40.715224</latitude>
6
+ <longitude>-74.005966</longitude>
7
+ </coordinates>
8
+ <address>
9
+ <street>Evergreen Terrace</street>
10
+ <city>Springfield</city>
11
+ <zip>2342</zip>
12
+ </address>
13
+ </location>
14
+ </person>
@@ -1,7 +1,7 @@
1
1
  require 'uri'
2
2
 
3
3
  require 'active_support'
4
- if Gem.loaded_specs['activesupport'].version >= Gem::Version.new('3')
4
+ if Gem.loaded_specs['activesupport'] && Gem.loaded_specs['activesupport'].version >= Gem::Version.new('3')
5
5
  require 'active_support/inflector'
6
6
  require 'active_support/core_ext/object/duplicable'
7
7
  require 'active_support/core_ext/module/delegation'
@@ -14,7 +14,7 @@ require 'roxml/definition'
14
14
  require 'roxml/xml'
15
15
 
16
16
  module ROXML # :nodoc:
17
- VERSION = '3.1.5'
17
+ VERSION = '3.2.1'
18
18
 
19
19
  def self.included(base) # :nodoc:
20
20
  base.class_eval do
@@ -90,17 +90,20 @@ module ROXML
90
90
 
91
91
  def wrap(xml, opts = {:always_create => false})
92
92
  wrap_with = @auto_vals ? auto_wrapper : wrapper
93
-
93
+
94
94
  return xml if !wrap_with || xml.name == wrap_with
95
- if !opts[:always_create] && (child = xml.children.find {|c| c.name == wrap_with })
96
- return child
97
- end
98
95
 
99
96
  wraps = wrap_with.to_s.split('/')
100
- wraps.inject(xml){|node,wrap| XML.add_node(node, wrap)}
97
+ wraps.inject(xml) do |node,wrap|
98
+ if !opts[:always_create] && (child = node.children.find {|c| c.name == wrap })
99
+ child
100
+ else
101
+ XML.add_node(node, wrap)
102
+ end
103
+ end
104
+
101
105
  end
102
106
 
103
-
104
107
  def nodes_in(xml)
105
108
  @default_namespace = xml.default_namespace
106
109
  vals = xml.roxml_search(xpath, @instance.class.roxml_namespaces)
@@ -4,19 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{roxml}
8
- s.version = "3.2.1"
7
+ s.name = "roxml"
8
+ s.version = "3.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = [%q{Ben Woosley}, %q{Zak Mandhro}, %q{Anders Engstrom}, %q{Russ Olsen}]
12
- s.date = %q{2012-01-05}
13
- s.description = %q{ROXML is a Ruby library designed to make it easier for Ruby developers to work with XML.
14
- Using simple annotations, it enables Ruby classes to be mapped to XML. ROXML takes care
15
- of the marshalling and unmarshalling of mapped attributes so that developers can focus on
16
- building first-class Ruby classes. As a result, ROXML simplifies the development of
17
- RESTful applications, Web Services, and XML-RPC.
18
- }
19
- s.email = %q{ben.woosley@gmail.com}
11
+ s.authors = ["Ben Woosley", "Zak Mandhro", "Anders Engstrom", "Russ Olsen"]
12
+ s.date = "2012-01-30"
13
+ s.description = "ROXML is a Ruby library designed to make it easier for Ruby developers to work with XML.\nUsing simple annotations, it enables Ruby classes to be mapped to XML. ROXML takes care\nof the marshalling and unmarshalling of mapped attributes so that developers can focus on\nbuilding first-class Ruby classes. As a result, ROXML simplifies the development of\nRESTful applications, Web Services, and XML-RPC.\n"
14
+ s.email = "ben.woosley@gmail.com"
20
15
  s.extra_rdoc_files = [
21
16
  "History.txt",
22
17
  "README.rdoc"
@@ -37,6 +32,7 @@ RESTful applications, Web Services, and XML-RPC.
37
32
  "examples/dashed_elements.rb",
38
33
  "examples/library.rb",
39
34
  "examples/library_with_fines.rb",
35
+ "examples/person.rb",
40
36
  "examples/posts.rb",
41
37
  "examples/rails.rb",
42
38
  "examples/twitter.rb",
@@ -45,6 +41,7 @@ RESTful applications, Web Services, and XML-RPC.
45
41
  "examples/xml/current_weather.xml",
46
42
  "examples/xml/dashed_elements.xml",
47
43
  "examples/xml/library_with_fines.xml",
44
+ "examples/xml/person.xml",
48
45
  "examples/xml/posts.xml",
49
46
  "examples/xml/twitter.xml",
50
47
  "lib/roxml.rb",
@@ -62,6 +59,7 @@ RESTful applications, Web Services, and XML-RPC.
62
59
  "spec/examples/dashed_elements_spec.rb",
63
60
  "spec/examples/library_spec.rb",
64
61
  "spec/examples/library_with_fines_spec.rb",
62
+ "spec/examples/person_spec.rb",
65
63
  "spec/examples/post_spec.rb",
66
64
  "spec/examples/twitter_spec.rb",
67
65
  "spec/reference_spec.rb",
@@ -130,11 +128,11 @@ RESTful applications, Web Services, and XML-RPC.
130
128
  "test/unit/xml_text_test.rb",
131
129
  "website/index.html"
132
130
  ]
133
- s.homepage = %q{http://roxml.rubyforge.org}
134
- s.require_paths = [%q{lib}]
135
- s.rubyforge_project = %q{roxml}
136
- s.rubygems_version = %q{1.8.8}
137
- s.summary = %q{Ruby Object to XML mapping library}
131
+ s.homepage = "http://roxml.rubyforge.org"
132
+ s.require_paths = ["lib"]
133
+ s.rubyforge_project = "roxml"
134
+ s.rubygems_version = "1.8.10"
135
+ s.summary = "Ruby Object to XML mapping library"
138
136
 
139
137
  if s.respond_to? :specification_version then
140
138
  s.specification_version = 3
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+ require_relative './../../examples/person'
3
+
4
+ describe Person do
5
+
6
+ before do
7
+ @person = Person.new
8
+ @person.name = 'John Doe'
9
+ @person.lat = '40.715224'
10
+ @person.long = '-74.005966'
11
+ @person.street = 'Evergreen Terrace'
12
+ @person.city = 'Springfield'
13
+ @person.zip = '2342'
14
+ end
15
+
16
+ it 'should only contain one location element' do
17
+ @person.to_xml.roxml_search('location').count.should == 1
18
+ end
19
+
20
+ describe '#to_xml' do
21
+ before do
22
+ @xml_generated = @person.to_xml.to_s.gsub("\n",'').squeeze(' ')
23
+ end
24
+
25
+ it 'should generate the expected xml' do
26
+ xml_file = File.read(xml_for('person')).gsub("\n",'').squeeze(' ')
27
+ xml_file.should == @xml_generated
28
+ end
29
+
30
+ it 'should generate identical xml after a full roundtrip' do
31
+ p = Person.from_xml(@xml_generated)
32
+ xml_roundtrip = p.to_xml.to_s.gsub("\n",'').squeeze(' ')
33
+ xml_roundtrip.should == @xml_generated
34
+ end
35
+ end
36
+
37
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roxml
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,11 +12,11 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2012-01-05 00:00:00.000000000Z
15
+ date: 2012-01-30 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport
19
- requirement: &2165456080 !ruby/object:Gem::Requirement
19
+ requirement: &70164162904540 !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
22
  - - ! '>='
@@ -24,10 +24,10 @@ dependencies:
24
24
  version: 2.3.0
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: *2165456080
27
+ version_requirements: *70164162904540
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: nokogiri
30
- requirement: &2165455600 !ruby/object:Gem::Requirement
30
+ requirement: &70164162900300 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ! '>='
@@ -35,10 +35,10 @@ dependencies:
35
35
  version: 1.3.3
36
36
  type: :runtime
37
37
  prerelease: false
38
- version_requirements: *2165455600
38
+ version_requirements: *70164162900300
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: rake
41
- requirement: &2165455120 !ruby/object:Gem::Requirement
41
+ requirement: &70164162909420 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
44
  - - ! '>='
@@ -46,10 +46,10 @@ dependencies:
46
46
  version: '0'
47
47
  type: :development
48
48
  prerelease: false
49
- version_requirements: *2165455120
49
+ version_requirements: *70164162909420
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: jeweler
52
- requirement: &2165454640 !ruby/object:Gem::Requirement
52
+ requirement: &70164162927020 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - ! '>='
@@ -57,10 +57,10 @@ dependencies:
57
57
  version: '0'
58
58
  type: :development
59
59
  prerelease: false
60
- version_requirements: *2165454640
60
+ version_requirements: *70164162927020
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rspec
63
- requirement: &2165454160 !ruby/object:Gem::Requirement
63
+ requirement: &70164162923220 !ruby/object:Gem::Requirement
64
64
  none: false
65
65
  requirements:
66
66
  - - ! '>='
@@ -68,10 +68,10 @@ dependencies:
68
68
  version: 2.0.0
69
69
  type: :development
70
70
  prerelease: false
71
- version_requirements: *2165454160
71
+ version_requirements: *70164162923220
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: sqlite3-ruby
74
- requirement: &2165453680 !ruby/object:Gem::Requirement
74
+ requirement: &70164162944020 !ruby/object:Gem::Requirement
75
75
  none: false
76
76
  requirements:
77
77
  - - ! '>='
@@ -79,10 +79,10 @@ dependencies:
79
79
  version: 1.2.4
80
80
  type: :development
81
81
  prerelease: false
82
- version_requirements: *2165453680
82
+ version_requirements: *70164162944020
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: activerecord
85
- requirement: &2165453200 !ruby/object:Gem::Requirement
85
+ requirement: &70164162960820 !ruby/object:Gem::Requirement
86
86
  none: false
87
87
  requirements:
88
88
  - - ! '>='
@@ -90,7 +90,7 @@ dependencies:
90
90
  version: 2.2.2
91
91
  type: :development
92
92
  prerelease: false
93
- version_requirements: *2165453200
93
+ version_requirements: *70164162960820
94
94
  description: ! 'ROXML is a Ruby library designed to make it easier for Ruby developers
95
95
  to work with XML.
96
96
 
@@ -128,6 +128,7 @@ files:
128
128
  - examples/dashed_elements.rb
129
129
  - examples/library.rb
130
130
  - examples/library_with_fines.rb
131
+ - examples/person.rb
131
132
  - examples/posts.rb
132
133
  - examples/rails.rb
133
134
  - examples/twitter.rb
@@ -136,6 +137,7 @@ files:
136
137
  - examples/xml/current_weather.xml
137
138
  - examples/xml/dashed_elements.xml
138
139
  - examples/xml/library_with_fines.xml
140
+ - examples/xml/person.xml
139
141
  - examples/xml/posts.xml
140
142
  - examples/xml/twitter.xml
141
143
  - lib/roxml.rb
@@ -153,6 +155,7 @@ files:
153
155
  - spec/examples/dashed_elements_spec.rb
154
156
  - spec/examples/library_spec.rb
155
157
  - spec/examples/library_with_fines_spec.rb
158
+ - spec/examples/person_spec.rb
156
159
  - spec/examples/post_spec.rb
157
160
  - spec/examples/twitter_spec.rb
158
161
  - spec/reference_spec.rb
@@ -240,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
243
  version: '0'
241
244
  requirements: []
242
245
  rubyforge_project: roxml
243
- rubygems_version: 1.8.8
246
+ rubygems_version: 1.8.10
244
247
  signing_key:
245
248
  specification_version: 3
246
249
  summary: Ruby Object to XML mapping library