rind 0.1.4 → 0.1.5

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.
@@ -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>.
@@ -18,11 +18,12 @@ module Manipulate
18
18
  children.insert(children.exact_index(self), *nodes)
19
19
  end
20
20
 
21
- # Calls Rind::Children::delete on <tt>self</tt>.
21
+ # Removes <tt>self</tt> from siblings and returns it.
22
22
  # === Example
23
23
  # nodes = ['a', 'b', 'c']
24
- # nodes[1].delete => 'b'
24
+ # nodes[1].remove => 'b'
25
+ # nodes => ['a', 'c']
25
26
  def remove
26
- self.parent.children.delete(self)
27
+ self.parent.children.delete_at(self.parent.children.exact_index(self))
27
28
  end
28
29
  end
@@ -19,9 +19,9 @@ module Xpath
19
19
  # node check
20
20
  nodes = [node]
21
21
  path.scan(%r{(?:^\/?|\/)
22
- (?:(.*?)::)? # axis
23
- ([^\/\[]+)? # node test
24
- ((?:\[.+?\])*) # predicates
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'
@@ -19,6 +19,6 @@ class ManipulateTest < Test::Unit::TestCase
19
19
 
20
20
  def test_remove
21
21
  assert_equal(@a.children[1].remove, @b2)
22
- assert(@a.children.empty?)
22
+ assert_equal(@a.children, [@b1])
23
23
  end
24
24
  end
@@ -23,6 +23,7 @@ class XpathTest < Test::Unit::TestCase
23
23
  assert_equal(@c1.s('/a'), [@a])
24
24
 
25
25
  assert_equal(@a.s('//c'), [@c1, @c2, @c3])
26
+ assert_equal(@a.s('//parent::b/c'), [@c1, @c2, @c3])
26
27
 
27
28
  assert_equal(@c2.s('..'), [@b2] )
28
29
 
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: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
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-26 00:00:00 -05:00
18
+ date: 2010-06-27 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies: []
21
21