om 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -8,5 +8,5 @@ group :development, :test do
8
8
  gem "rspec", "<2.0.0"
9
9
  gem "mocha", ">= 0.9.8"
10
10
  gem "ruby-debug"
11
- gem "equivalent-xml", ">= 0.1.6"
11
+ gem "equivalent-xml", ">= 0.2.4"
12
12
  end
data/Gemfile.lock CHANGED
@@ -2,8 +2,8 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  columnize (0.3.2)
5
- equivalent-xml (0.1.6)
6
- nokogiri
5
+ equivalent-xml (0.2.4)
6
+ nokogiri (>= 1.4.3)
7
7
  facets (2.9.1)
8
8
  git (1.2.5)
9
9
  jeweler (1.5.2)
@@ -25,7 +25,7 @@ PLATFORMS
25
25
  ruby
26
26
 
27
27
  DEPENDENCIES
28
- equivalent-xml (>= 0.1.6)
28
+ equivalent-xml (>= 0.2.4)
29
29
  facets
30
30
  jeweler
31
31
  mocha (>= 0.9.8)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.2.1
@@ -73,6 +73,10 @@ module OM::XML::Document
73
73
  self.class.template_registry
74
74
  end
75
75
 
76
+ def template(node_type, *args)
77
+ template_registry.instantiate(node_type, *args)
78
+ end
79
+
76
80
  # Instantiate a +node_type+ template and add it as a child of +target_node+, where +target_node+ is one of:
77
81
  # * a Nokogiri::XML::Node
78
82
  # * a single-element Nokogiri::XML::NodeSet
@@ -80,44 +84,44 @@ module OM::XML::Document
80
84
  # Additional arguments will be passed to the template unaltered.
81
85
  #
82
86
  # Returns the new Nokogiri::XML::Node.
83
- def add_child_node(target_node, node_type, *args)
84
- manipulate_node(:add_child, target_node, node_type, *args)
87
+ def add_child_node(target_node, node_type, *args, &block)
88
+ manipulate_node(:add_child, target_node, node_type, *args, &block)
85
89
  end
86
90
 
87
91
  # Instantiate a +node_type+ template and insert it as the following sibling of +target_node+.
88
92
  # Returns the new Nokogiri::XML::Node.
89
- def add_next_sibling_node(target_node, node_type, *args)
90
- manipulate_node(:add_next_sibling, target_node, node_type, *args)
93
+ def add_next_sibling_node(target_node, node_type, *args, &block)
94
+ manipulate_node(:add_next_sibling, target_node, node_type, *args, &block)
91
95
  end
92
96
 
93
97
  # Instantiate a +node_type+ template and insert it as the preceding sibling of +target_node+.
94
98
  # Returns the new Nokogiri::XML::Node.
95
- def add_previous_sibling_node(target_node, node_type, *args)
96
- manipulate_node(:add_previous_sibling, target_node, node_type, *args)
99
+ def add_previous_sibling_node(target_node, node_type, *args, &block)
100
+ manipulate_node(:add_previous_sibling, target_node, node_type, *args, &block)
97
101
  end
98
102
 
99
103
  # Instantiate a +node_type+ template and insert it as the following sibling of +target_node+.
100
104
  # Returns +target_node+.
101
- def after_node(target_node, node_type, *args)
102
- manipulate_node(:after, target_node, node_type, *args)
105
+ def after_node(target_node, node_type, *args, &block)
106
+ manipulate_node(:after, target_node, node_type, *args, &block)
103
107
  end
104
108
 
105
109
  # Instantiate a +node_type+ template and insert it as the preceding sibling of +target_node+.
106
110
  # Returns +target_node+.
107
- def before_node(target_node, node_type, *args)
108
- manipulate_node(:before, target_node, node_type, *args)
111
+ def before_node(target_node, node_type, *args, &block)
112
+ manipulate_node(:before, target_node, node_type, *args, &block)
109
113
  end
110
114
 
111
115
  # Instantiate a +node_type+ template and replace +target_node+ with it.
112
116
  # Returns the new Nokogiri::XML::Node.
113
- def replace_node(target_node, node_type, *args)
114
- manipulate_node(:replace, target_node, node_type, *args)
117
+ def replace_node(target_node, node_type, *args, &block)
118
+ manipulate_node(:replace, target_node, node_type, *args, &block)
115
119
  end
116
120
 
117
121
  # Instantiate a +node_type+ template and replace +target_node+ with it.
118
122
  # Returns +target_node+.
119
- def swap_node(target_node, node_type, *args)
120
- manipulate_node(:swap, target_node, node_type, *args)
123
+ def swap_node(target_node, node_type, *args, &block)
124
+ manipulate_node(:swap, target_node, node_type, *args, &block)
121
125
  end
122
126
 
123
127
  # Returns a hash combining the current documents namespaces (provided by nokogiri) and any namespaces that have been set up by your Terminology.
@@ -127,10 +131,10 @@ module OM::XML::Document
127
131
  end
128
132
 
129
133
  private
130
- def manipulate_node(method, target, *args)
134
+ def manipulate_node(method, target, *args, &block)
131
135
  if target.is_a?(Array)
132
136
  target = self.find_by_terms(*target)
133
137
  end
134
- template_registry.send(method, target, *args)
138
+ template_registry.send(method, target, *args, &block)
135
139
  end
136
140
  end
@@ -1,3 +1,35 @@
1
+ # Extend an OM::XML::Document with reusable templates, then use them to add content to
2
+ # instance documents.
3
+ #
4
+ # Example:
5
+ #
6
+ # require 'om/samples/mods_article'
7
+ #
8
+ # class OM::Samples::ModsArticle
9
+ # define_template :personalName do |xml, family, given, address|
10
+ # xml.name(:type => 'personal') do
11
+ # xml.namePart(:type => 'family') { xml.text(family) }
12
+ # xml.namePart(:type => 'given') { xml.text(given) }
13
+ # xml.namePart(:type => 'termsOfAddress') { xml.text(address) }
14
+ # end
15
+ # end
16
+ #
17
+ # define_template :role do |xml, text, attrs|
18
+ # xml.role do
19
+ # attrs = { :type => 'text' }.merge(attrs)
20
+ # xml.roleTerm(attrs) { xml.text(text) }
21
+ # end
22
+ # end
23
+ # end
24
+ #
25
+ # mods = OM::Samples::ModsArticle.from_xml(File.read('./spec/fixtures/CBF_MODS/ARS0025_016.xml'))
26
+ #
27
+ # mods.add_previous_sibling_node([:person => 0], :personalName, 'Shmoe', 'Joseph', 'Dr.') { |person|
28
+ # person.add_child(mods.template(:role, 'author', :authority => 'marcrelator'))
29
+ # person.add_child(mods.template(:role, 'sub', :authority => 'local', :type => 'code'))
30
+ # person
31
+ # }
32
+
1
33
  class OM::XML::TemplateRegistry
2
34
 
3
35
  def initialize
@@ -54,44 +86,44 @@ class OM::XML::TemplateRegistry
54
86
 
55
87
  # +instantiate+ a node and add it as a child of the [Nokogiri::XML::Node] specified by +target_node+
56
88
  # @return the new [Nokogiri::XML::Node]
57
- def add_child(target_node, node_type, *args)
58
- attach_node(:add_child, target_node, :self, node_type, *args)
89
+ def add_child(target_node, node_type, *args, &block)
90
+ attach_node(:add_child, target_node, :self, node_type, *args, &block)
59
91
  end
60
92
 
61
93
  # +instantiate+ a node and add it as a following sibling of the [Nokogiri::XML::Node] specified by +target_node+
62
94
  # @return the new [Nokogiri::XML::Node]
63
- def add_next_sibling(target_node, node_type, *args)
64
- attach_node(:add_next_sibling, target_node, :parent, node_type, *args)
95
+ def add_next_sibling(target_node, node_type, *args, &block)
96
+ attach_node(:add_next_sibling, target_node, :parent, node_type, *args, &block)
65
97
  end
66
98
 
67
99
  # +instantiate+ a node and add it as a preceding sibling of the [Nokogiri::XML::Node] specified by +target_node+
68
100
  # @return the new [Nokogiri::XML::Node]
69
- def add_previous_sibling(target_node, node_type, *args)
70
- attach_node(:add_previous_sibling, target_node, :parent, node_type, *args)
101
+ def add_previous_sibling(target_node, node_type, *args, &block)
102
+ attach_node(:add_previous_sibling, target_node, :parent, node_type, *args, &block)
71
103
  end
72
104
 
73
105
  # +instantiate+ a node and add it as a following sibling of the [Nokogiri::XML::Node] specified by +target_node+
74
106
  # @return +target_node+
75
- def after(target_node, node_type, *args)
76
- attach_node(:after, target_node, :parent, node_type, *args)
107
+ def after(target_node, node_type, *args, &block)
108
+ attach_node(:after, target_node, :parent, node_type, *args, &block)
77
109
  end
78
110
 
79
111
  # +instantiate+ a node and add it as a preceding sibling of the [Nokogiri::XML::Node] specified by +target_node+
80
112
  # @return +target_node+
81
- def before(target_node, node_type, *args)
82
- attach_node(:before, target_node, :parent, node_type, *args)
113
+ def before(target_node, node_type, *args, &block)
114
+ attach_node(:before, target_node, :parent, node_type, *args, &block)
83
115
  end
84
116
 
85
117
  # +instantiate+ a node replace the [Nokogiri::XML::Node] specified by +target_node+ with it
86
118
  # @return the new [Nokogiri::XML::Node]
87
- def replace(target_node, node_type, *args)
88
- attach_node(:replace, target_node, :parent, node_type, *args)
119
+ def replace(target_node, node_type, *args, &block)
120
+ attach_node(:replace, target_node, :parent, node_type, *args, &block)
89
121
  end
90
122
 
91
123
  # +instantiate+ a node replace the [Nokogiri::XML::Node] specified by +target_node+ with it
92
124
  # @return +target_node+
93
- def swap(target_node, node_type, *args)
94
- attach_node(:swap, target_node, :parent, node_type, *args)
125
+ def swap(target_node, node_type, *args, &block)
126
+ attach_node(:swap, target_node, :parent, node_type, *args, &block)
95
127
  end
96
128
 
97
129
  def methods
@@ -123,7 +155,7 @@ class OM::XML::TemplateRegistry
123
155
  builder_node.elements.last.remove
124
156
  end
125
157
 
126
- def attach_node(method, target_node, builder_node_offset, node_type, *args)
158
+ def attach_node(method, target_node, builder_node_offset, node_type, *args, &block)
127
159
  if target_node.is_a?(Nokogiri::XML::NodeSet) and target_node.length == 1
128
160
  target_node = target_node.first
129
161
  end
@@ -136,7 +168,11 @@ class OM::XML::TemplateRegistry
136
168
  node.namespace = nil
137
169
  end
138
170
  }
139
- return result
171
+ if block_given?
172
+ yield result
173
+ else
174
+ return result
175
+ end
140
176
  end
141
177
 
142
178
  def empty_root_node
data/om.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{om}
8
- s.version = "1.2.0"
8
+ s.version = "1.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Zumwalt"]
12
- s.date = %q{2011-03-22}
12
+ s.date = %q{2011-03-23}
13
13
  s.description = %q{OM (Opinionated Metadata): A library to help you tame sprawling XML schemas like MODS. Wraps Nokogiri documents in objects with miscellaneous helper methods for doing things like retrieve generated xpath queries or look up properties based on a simplified DSL}
14
14
  s.email = %q{matt.zumwalt@yourmediashelf.com}
15
15
  s.extra_rdoc_files = [
@@ -70,7 +70,7 @@ Gem::Specification.new do |s|
70
70
  ]
71
71
  s.homepage = %q{http://github.com/mediashelf/om}
72
72
  s.require_paths = ["lib"]
73
- s.rubygems_version = %q{1.3.7}
73
+ s.rubygems_version = %q{1.6.2}
74
74
  s.summary = %q{OM (Opinionated Metadata): A library to help you tame sprawling XML schemas like MODS.}
75
75
  s.test_files = [
76
76
  "spec/integration/rights_metadata_integration_example_spec.rb",
@@ -92,7 +92,6 @@ Gem::Specification.new do |s|
92
92
  ]
93
93
 
94
94
  if s.respond_to? :specification_version then
95
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
96
95
  s.specification_version = 3
97
96
 
98
97
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -102,7 +101,7 @@ Gem::Specification.new do |s|
102
101
  s.add_development_dependency(%q<rspec>, ["< 2.0.0"])
103
102
  s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
104
103
  s.add_development_dependency(%q<ruby-debug>, [">= 0"])
105
- s.add_development_dependency(%q<equivalent-xml>, [">= 0.1.6"])
104
+ s.add_development_dependency(%q<equivalent-xml>, [">= 0.2.4"])
106
105
  s.add_runtime_dependency(%q<nokogiri>, [">= 1.4.2"])
107
106
  s.add_runtime_dependency(%q<facets>, [">= 0"])
108
107
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
@@ -115,7 +114,7 @@ Gem::Specification.new do |s|
115
114
  s.add_dependency(%q<rspec>, ["< 2.0.0"])
116
115
  s.add_dependency(%q<mocha>, [">= 0.9.8"])
117
116
  s.add_dependency(%q<ruby-debug>, [">= 0"])
118
- s.add_dependency(%q<equivalent-xml>, [">= 0.1.6"])
117
+ s.add_dependency(%q<equivalent-xml>, [">= 0.2.4"])
119
118
  s.add_dependency(%q<nokogiri>, [">= 1.4.2"])
120
119
  s.add_dependency(%q<facets>, [">= 0"])
121
120
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
@@ -129,7 +128,7 @@ Gem::Specification.new do |s|
129
128
  s.add_dependency(%q<rspec>, ["< 2.0.0"])
130
129
  s.add_dependency(%q<mocha>, [">= 0.9.8"])
131
130
  s.add_dependency(%q<ruby-debug>, [">= 0"])
132
- s.add_dependency(%q<equivalent-xml>, [">= 0.1.6"])
131
+ s.add_dependency(%q<equivalent-xml>, [">= 0.2.4"])
133
132
  s.add_dependency(%q<nokogiri>, [">= 1.4.2"])
134
133
  s.add_dependency(%q<facets>, [">= 0"])
135
134
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
data/spec/spec_helper.rb CHANGED
@@ -3,6 +3,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
  require 'om'
4
4
  require 'spec'
5
5
  require 'spec/autorun'
6
+ require 'equivalent-xml/rspec_matchers'
6
7
  require 'ruby-debug'
7
8
 
8
9
  Spec::Runner.configure do |config|
@@ -1,6 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
  require "om"
3
- require 'equivalent-xml'
4
3
 
5
4
  describe "OM::XML::TemplateRegistry" do
6
5
 
@@ -57,19 +56,13 @@ describe "OM::XML::TemplateRegistry" do
57
56
  it "should instantiate a detached node from a template" do
58
57
  node = RegistryTest.template_registry.instantiate(:zombie, 'Zeke')
59
58
  expectation = Nokogiri::XML('<monster wants="braaaaainz">Zeke</monster>').root
60
- EquivalentXml.equivalent?(node, expectation).should == true
59
+ node.should be_equivalent_to(expectation)
61
60
  end
62
61
 
63
62
  it "should raise an error when trying to instantiate an unknown node_type" do
64
63
  lambda { RegistryTest.template_registry.instantiate(:demigod, 'Hercules') }.should raise_error(NameError)
65
64
  end
66
65
 
67
- it "should instantiate a detached node from a template using the template name as a method" do
68
- node = RegistryTest.template_registry.zombie('Zeke')
69
- expectation = Nokogiri::XML('<monster wants="braaaaainz">Zeke</monster>').root
70
- EquivalentXml.equivalent?(node, expectation).should == true
71
- end
72
-
73
66
  it "should raise an exception if a missing method name doesn't match a node_type" do
74
67
  lambda { RegistryTest.template_registry.demigod('Hercules') }.should raise_error(NameError)
75
68
  end
@@ -105,48 +98,63 @@ describe "OM::XML::TemplateRegistry" do
105
98
  @test_document.ng_xml.root.elements.length.should == 2
106
99
  end
107
100
 
101
+ it "should instantiate a detached node from a template using the template name as a method" do
102
+ node = RegistryTest.template_registry.person('Odin', 'All-Father')
103
+ expectation = Nokogiri::XML('<person title="All-Father">Odin</person>').root
104
+ node.should be_equivalent_to(expectation)
105
+ end
106
+
108
107
  it "should add_child" do
109
108
  return_value = @test_document.template_registry.add_child(@test_document.ng_xml.root, :person, 'Bob', 'Builder')
110
109
  return_value.should == @test_document.find_by_terms(:person => 1).first
111
- EquivalentXml.equivalent?(@test_document.ng_xml, @expectations[:after], :element_order => true).should == true
110
+ @test_document.ng_xml.should be_equivalent_to(@expectations[:after]).respecting_element_order
112
111
  end
113
112
 
114
113
  it "should add_next_sibling" do
115
114
  return_value = @test_document.template_registry.add_next_sibling(@test_document.find_by_terms(:person => 0), :person, 'Bob', 'Builder')
116
115
  return_value.should == @test_document.find_by_terms(:person => 1).first
117
- EquivalentXml.equivalent?(@test_document.ng_xml, @expectations[:after], :element_order => true).should == true
116
+ @test_document.ng_xml.should be_equivalent_to(@expectations[:after]).respecting_element_order
118
117
  end
119
118
 
120
119
  it "should add_previous_sibling" do
121
120
  return_value = @test_document.template_registry.add_previous_sibling(@test_document.find_by_terms(:person => 0), :person, 'Bob', 'Builder')
122
121
  return_value.should == @test_document.find_by_terms(:person => 0).first
123
- EquivalentXml.equivalent?(@test_document.ng_xml, @expectations[:before], :element_order => true).should == true
122
+ @test_document.ng_xml.should be_equivalent_to(@expectations[:before]).respecting_element_order
124
123
  end
125
124
 
126
125
  it "should after" do
127
126
  return_value = @test_document.template_registry.after(@test_document.find_by_terms(:person => 0), :person, 'Bob', 'Builder')
128
127
  return_value.should == @test_document.find_by_terms(:person => 0).first
129
- EquivalentXml.equivalent?(@test_document.ng_xml, @expectations[:after], :element_order => true).should == true
128
+ @test_document.ng_xml.should be_equivalent_to(@expectations[:after]).respecting_element_order
130
129
  end
131
130
 
132
131
  it "should before" do
133
132
  return_value = @test_document.template_registry.before(@test_document.find_by_terms(:person => 0), :person, 'Bob', 'Builder')
134
133
  return_value.should == @test_document.find_by_terms(:person => 1).first
135
- EquivalentXml.equivalent?(@test_document.ng_xml, @expectations[:before], :element_order => true).should == true
134
+ @test_document.ng_xml.should be_equivalent_to(@expectations[:before]).respecting_element_order
136
135
  end
137
136
 
138
137
  it "should replace" do
139
138
  target_node = @test_document.find_by_terms(:person => 0).first
140
139
  return_value = @test_document.template_registry.replace(target_node, :person, 'Bob', 'Builder')
141
140
  return_value.should == @test_document.find_by_terms(:person => 0).first
142
- EquivalentXml.equivalent?(@test_document.ng_xml, @expectations[:instead], :element_order => true).should == true
141
+ @test_document.ng_xml.should be_equivalent_to(@expectations[:instead]).respecting_element_order
143
142
  end
144
143
 
145
144
  it "should swap" do
146
145
  target_node = @test_document.find_by_terms(:person => 0).first
147
146
  return_value = @test_document.template_registry.swap(target_node, :person, 'Bob', 'Builder')
148
147
  return_value.should == target_node
149
- EquivalentXml.equivalent?(@test_document.ng_xml, @expectations[:instead], :element_order => true).should == true
148
+ @test_document.ng_xml.should be_equivalent_to(@expectations[:instead]).respecting_element_order
149
+ end
150
+
151
+ it "should yield the result if a block is given" do
152
+ target_node = @test_document.find_by_terms(:person => 0).first
153
+ expectation = Nokogiri::XML('<person xmlns="urn:registry-test" title="Actor">Alice</person>').root
154
+ @test_document.template_registry.swap(target_node, :person, 'Bob', 'Builder') { |old_node|
155
+ old_node.should be_equivalent_to(expectation)
156
+ old_node
157
+ }.should be_equivalent_to(expectation)
150
158
  end
151
159
  end
152
160
 
@@ -166,48 +174,54 @@ describe "OM::XML::TemplateRegistry" do
166
174
  @test_document.ng_xml.root.elements.length.should == 2
167
175
  end
168
176
 
177
+ it "should instantiate a detached node from a template" do
178
+ node = @test_document.template(:person, 'Odin', 'All-Father')
179
+ expectation = Nokogiri::XML('<person title="All-Father">Odin</person>').root
180
+ node.should be_equivalent_to(expectation)
181
+ end
182
+
169
183
  it "should add_child_node" do
170
184
  return_value = @test_document.add_child_node(@test_document.ng_xml.root, :person, 'Bob', 'Builder')
171
185
  return_value.should == @test_document.find_by_terms(:person => 1).first
172
- EquivalentXml.equivalent?(@test_document.ng_xml, @expectations[:after], :element_order => true).should == true
186
+ @test_document.ng_xml.should be_equivalent_to(@expectations[:after]).respecting_element_order
173
187
  end
174
188
 
175
189
  it "should add_next_sibling_node" do
176
190
  return_value = @test_document.add_next_sibling_node([:person => 0], :person, 'Bob', 'Builder')
177
191
  return_value.should == @test_document.find_by_terms(:person => 1).first
178
- EquivalentXml.equivalent?(@test_document.ng_xml, @expectations[:after], :element_order => true).should == true
192
+ @test_document.ng_xml.should be_equivalent_to(@expectations[:after]).respecting_element_order
179
193
  end
180
194
 
181
195
  it "should add_previous_sibling_node" do
182
196
  return_value = @test_document.add_previous_sibling_node([:person => 0], :person, 'Bob', 'Builder')
183
197
  return_value.should == @test_document.find_by_terms(:person => 0).first
184
- EquivalentXml.equivalent?(@test_document.ng_xml, @expectations[:before], :element_order => true).should == true
198
+ @test_document.ng_xml.should be_equivalent_to(@expectations[:before]).respecting_element_order
185
199
  end
186
200
 
187
201
  it "should after_node" do
188
202
  return_value = @test_document.after_node([:person => 0], :person, 'Bob', 'Builder')
189
203
  return_value.should == @test_document.find_by_terms(:person => 0).first
190
- EquivalentXml.equivalent?(@test_document.ng_xml, @expectations[:after], :element_order => true).should == true
204
+ @test_document.ng_xml.should be_equivalent_to(@expectations[:after]).respecting_element_order
191
205
  end
192
206
 
193
207
  it "should before_node" do
194
208
  return_value = @test_document.before_node([:person => 0], :person, 'Bob', 'Builder')
195
209
  return_value.should == @test_document.find_by_terms(:person => 1).first
196
- EquivalentXml.equivalent?(@test_document.ng_xml, @expectations[:before], :element_order => true).should == true
210
+ @test_document.ng_xml.should be_equivalent_to(@expectations[:before]).respecting_element_order
197
211
  end
198
212
 
199
213
  it "should replace_node" do
200
214
  target_node = @test_document.find_by_terms(:person => 0).first
201
215
  return_value = @test_document.replace_node(target_node, :person, 'Bob', 'Builder')
202
216
  return_value.should == @test_document.find_by_terms(:person => 0).first
203
- EquivalentXml.equivalent?(@test_document.ng_xml, @expectations[:instead], :element_order => true).should == true
217
+ @test_document.ng_xml.should be_equivalent_to(@expectations[:instead]).respecting_element_order
204
218
  end
205
219
 
206
220
  it "should swap_node" do
207
221
  target_node = @test_document.find_by_terms(:person => 0).first
208
222
  return_value = @test_document.swap_node(target_node, :person, 'Bob', 'Builder')
209
223
  return_value.should == target_node
210
- EquivalentXml.equivalent?(@test_document.ng_xml, @expectations[:instead], :element_order => true).should == true
224
+ @test_document.ng_xml.should be_equivalent_to(@expectations[:instead]).respecting_element_order
211
225
  end
212
226
  end
213
227
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: om
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
5
- prerelease: false
4
+ hash: 29
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 0
10
- version: 1.2.0
9
+ - 1
10
+ version: 1.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Zumwalt
@@ -15,14 +15,13 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-22 00:00:00 -07:00
18
+ date: 2011-03-23 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- type: :runtime
23
22
  prerelease: false
24
- name: nokogiri
25
- version_requirements: &id001 !ruby/object:Gem::Requirement
23
+ type: :runtime
24
+ requirement: &id001 !ruby/object:Gem::Requirement
26
25
  none: false
27
26
  requirements:
28
27
  - - ">="
@@ -31,12 +30,12 @@ dependencies:
31
30
  segments:
32
31
  - 0
33
32
  version: "0"
34
- requirement: *id001
33
+ name: nokogiri
34
+ version_requirements: *id001
35
35
  - !ruby/object:Gem::Dependency
36
- type: :runtime
37
36
  prerelease: false
38
- name: facets
39
- version_requirements: &id002 !ruby/object:Gem::Requirement
37
+ type: :runtime
38
+ requirement: &id002 !ruby/object:Gem::Requirement
40
39
  none: false
41
40
  requirements:
42
41
  - - ">="
@@ -45,12 +44,12 @@ dependencies:
45
44
  segments:
46
45
  - 0
47
46
  version: "0"
48
- requirement: *id002
47
+ name: facets
48
+ version_requirements: *id002
49
49
  - !ruby/object:Gem::Dependency
50
- type: :development
51
50
  prerelease: false
52
- name: jeweler
53
- version_requirements: &id003 !ruby/object:Gem::Requirement
51
+ type: :development
52
+ requirement: &id003 !ruby/object:Gem::Requirement
54
53
  none: false
55
54
  requirements:
56
55
  - - ">="
@@ -59,12 +58,12 @@ dependencies:
59
58
  segments:
60
59
  - 0
61
60
  version: "0"
62
- requirement: *id003
61
+ name: jeweler
62
+ version_requirements: *id003
63
63
  - !ruby/object:Gem::Dependency
64
- type: :development
65
64
  prerelease: false
66
- name: rspec
67
- version_requirements: &id004 !ruby/object:Gem::Requirement
65
+ type: :development
66
+ requirement: &id004 !ruby/object:Gem::Requirement
68
67
  none: false
69
68
  requirements:
70
69
  - - <
@@ -75,12 +74,12 @@ dependencies:
75
74
  - 0
76
75
  - 0
77
76
  version: 2.0.0
78
- requirement: *id004
77
+ name: rspec
78
+ version_requirements: *id004
79
79
  - !ruby/object:Gem::Dependency
80
- type: :development
81
80
  prerelease: false
82
- name: mocha
83
- version_requirements: &id005 !ruby/object:Gem::Requirement
81
+ type: :development
82
+ requirement: &id005 !ruby/object:Gem::Requirement
84
83
  none: false
85
84
  requirements:
86
85
  - - ">="
@@ -91,12 +90,12 @@ dependencies:
91
90
  - 9
92
91
  - 8
93
92
  version: 0.9.8
94
- requirement: *id005
93
+ name: mocha
94
+ version_requirements: *id005
95
95
  - !ruby/object:Gem::Dependency
96
- type: :development
97
96
  prerelease: false
98
- name: ruby-debug
99
- version_requirements: &id006 !ruby/object:Gem::Requirement
97
+ type: :development
98
+ requirement: &id006 !ruby/object:Gem::Requirement
100
99
  none: false
101
100
  requirements:
102
101
  - - ">="
@@ -105,28 +104,28 @@ dependencies:
105
104
  segments:
106
105
  - 0
107
106
  version: "0"
108
- requirement: *id006
107
+ name: ruby-debug
108
+ version_requirements: *id006
109
109
  - !ruby/object:Gem::Dependency
110
- type: :development
111
110
  prerelease: false
112
- name: equivalent-xml
113
- version_requirements: &id007 !ruby/object:Gem::Requirement
111
+ type: :development
112
+ requirement: &id007 !ruby/object:Gem::Requirement
114
113
  none: false
115
114
  requirements:
116
115
  - - ">="
117
116
  - !ruby/object:Gem::Version
118
- hash: 23
117
+ hash: 31
119
118
  segments:
120
119
  - 0
121
- - 1
122
- - 6
123
- version: 0.1.6
124
- requirement: *id007
120
+ - 2
121
+ - 4
122
+ version: 0.2.4
123
+ name: equivalent-xml
124
+ version_requirements: *id007
125
125
  - !ruby/object:Gem::Dependency
126
- type: :runtime
127
126
  prerelease: false
128
- name: nokogiri
129
- version_requirements: &id008 !ruby/object:Gem::Requirement
127
+ type: :runtime
128
+ requirement: &id008 !ruby/object:Gem::Requirement
130
129
  none: false
131
130
  requirements:
132
131
  - - ">="
@@ -137,12 +136,12 @@ dependencies:
137
136
  - 4
138
137
  - 2
139
138
  version: 1.4.2
140
- requirement: *id008
139
+ name: nokogiri
140
+ version_requirements: *id008
141
141
  - !ruby/object:Gem::Dependency
142
- type: :runtime
143
142
  prerelease: false
144
- name: facets
145
- version_requirements: &id009 !ruby/object:Gem::Requirement
143
+ type: :runtime
144
+ requirement: &id009 !ruby/object:Gem::Requirement
146
145
  none: false
147
146
  requirements:
148
147
  - - ">="
@@ -151,12 +150,12 @@ dependencies:
151
150
  segments:
152
151
  - 0
153
152
  version: "0"
154
- requirement: *id009
153
+ name: facets
154
+ version_requirements: *id009
155
155
  - !ruby/object:Gem::Dependency
156
- type: :development
157
156
  prerelease: false
158
- name: rspec
159
- version_requirements: &id010 !ruby/object:Gem::Requirement
157
+ type: :development
158
+ requirement: &id010 !ruby/object:Gem::Requirement
160
159
  none: false
161
160
  requirements:
162
161
  - - ">="
@@ -167,12 +166,12 @@ dependencies:
167
166
  - 2
168
167
  - 9
169
168
  version: 1.2.9
170
- requirement: *id010
169
+ name: rspec
170
+ version_requirements: *id010
171
171
  - !ruby/object:Gem::Dependency
172
- type: :development
173
172
  prerelease: false
174
- name: mocha
175
- version_requirements: &id011 !ruby/object:Gem::Requirement
173
+ type: :development
174
+ requirement: &id011 !ruby/object:Gem::Requirement
176
175
  none: false
177
176
  requirements:
178
177
  - - ">="
@@ -183,12 +182,12 @@ dependencies:
183
182
  - 9
184
183
  - 8
185
184
  version: 0.9.8
186
- requirement: *id011
185
+ name: mocha
186
+ version_requirements: *id011
187
187
  - !ruby/object:Gem::Dependency
188
- type: :development
189
188
  prerelease: false
190
- name: ruby-debug
191
- version_requirements: &id012 !ruby/object:Gem::Requirement
189
+ type: :development
190
+ requirement: &id012 !ruby/object:Gem::Requirement
192
191
  none: false
193
192
  requirements:
194
193
  - - ">="
@@ -197,7 +196,8 @@ dependencies:
197
196
  segments:
198
197
  - 0
199
198
  version: "0"
200
- requirement: *id012
199
+ name: ruby-debug
200
+ version_requirements: *id012
201
201
  description: "OM (Opinionated Metadata): A library to help you tame sprawling XML schemas like MODS. Wraps Nokogiri documents in objects with miscellaneous helper methods for doing things like retrieve generated xpath queries or look up properties based on a simplified DSL"
202
202
  email: matt.zumwalt@yourmediashelf.com
203
203
  executables: []
@@ -288,7 +288,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
288
288
  requirements: []
289
289
 
290
290
  rubyforge_project:
291
- rubygems_version: 1.3.7
291
+ rubygems_version: 1.6.2
292
292
  signing_key:
293
293
  specification_version: 3
294
294
  summary: "OM (Opinionated Metadata): A library to help you tame sprawling XML schemas like MODS."