roxml 3.1.6 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,15 +10,6 @@ Please submit bugs here:
10
10
 
11
11
  http://github.com/Empact/roxml/issues
12
12
 
13
-
14
- =ROXML is of, by, and for all of us
15
-
16
- I've taken a lead role on ROXML these past months, but unfortunately I, Ben Woosley (Empact), am unable to continue to maintain ROXML at this time, as it no longer aligns with my other interests & efforts. While I would very much like to fix the bugs listed on the github issues page, I'm simply not the person to do it, given my other concerns.
17
-
18
- But don't be mistaken, the library covers most cases very well, and is on the better-tested side of the spectrum (some 353 examples, all green as of this writing).
19
-
20
- If you run into a problem with ROXML, *please* take advantage of those tests, and github, by rolling up your sleeves and making a fix! Your fellow programmers, myself included, will appreciate you for it.
21
-
22
13
  =Quick Start Guide
23
14
 
24
15
  This is a short usage example. See ROXML::ClassMethods::Declarations and packaged test cases for more information.
data/Rakefile CHANGED
@@ -84,21 +84,21 @@ require 'rake/testtask'
84
84
  desc "Test ROXML using the default parser selection behavior"
85
85
  task :test do
86
86
  require 'rake/runtest'
87
- $LOAD_PATH << 'lib'
87
+ $LOAD_PATH << '.'
88
88
  Rake.run_tests 'test/unit/*_test.rb'
89
89
  end
90
90
 
91
91
  namespace :test do
92
92
  desc "Test ROXML under the Nokogiri parser"
93
93
  task :nokogiri do
94
- $LOAD_PATH << 'spec'
94
+ $LOAD_PATH << '.'
95
95
  require 'spec/support/nokogiri'
96
96
  Rake::Task["test"].invoke
97
97
  end
98
98
 
99
99
  desc "Test ROXML under the LibXML parser"
100
100
  task :libxml do
101
- $LOAD_PATH << 'spec'
101
+ $LOAD_PATH << '.'
102
102
  require 'spec/support/libxml'
103
103
  Rake::Task["test"].invoke
104
104
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.6
1
+ 3.2.0
@@ -25,7 +25,7 @@ module PITA
25
25
  end
26
26
  end
27
27
 
28
- unless defined?(Spec)
28
+ unless defined?(RSpec)
29
29
  response = PITA::ItemSearchResponse.from_xml(xml_for('amazon'))
30
30
  p response.total_results
31
31
  p response.total_pages
@@ -18,7 +18,7 @@ class Weather < Base
18
18
  xml_reader :observation, :as => WeatherObservation, :required => true
19
19
  end
20
20
 
21
- unless defined?(Spec)
21
+ unless defined?(RSpec)
22
22
  current_weather = Weather.from_xml(xml_for('current_weather')).observation
23
23
  puts "temperature: #{current_weather.temperature}"
24
24
  puts "feels_like: #{current_weather.feels_like}"
@@ -14,7 +14,7 @@ module GitHub
14
14
  end
15
15
  end
16
16
 
17
- unless defined?(Spec)
17
+ unless defined?(RSpec)
18
18
  commit = GitHub::Commit.from_xml(xml_for('dashed_elements'))
19
19
  puts commit.committed_date, commit.url, commit.id, ''
20
20
  end
@@ -0,0 +1,13 @@
1
+ class LibraryWithFines
2
+
3
+ include ROXML
4
+
5
+ xml_name 'library'
6
+
7
+ xml_accessor :name
8
+
9
+ xml_accessor :fines,
10
+ :as => { :key => 'name', :value => 'desc' },
11
+ :from => 'fine',
12
+ :in => 'policy/fines'
13
+ end
@@ -19,7 +19,7 @@ class Posts
19
19
  xml_reader :posts, :as => [Post]
20
20
  end
21
21
 
22
- unless defined?(Spec)
22
+ unless defined?(RSpec)
23
23
  posts = Posts.from_xml(xml_for('posts'))
24
24
  posts.posts.each do |post|
25
25
  puts post.description, post.href, post.extended, ''
@@ -3,10 +3,9 @@ require_relative './../spec/spec_helper'
3
3
  require 'sqlite3'
4
4
  require 'active_record'
5
5
 
6
- DB_PATH = 'spec/examples/rails.sqlite3'
7
6
  ActiveRecord::Base.establish_connection(
8
7
  :adapter => 'sqlite3',
9
- :database => DB_PATH
8
+ :database => ':memory:'
10
9
  )
11
10
 
12
11
  class Waypoint < ActiveRecord::Base
@@ -0,0 +1,19 @@
1
+ <library>
2
+ <name>Ruby library</name>
3
+ <policy>
4
+ <fines>
5
+ <fine>
6
+ <name>late-book</name>
7
+ <desc>The book was returned late.</desc>
8
+ </fine>
9
+ <fine>
10
+ <name>damaged-book</name>
11
+ <desc>The book was returned damaged.</desc>
12
+ </fine>
13
+ <fine>
14
+ <name>talking</name>
15
+ <desc>The librarian won't go out with you. Stop asking.</desc>
16
+ </fine>
17
+ </fines>
18
+ </policy>
19
+ </library>
@@ -1,12 +1,14 @@
1
1
  require 'uri'
2
2
 
3
3
  require 'active_support'
4
- require 'active_support/inflector/inflections'
5
- require 'active_support/core_ext/object/duplicable'
6
- require 'active_support/core_ext/module/delegation'
7
- require 'active_support/core_ext/array/extract_options'
8
- require 'active_support/core_ext/hash'
9
- require 'active_support/core_ext/string/starts_ends_with'
4
+ if Gem.loaded_specs['activesupport'].version >= Gem::Version.new('3')
5
+ require 'active_support/inflector'
6
+ require 'active_support/core_ext/object/duplicable'
7
+ require 'active_support/core_ext/module/delegation'
8
+ require 'active_support/core_ext/array/extract_options'
9
+ require 'active_support/core_ext/hash'
10
+ require 'active_support/core_ext/string/starts_ends_with'
11
+ end
10
12
 
11
13
  require 'roxml/definition'
12
14
  require 'roxml/xml'
@@ -98,9 +98,12 @@ module ROXML
98
98
  if !opts[:always_create] && (child = xml.children.find {|c| c.name == wrap_with })
99
99
  return child
100
100
  end
101
- XML.add_node(xml, wrap_with.to_s)
101
+
102
+ wraps = wrap_with.to_s.split('/')
103
+ wraps.inject(xml){|node,wrap| XML.add_node(node, wrap)}
102
104
  end
103
105
 
106
+
104
107
  def nodes_in(xml)
105
108
  @default_namespace = xml.default_namespace
106
109
  vals = xml.roxml_search(xpath, @instance.class.roxml_namespaces)
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{roxml}
8
- s.version = "3.1.6"
8
+ s.version = "3.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Ben Woosley", "Zak Mandhro", "Anders Engstrom", "Russ Olsen"]
12
- s.date = %q{2010-11-03}
11
+ s.authors = [%q{Ben Woosley}, %q{Zak Mandhro}, %q{Anders Engstrom}, %q{Russ Olsen}]
12
+ s.date = %q{2011-11-25}
13
13
  s.description = %q{ROXML is a Ruby library designed to make it easier for Ruby developers to work with XML.
14
14
  Using simple annotations, it enables Ruby classes to be mapped to XML. ROXML takes care
15
15
  of the marshalling and unmarshalling of mapped attributes so that developers can focus on
@@ -19,169 +19,121 @@ RESTful applications, Web Services, and XML-RPC.
19
19
  s.email = %q{ben.woosley@gmail.com}
20
20
  s.extra_rdoc_files = [
21
21
  "History.txt",
22
- "README.rdoc"
22
+ "README.rdoc"
23
23
  ]
24
24
  s.files = [
25
- ".gitignore",
26
- ".gitmodules",
27
- ".rspec",
28
- "History.txt",
29
- "LICENSE",
30
- "README.rdoc",
31
- "Rakefile",
32
- "TODO",
33
- "VERSION",
34
- "examples/amazon.rb",
35
- "examples/current_weather.rb",
36
- "examples/dashed_elements.rb",
37
- "examples/library.rb",
38
- "examples/posts.rb",
39
- "examples/rails.rb",
40
- "examples/twitter.rb",
41
- "examples/xml/active_record.xml",
42
- "examples/xml/amazon.xml",
43
- "examples/xml/current_weather.xml",
44
- "examples/xml/dashed_elements.xml",
45
- "examples/xml/posts.xml",
46
- "examples/xml/twitter.xml",
47
- "lib/roxml.rb",
48
- "lib/roxml/definition.rb",
49
- "lib/roxml/hash_definition.rb",
50
- "lib/roxml/xml.rb",
51
- "lib/roxml/xml/parsers/libxml.rb",
52
- "lib/roxml/xml/parsers/nokogiri.rb",
53
- "lib/roxml/xml/references.rb",
54
- "roxml.gemspec",
55
- "spec/definition_spec.rb",
56
- "spec/examples/active_record_spec.rb",
57
- "spec/examples/amazon_spec.rb",
58
- "spec/examples/current_weather_spec.rb",
59
- "spec/examples/dashed_elements_spec.rb",
60
- "spec/examples/library_spec.rb",
61
- "spec/examples/post_spec.rb",
62
- "spec/examples/twitter_spec.rb",
63
- "spec/roxml_spec.rb",
64
- "spec/shared_specs.rb",
65
- "spec/spec_helper.rb",
66
- "spec/support/libxml.rb",
67
- "spec/support/nokogiri.rb",
68
- "spec/xml/array_spec.rb",
69
- "spec/xml/attributes_spec.rb",
70
- "spec/xml/encoding_spec.rb",
71
- "spec/xml/namespace_spec.rb",
72
- "spec/xml/namespaces_spec.rb",
73
- "spec/xml/object_spec.rb",
74
- "spec/xml/parser_spec.rb",
75
- "spec/xml/text_spec.rb",
76
- "test/fixtures/book_malformed.xml",
77
- "test/fixtures/book_pair.xml",
78
- "test/fixtures/book_text_with_attribute.xml",
79
- "test/fixtures/book_valid.xml",
80
- "test/fixtures/book_with_authors.xml",
81
- "test/fixtures/book_with_contributions.xml",
82
- "test/fixtures/book_with_contributors.xml",
83
- "test/fixtures/book_with_contributors_attrs.xml",
84
- "test/fixtures/book_with_default_namespace.xml",
85
- "test/fixtures/book_with_depth.xml",
86
- "test/fixtures/book_with_octal_pages.xml",
87
- "test/fixtures/book_with_publisher.xml",
88
- "test/fixtures/book_with_wrapped_attr.xml",
89
- "test/fixtures/dictionary_of_attr_name_clashes.xml",
90
- "test/fixtures/dictionary_of_attrs.xml",
91
- "test/fixtures/dictionary_of_guarded_names.xml",
92
- "test/fixtures/dictionary_of_mixeds.xml",
93
- "test/fixtures/dictionary_of_name_clashes.xml",
94
- "test/fixtures/dictionary_of_names.xml",
95
- "test/fixtures/dictionary_of_texts.xml",
96
- "test/fixtures/library.xml",
97
- "test/fixtures/library_uppercase.xml",
98
- "test/fixtures/muffins.xml",
99
- "test/fixtures/nameless_ageless_youth.xml",
100
- "test/fixtures/node_with_attr_name_conflicts.xml",
101
- "test/fixtures/node_with_name_conflicts.xml",
102
- "test/fixtures/numerology.xml",
103
- "test/fixtures/person.xml",
104
- "test/fixtures/person_with_guarded_mothers.xml",
105
- "test/fixtures/person_with_mothers.xml",
106
- "test/load_test.rb",
107
- "test/mocks/dictionaries.rb",
108
- "test/mocks/mocks.rb",
109
- "test/support/fixtures.rb",
110
- "test/test_helper.rb",
111
- "test/unit/definition_test.rb",
112
- "test/unit/deprecations_test.rb",
113
- "test/unit/to_xml_test.rb",
114
- "test/unit/xml_attribute_test.rb",
115
- "test/unit/xml_block_test.rb",
116
- "test/unit/xml_bool_test.rb",
117
- "test/unit/xml_convention_test.rb",
118
- "test/unit/xml_hash_test.rb",
119
- "test/unit/xml_initialize_test.rb",
120
- "test/unit/xml_name_test.rb",
121
- "test/unit/xml_namespace_test.rb",
122
- "test/unit/xml_object_test.rb",
123
- "test/unit/xml_required_test.rb",
124
- "test/unit/xml_text_test.rb",
125
- "website/index.html"
25
+ ".gitmodules",
26
+ ".rspec",
27
+ "History.txt",
28
+ "LICENSE",
29
+ "README.rdoc",
30
+ "Rakefile",
31
+ "TODO",
32
+ "VERSION",
33
+ "examples/amazon.rb",
34
+ "examples/current_weather.rb",
35
+ "examples/dashed_elements.rb",
36
+ "examples/library.rb",
37
+ "examples/library_with_fines.rb",
38
+ "examples/posts.rb",
39
+ "examples/rails.rb",
40
+ "examples/twitter.rb",
41
+ "examples/xml/active_record.xml",
42
+ "examples/xml/amazon.xml",
43
+ "examples/xml/current_weather.xml",
44
+ "examples/xml/dashed_elements.xml",
45
+ "examples/xml/library_with_fines.xml",
46
+ "examples/xml/posts.xml",
47
+ "examples/xml/twitter.xml",
48
+ "lib/roxml.rb",
49
+ "lib/roxml/definition.rb",
50
+ "lib/roxml/hash_definition.rb",
51
+ "lib/roxml/xml.rb",
52
+ "lib/roxml/xml/parsers/libxml.rb",
53
+ "lib/roxml/xml/parsers/nokogiri.rb",
54
+ "lib/roxml/xml/references.rb",
55
+ "roxml.gemspec",
56
+ "spec/definition_spec.rb",
57
+ "spec/examples/active_record_spec.rb",
58
+ "spec/examples/amazon_spec.rb",
59
+ "spec/examples/current_weather_spec.rb",
60
+ "spec/examples/dashed_elements_spec.rb",
61
+ "spec/examples/library_spec.rb",
62
+ "spec/examples/library_with_fines_spec.rb",
63
+ "spec/examples/post_spec.rb",
64
+ "spec/examples/twitter_spec.rb",
65
+ "spec/reference_spec.rb",
66
+ "spec/roxml_spec.rb",
67
+ "spec/shared_specs.rb",
68
+ "spec/spec_helper.rb",
69
+ "spec/support/libxml.rb",
70
+ "spec/support/nokogiri.rb",
71
+ "spec/xml/array_spec.rb",
72
+ "spec/xml/attributes_spec.rb",
73
+ "spec/xml/encoding_spec.rb",
74
+ "spec/xml/namespace_spec.rb",
75
+ "spec/xml/namespaces_spec.rb",
76
+ "spec/xml/object_spec.rb",
77
+ "spec/xml/parser_spec.rb",
78
+ "spec/xml/text_spec.rb",
79
+ "test/fixtures/book_malformed.xml",
80
+ "test/fixtures/book_pair.xml",
81
+ "test/fixtures/book_text_with_attribute.xml",
82
+ "test/fixtures/book_valid.xml",
83
+ "test/fixtures/book_with_authors.xml",
84
+ "test/fixtures/book_with_contributions.xml",
85
+ "test/fixtures/book_with_contributors.xml",
86
+ "test/fixtures/book_with_contributors_attrs.xml",
87
+ "test/fixtures/book_with_default_namespace.xml",
88
+ "test/fixtures/book_with_depth.xml",
89
+ "test/fixtures/book_with_octal_pages.xml",
90
+ "test/fixtures/book_with_publisher.xml",
91
+ "test/fixtures/book_with_wrapped_attr.xml",
92
+ "test/fixtures/dictionary_of_attr_name_clashes.xml",
93
+ "test/fixtures/dictionary_of_attrs.xml",
94
+ "test/fixtures/dictionary_of_guarded_names.xml",
95
+ "test/fixtures/dictionary_of_mixeds.xml",
96
+ "test/fixtures/dictionary_of_name_clashes.xml",
97
+ "test/fixtures/dictionary_of_names.xml",
98
+ "test/fixtures/dictionary_of_texts.xml",
99
+ "test/fixtures/library.xml",
100
+ "test/fixtures/library_uppercase.xml",
101
+ "test/fixtures/muffins.xml",
102
+ "test/fixtures/nameless_ageless_youth.xml",
103
+ "test/fixtures/node_with_attr_name_conflicts.xml",
104
+ "test/fixtures/node_with_name_conflicts.xml",
105
+ "test/fixtures/numerology.xml",
106
+ "test/fixtures/person.xml",
107
+ "test/fixtures/person_with_guarded_mothers.xml",
108
+ "test/fixtures/person_with_mothers.xml",
109
+ "test/load_test.rb",
110
+ "test/mocks/dictionaries.rb",
111
+ "test/mocks/mocks.rb",
112
+ "test/support/fixtures.rb",
113
+ "test/test_helper.rb",
114
+ "test/unit/definition_test.rb",
115
+ "test/unit/deprecations_test.rb",
116
+ "test/unit/to_xml_test.rb",
117
+ "test/unit/xml_attribute_test.rb",
118
+ "test/unit/xml_block_test.rb",
119
+ "test/unit/xml_bool_test.rb",
120
+ "test/unit/xml_convention_test.rb",
121
+ "test/unit/xml_hash_test.rb",
122
+ "test/unit/xml_initialize_test.rb",
123
+ "test/unit/xml_name_test.rb",
124
+ "test/unit/xml_namespace_test.rb",
125
+ "test/unit/xml_object_test.rb",
126
+ "test/unit/xml_required_test.rb",
127
+ "test/unit/xml_text_test.rb",
128
+ "website/index.html"
126
129
  ]
127
130
  s.homepage = %q{http://roxml.rubyforge.org}
128
- s.rdoc_options = ["--charset=UTF-8"]
129
- s.require_paths = ["lib"]
131
+ s.require_paths = [%q{lib}]
130
132
  s.rubyforge_project = %q{roxml}
131
- s.rubygems_version = %q{1.3.7}
133
+ s.rubygems_version = %q{1.8.8}
132
134
  s.summary = %q{Ruby Object to XML mapping library}
133
- s.test_files = [
134
- "spec/definition_spec.rb",
135
- "spec/examples/active_record_spec.rb",
136
- "spec/examples/amazon_spec.rb",
137
- "spec/examples/current_weather_spec.rb",
138
- "spec/examples/dashed_elements_spec.rb",
139
- "spec/examples/library_spec.rb",
140
- "spec/examples/post_spec.rb",
141
- "spec/examples/twitter_spec.rb",
142
- "spec/roxml_spec.rb",
143
- "spec/shared_specs.rb",
144
- "spec/spec_helper.rb",
145
- "spec/support/libxml.rb",
146
- "spec/support/nokogiri.rb",
147
- "spec/xml/array_spec.rb",
148
- "spec/xml/attributes_spec.rb",
149
- "spec/xml/encoding_spec.rb",
150
- "spec/xml/namespace_spec.rb",
151
- "spec/xml/namespaces_spec.rb",
152
- "spec/xml/object_spec.rb",
153
- "spec/xml/parser_spec.rb",
154
- "spec/xml/text_spec.rb",
155
- "test/load_test.rb",
156
- "test/mocks/dictionaries.rb",
157
- "test/mocks/mocks.rb",
158
- "test/support/fixtures.rb",
159
- "test/test_helper.rb",
160
- "test/unit/definition_test.rb",
161
- "test/unit/deprecations_test.rb",
162
- "test/unit/to_xml_test.rb",
163
- "test/unit/xml_attribute_test.rb",
164
- "test/unit/xml_block_test.rb",
165
- "test/unit/xml_bool_test.rb",
166
- "test/unit/xml_convention_test.rb",
167
- "test/unit/xml_hash_test.rb",
168
- "test/unit/xml_initialize_test.rb",
169
- "test/unit/xml_name_test.rb",
170
- "test/unit/xml_namespace_test.rb",
171
- "test/unit/xml_object_test.rb",
172
- "test/unit/xml_required_test.rb",
173
- "test/unit/xml_text_test.rb",
174
- "examples/amazon.rb",
175
- "examples/current_weather.rb",
176
- "examples/dashed_elements.rb",
177
- "examples/library.rb",
178
- "examples/posts.rb",
179
- "examples/rails.rb",
180
- "examples/twitter.rb"
181
- ]
182
135
 
183
136
  if s.respond_to? :specification_version then
184
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
185
137
  s.specification_version = 3
186
138
 
187
139
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -1,16 +1,12 @@
1
1
  require 'fileutils'
2
- require_relative './../spec_helper'
3
- require_relative './../../examples/rails'
2
+ require 'spec_helper'
3
+ require_relative '../../examples/rails'
4
4
 
5
5
  describe ROXML, "under ActiveRecord" do
6
6
  before do
7
7
  @route = Route.from_xml(xml_for('active_record'))
8
8
  end
9
9
 
10
- before(:all) do
11
- FileUtils.rm(DB_PATH) if File.exists?(DB_PATH)
12
- end
13
-
14
10
  it "should be parsed" do
15
11
  @route.should_not == nil
16
12
  @route.should be_an_instance_of(Route)
@@ -1,4 +1,4 @@
1
- require_relative './../spec_helper'
1
+ require 'spec_helper'
2
2
  require_relative './../../examples/amazon'
3
3
 
4
4
  describe PITA::ItemSearchResponse do
@@ -1,4 +1,4 @@
1
- require_relative './../spec_helper'
1
+ require 'spec_helper'
2
2
  require_relative './../../examples/current_weather'
3
3
 
4
4
  describe Weather do
@@ -1,4 +1,4 @@
1
- require_relative './../spec_helper'
1
+ require 'spec_helper'
2
2
  require_relative './../../examples/dashed_elements'
3
3
 
4
4
  describe GitHub::Commit do
@@ -1,4 +1,4 @@
1
- require_relative './../spec_helper'
1
+ require 'spec_helper'
2
2
  require_relative './../../examples/library'
3
3
 
4
4
  describe Library do
@@ -0,0 +1,38 @@
1
+ require_relative './../spec_helper'
2
+ require_relative './../../examples/library_with_fines'
3
+
4
+ describe LibraryWithFines do
5
+
6
+ let(:xml) { File.read(xml_for('library_with_fines')) }
7
+ let(:library) { LibraryWithFines.from_xml(xml) }
8
+
9
+ it "should read nested elements" do
10
+ library.fines.should be_a(Hash)
11
+ library.fines.size == 3
12
+ library.fines.should have_key('talking')
13
+ library.fines['talking'].should match(/Stop asking/)
14
+ end
15
+
16
+ class String
17
+ def remove_whitespace
18
+ self.gsub(/\s{2,}/, '').gsub("\n", '')
19
+ end
20
+ end
21
+
22
+ it "should write deeply nested elements" do
23
+ xml_out = library.to_xml.to_s
24
+ xml_out.remove_whitespace.should == xml.remove_whitespace
25
+ end
26
+
27
+ it "should write two children of library: name and policy" do
28
+ library.to_xml.children.map{|e| e.name }.should == ['name', 'policy']
29
+ end
30
+
31
+ it "should be re-parsable via .from_xml" do
32
+ lib_reparsed = LibraryWithFines.from_xml(library.to_xml.to_s)
33
+ lib_reparsed.name.should == library.name
34
+ lib_reparsed.fines.should == library.fines
35
+ end
36
+
37
+
38
+ end
@@ -1,4 +1,4 @@
1
- require_relative './../spec_helper'
1
+ require 'spec_helper'
2
2
  require_relative './../../examples/posts'
3
3
 
4
4
  describe Post do
@@ -1,4 +1,4 @@
1
- require_relative './../spec_helper'
1
+ require 'spec_helper'
2
2
  require_relative './../../examples/twitter'
3
3
 
4
4
  describe Statuses do
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+ require_relative './spec_helper'
3
+
4
+ describe ROXML::XMLRef do
5
+
6
+ class Org
7
+ include ROXML
8
+ xml_accessor :fines,
9
+ :in => 'policy/fines',
10
+ :from => 'fine',
11
+ :as => { :key => 'name', :value => 'desc' }
12
+ end
13
+
14
+ let(:org) do
15
+ org = Org.new
16
+ org.fines = { 'name' => 'a fine', 'desc' => 'a desc' }
17
+ org
18
+ end
19
+
20
+ let(:reference) do
21
+ Org.roxml_attrs.first.to_ref(org)
22
+ end
23
+
24
+ it "should properly reconstruct wrappers with multiple elements" do
25
+
26
+ reference.should be_a(ROXML::XMLHashRef)
27
+
28
+ xml = ROXML::XML.new_node('org').tap do |root|
29
+ reference.update_xml(root, org.fines)
30
+ end
31
+
32
+ xml_path( xml ).should == %w{org policy fines fine name}
33
+ end
34
+ end
@@ -1,15 +1,15 @@
1
- require_relative './spec_helper'
2
-
3
- shared_examples_for "freezable xml reference" do
4
- describe "with :frozen option" do
5
- it "should be frozen" do
6
- @frozen.frozen?.should be_true
1
+ if defined?(shared_examples_for)
2
+ shared_examples_for "freezable xml reference" do
3
+ describe "with :frozen option" do
4
+ it "should be frozen" do
5
+ @frozen.frozen?.should be_true
6
+ end
7
7
  end
8
- end
9
8
 
10
- describe "without :frozen option" do
11
- it "should not be frozen" do
12
- @unfrozen.frozen?.should be_false
9
+ describe "without :frozen option" do
10
+ it "should not be frozen" do
11
+ @unfrozen.frozen?.should be_false
12
+ end
13
13
  end
14
14
  end
15
- end
15
+ end
@@ -1,5 +1,8 @@
1
+ require 'ostruct'
1
2
  require 'rubygems'
2
3
  require 'pathname'
4
+ require 'ostruct'
5
+
3
6
  require_relative './../test/support/fixtures'
4
7
  require_relative './../lib/roxml'
5
8
  require_relative './shared_specs'
@@ -11,3 +14,12 @@ end
11
14
  class RoxmlObject
12
15
  include ROXML
13
16
  end
17
+
18
+ # returns an array representing the path through first child of each element in the doc
19
+ def xml_path(xml, path = [])
20
+ path << xml.name if xml.is_a?(Nokogiri::XML::Element)
21
+ unless xml.children.empty?
22
+ xml_path(xml.children.first, path)
23
+ end
24
+ return path
25
+ end
@@ -1,4 +1,4 @@
1
- require_relative './../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  module ArraySpec
4
4
  class Book
@@ -1,4 +1,4 @@
1
- require_relative './../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe ROXML::XMLAttributeRef do
4
4
  before do
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- require_relative './../spec_helper'
2
+ require 'spec_helper'
3
3
 
4
4
  describe ROXML, "encoding" do
5
5
  class TestResult
@@ -1,4 +1,4 @@
1
- require_relative './../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe ROXML::XMLObjectRef do
4
4
  class SubObject
@@ -1,4 +1,4 @@
1
- require_relative './../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe ROXML::XMLTextRef do
4
4
  before do
metadata CHANGED
@@ -1,14 +1,10 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: roxml
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 3
7
- - 1
8
- - 6
9
- version: 3.1.6
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.2.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Ben Woosley
13
9
  - Zak Mandhro
14
10
  - Anders Engstrom
@@ -16,102 +12,85 @@ authors:
16
12
  autorequire:
17
13
  bindir: bin
18
14
  cert_chain: []
19
-
20
- date: 2010-11-03 00:00:00 -07:00
21
- default_executable:
22
- dependencies:
23
- - !ruby/object:Gem::Dependency
15
+ date: 2011-11-25 00:00:00.000000000Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
24
18
  name: activesupport
25
- prerelease: false
26
- requirement: &id001 !ruby/object:Gem::Requirement
19
+ requirement: &2153023980 !ruby/object:Gem::Requirement
27
20
  none: false
28
- requirements:
29
- - - ">="
30
- - !ruby/object:Gem::Version
31
- segments:
32
- - 2
33
- - 3
34
- - 0
21
+ requirements:
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
35
24
  version: 2.3.0
36
25
  type: :runtime
37
- version_requirements: *id001
38
- - !ruby/object:Gem::Dependency
39
- name: nokogiri
40
26
  prerelease: false
41
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ version_requirements: *2153023980
28
+ - !ruby/object:Gem::Dependency
29
+ name: nokogiri
30
+ requirement: &2153023460 !ruby/object:Gem::Requirement
42
31
  none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- segments:
47
- - 1
48
- - 3
49
- - 3
32
+ requirements:
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
50
35
  version: 1.3.3
51
36
  type: :runtime
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: rspec
55
37
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
38
+ version_requirements: *2153023460
39
+ - !ruby/object:Gem::Dependency
40
+ name: rspec
41
+ requirement: &2153022940 !ruby/object:Gem::Requirement
57
42
  none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- segments:
62
- - 2
63
- - 0
64
- - 0
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
65
46
  version: 2.0.0
66
47
  type: :development
67
- version_requirements: *id003
68
- - !ruby/object:Gem::Dependency
69
- name: sqlite3-ruby
70
48
  prerelease: false
71
- requirement: &id004 !ruby/object:Gem::Requirement
49
+ version_requirements: *2153022940
50
+ - !ruby/object:Gem::Dependency
51
+ name: sqlite3-ruby
52
+ requirement: &2153022340 !ruby/object:Gem::Requirement
72
53
  none: false
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- segments:
77
- - 1
78
- - 2
79
- - 4
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
80
57
  version: 1.2.4
81
58
  type: :development
82
- version_requirements: *id004
83
- - !ruby/object:Gem::Dependency
84
- name: activerecord
85
59
  prerelease: false
86
- requirement: &id005 !ruby/object:Gem::Requirement
60
+ version_requirements: *2153022340
61
+ - !ruby/object:Gem::Dependency
62
+ name: activerecord
63
+ requirement: &2153013780 !ruby/object:Gem::Requirement
87
64
  none: false
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- segments:
92
- - 2
93
- - 2
94
- - 2
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
95
68
  version: 2.2.2
96
69
  type: :development
97
- version_requirements: *id005
98
- description: |
99
- ROXML is a Ruby library designed to make it easier for Ruby developers to work with XML.
100
- Using simple annotations, it enables Ruby classes to be mapped to XML. ROXML takes care
101
- of the marshalling and unmarshalling of mapped attributes so that developers can focus on
102
- building first-class Ruby classes. As a result, ROXML simplifies the development of
70
+ prerelease: false
71
+ version_requirements: *2153013780
72
+ description: ! 'ROXML is a Ruby library designed to make it easier for Ruby developers
73
+ to work with XML.
74
+
75
+ Using simple annotations, it enables Ruby classes to be mapped to XML. ROXML takes
76
+ care
77
+
78
+ of the marshalling and unmarshalling of mapped attributes so that developers can
79
+ focus on
80
+
81
+ building first-class Ruby classes. As a result, ROXML simplifies the development
82
+ of
83
+
103
84
  RESTful applications, Web Services, and XML-RPC.
104
85
 
86
+ '
105
87
  email: ben.woosley@gmail.com
106
88
  executables: []
107
-
108
89
  extensions: []
109
-
110
- extra_rdoc_files:
90
+ extra_rdoc_files:
111
91
  - History.txt
112
92
  - README.rdoc
113
- files:
114
- - .gitignore
93
+ files:
115
94
  - .gitmodules
116
95
  - .rspec
117
96
  - History.txt
@@ -124,6 +103,7 @@ files:
124
103
  - examples/current_weather.rb
125
104
  - examples/dashed_elements.rb
126
105
  - examples/library.rb
106
+ - examples/library_with_fines.rb
127
107
  - examples/posts.rb
128
108
  - examples/rails.rb
129
109
  - examples/twitter.rb
@@ -131,6 +111,7 @@ files:
131
111
  - examples/xml/amazon.xml
132
112
  - examples/xml/current_weather.xml
133
113
  - examples/xml/dashed_elements.xml
114
+ - examples/xml/library_with_fines.xml
134
115
  - examples/xml/posts.xml
135
116
  - examples/xml/twitter.xml
136
117
  - lib/roxml.rb
@@ -147,8 +128,10 @@ files:
147
128
  - spec/examples/current_weather_spec.rb
148
129
  - spec/examples/dashed_elements_spec.rb
149
130
  - spec/examples/library_spec.rb
131
+ - spec/examples/library_with_fines_spec.rb
150
132
  - spec/examples/post_spec.rb
151
133
  - spec/examples/twitter_spec.rb
134
+ - spec/reference_spec.rb
152
135
  - spec/roxml_spec.rb
153
136
  - spec/shared_specs.rb
154
137
  - spec/spec_helper.rb
@@ -212,83 +195,28 @@ files:
212
195
  - test/unit/xml_required_test.rb
213
196
  - test/unit/xml_text_test.rb
214
197
  - website/index.html
215
- has_rdoc: true
216
198
  homepage: http://roxml.rubyforge.org
217
199
  licenses: []
218
-
219
200
  post_install_message:
220
- rdoc_options:
221
- - --charset=UTF-8
222
- require_paths:
201
+ rdoc_options: []
202
+ require_paths:
223
203
  - lib
224
- required_ruby_version: !ruby/object:Gem::Requirement
204
+ required_ruby_version: !ruby/object:Gem::Requirement
225
205
  none: false
226
- requirements:
227
- - - ">="
228
- - !ruby/object:Gem::Version
229
- segments:
230
- - 0
231
- version: "0"
232
- required_rubygems_version: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ! '>='
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ required_rubygems_version: !ruby/object:Gem::Requirement
233
211
  none: false
234
- requirements:
235
- - - ">="
236
- - !ruby/object:Gem::Version
237
- segments:
238
- - 0
239
- version: "0"
212
+ requirements:
213
+ - - ! '>='
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
240
216
  requirements: []
241
-
242
217
  rubyforge_project: roxml
243
- rubygems_version: 1.3.7
218
+ rubygems_version: 1.8.8
244
219
  signing_key:
245
220
  specification_version: 3
246
221
  summary: Ruby Object to XML mapping library
247
- test_files:
248
- - spec/definition_spec.rb
249
- - spec/examples/active_record_spec.rb
250
- - spec/examples/amazon_spec.rb
251
- - spec/examples/current_weather_spec.rb
252
- - spec/examples/dashed_elements_spec.rb
253
- - spec/examples/library_spec.rb
254
- - spec/examples/post_spec.rb
255
- - spec/examples/twitter_spec.rb
256
- - spec/roxml_spec.rb
257
- - spec/shared_specs.rb
258
- - spec/spec_helper.rb
259
- - spec/support/libxml.rb
260
- - spec/support/nokogiri.rb
261
- - spec/xml/array_spec.rb
262
- - spec/xml/attributes_spec.rb
263
- - spec/xml/encoding_spec.rb
264
- - spec/xml/namespace_spec.rb
265
- - spec/xml/namespaces_spec.rb
266
- - spec/xml/object_spec.rb
267
- - spec/xml/parser_spec.rb
268
- - spec/xml/text_spec.rb
269
- - test/load_test.rb
270
- - test/mocks/dictionaries.rb
271
- - test/mocks/mocks.rb
272
- - test/support/fixtures.rb
273
- - test/test_helper.rb
274
- - test/unit/definition_test.rb
275
- - test/unit/deprecations_test.rb
276
- - test/unit/to_xml_test.rb
277
- - test/unit/xml_attribute_test.rb
278
- - test/unit/xml_block_test.rb
279
- - test/unit/xml_bool_test.rb
280
- - test/unit/xml_convention_test.rb
281
- - test/unit/xml_hash_test.rb
282
- - test/unit/xml_initialize_test.rb
283
- - test/unit/xml_name_test.rb
284
- - test/unit/xml_namespace_test.rb
285
- - test/unit/xml_object_test.rb
286
- - test/unit/xml_required_test.rb
287
- - test/unit/xml_text_test.rb
288
- - examples/amazon.rb
289
- - examples/current_weather.rb
290
- - examples/dashed_elements.rb
291
- - examples/library.rb
292
- - examples/posts.rb
293
- - examples/rails.rb
294
- - examples/twitter.rb
222
+ test_files: []
data/.gitignore DELETED
@@ -1,7 +0,0 @@
1
- spec/**/*.xml
2
- rdoc
3
- build
4
- doc
5
- Rake.config
6
- pkg
7
- .project