rind 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +6 -0
- data/lib/rind/manipulate.rb +4 -3
- data/lib/rind/xpath.rb +5 -5
- data/test/manipulate_test.rb +1 -1
- data/test/xpath_test.rb +1 -0
- metadata +4 -4
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 0.1.5 - 2010.06.27
|
2
|
+
* Xpath query parser was not matching leading '//axis::node' correctly. The axis was being parsed as '/axis'.
|
3
|
+
* The <tt>parent</tt> axis was not being handled correctly for the root node.
|
4
|
+
* Xpath queries were returning node-sets that contained duplicate nodes.
|
5
|
+
* The Manipulate::remove function was not removing only the selected node. All nodes that matched <tt>==</tt> were being returned.
|
6
|
+
|
1
7
|
== 0.1.4 - 2010.06.26
|
2
8
|
* Xpath searches with attribute values containing a <tt>/</tt>, like <tt>style[@type="text/css"]</tt>, broke the query parser.
|
3
9
|
* The Manipulate::insert_after and Manipulate::insert_before functions and Xpath positions were not returning the correct nodes when other available nodes matched <tt>==</tt>.
|
data/lib/rind/manipulate.rb
CHANGED
@@ -18,11 +18,12 @@ module Manipulate
|
|
18
18
|
children.insert(children.exact_index(self), *nodes)
|
19
19
|
end
|
20
20
|
|
21
|
-
#
|
21
|
+
# Removes <tt>self</tt> from siblings and returns it.
|
22
22
|
# === Example
|
23
23
|
# nodes = ['a', 'b', 'c']
|
24
|
-
# nodes[1].
|
24
|
+
# nodes[1].remove => 'b'
|
25
|
+
# nodes => ['a', 'c']
|
25
26
|
def remove
|
26
|
-
self.parent.children.
|
27
|
+
self.parent.children.delete_at(self.parent.children.exact_index(self))
|
27
28
|
end
|
28
29
|
end
|
data/lib/rind/xpath.rb
CHANGED
@@ -19,9 +19,9 @@ module Xpath
|
|
19
19
|
# node check
|
20
20
|
nodes = [node]
|
21
21
|
path.scan(%r{(?:^\/?|\/)
|
22
|
-
(?:(
|
23
|
-
([^\/\[]+)?
|
24
|
-
((?:\[.+?\])*)
|
22
|
+
(?:([^\/]*?)::)? # axis
|
23
|
+
([^\/\[]+)? # node test
|
24
|
+
((?:\[.+?\])*) # predicates
|
25
25
|
}x) do |axis, node_test, predicates|
|
26
26
|
case node_test
|
27
27
|
when nil
|
@@ -41,7 +41,7 @@ module Xpath
|
|
41
41
|
predicates.gsub!(/^@/, 'attribute::')
|
42
42
|
|
43
43
|
# find matching nodes
|
44
|
-
nodes = nodes.collect{|node| node.find_matching_nodes(axis, node_test)}.flatten.compact
|
44
|
+
nodes = nodes.collect{|node| node.find_matching_nodes(axis, node_test)}.flatten.compact.uniq
|
45
45
|
|
46
46
|
# check predicates
|
47
47
|
if not predicates.nil?
|
@@ -94,7 +94,7 @@ module Xpath
|
|
94
94
|
when 'following-sibling'
|
95
95
|
self.next_siblings.find_all{|node| node.is_matching_node?(node_test)}
|
96
96
|
when 'parent'
|
97
|
-
self.parent.is_matching_node?(node_test) ? [self.parent] : []
|
97
|
+
(not self.parent.nil? and self.parent.is_matching_node?(node_test)) ? [self.parent] : []
|
98
98
|
when 'preceding-sibling'
|
99
99
|
self.prev_siblings.find_all{|node| node.is_matching_node?(node_test)}
|
100
100
|
when 'self'
|
data/test/manipulate_test.rb
CHANGED
data/test/xpath_test.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rind
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Aaron Lasseigne
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-06-
|
18
|
+
date: 2010-06-27 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|