niceogiri 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - jruby-19mode
6
+ - rbx-19mode
7
+ - ruby-head
@@ -1,3 +1,3 @@
1
1
  module Niceogiri
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -133,18 +133,19 @@ module Niceogiri
133
133
  # @param [XML::Node] node the node to inherit
134
134
  # @return [self]
135
135
  def inherit(node)
136
- self.namespace = node.namespace.href if node.namespace
136
+ inherit_namespaces node
137
137
  inherit_attrs node.attributes
138
- node.children.each do |c|
139
- self << (n = c.dup)
140
- if c.respond_to?(:namespace) && c.namespace
141
- ns = n.add_namespace c.namespace.prefix, c.namespace.href
142
- n.namespace = ns
143
- end
144
- end
138
+ inherit_children node
145
139
  self
146
140
  end
147
141
 
142
+ def inherit_namespaces(node)
143
+ node.namespace_definitions.each do |ns|
144
+ add_namespace ns.prefix, ns.href
145
+ end
146
+ self.namespace = node.namespace.href if node.namespace
147
+ end
148
+
148
149
  # Inherit a set of attributes
149
150
  #
150
151
  # @param [Hash] attrs a hash of attributes to set on the node
@@ -157,6 +158,16 @@ module Niceogiri
157
158
  self
158
159
  end
159
160
 
161
+ def inherit_children(node)
162
+ node.children.each do |c|
163
+ self << (n = c.dup)
164
+ if c.respond_to?(:namespace) && c.namespace
165
+ ns = n.add_namespace c.namespace.prefix, c.namespace.href
166
+ n.namespace = ns
167
+ end
168
+ end
169
+ end
170
+
160
171
  # The node as XML
161
172
  #
162
173
  # @return [String] XML representation of the node
@@ -162,6 +162,15 @@ module Niceogiri
162
162
  body.namespace.href.should be == 'barfoo'
163
163
  end
164
164
 
165
+ it 'holds on to prefixed namespaces when inheriting content' do
166
+ n = Nokogiri::XML.parse('<message xmlns:foo="foobar"></message>').root
167
+ n.namespaces['xmlns:foo'].should be == 'foobar'
168
+
169
+ n2 = Node.new('message').inherit n
170
+ n2.to_s.should == n.to_s
171
+ n2.namespaces['xmlns:foo'].should be == 'foobar'
172
+ end
173
+
165
174
  it 'holds on to namespaces without a prefix when inheriting content' do
166
175
  n = Nokogiri::XML.parse('<message><bar:foo xmlns="http://bar.com"></message>').root
167
176
  n2 = Node.new('message').inherit n
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: niceogiri
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-11-14 00:00:00.000000000 Z
13
+ date: 2012-11-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
@@ -120,6 +120,7 @@ extra_rdoc_files:
120
120
  files:
121
121
  - .gitignore
122
122
  - .rspec
123
+ - .travis.yml
123
124
  - Gemfile
124
125
  - Guardfile
125
126
  - LICENSE
@@ -148,7 +149,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
148
149
  version: '0'
149
150
  segments:
150
151
  - 0
151
- hash: 1354346198489803166
152
+ hash: -1530677168278840494
152
153
  required_rubygems_version: !ruby/object:Gem::Requirement
153
154
  none: false
154
155
  requirements:
@@ -157,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
158
  version: '0'
158
159
  segments:
159
160
  - 0
160
- hash: 1354346198489803166
161
+ hash: -1530677168278840494
161
162
  requirements: []
162
163
  rubyforge_project:
163
164
  rubygems_version: 1.8.24