polyrex-links 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/polyrex-links.rb +13 -3
  2. metadata +2 -2
data/lib/polyrex-links.rb CHANGED
@@ -15,9 +15,19 @@ class PolyrexLinks
15
15
  end
16
16
 
17
17
  def locate(path)
18
- xpath = path.split('/').map{|x| "records/link[summary/name='%s']" % x}\
19
- .join + '/summary/url/text()'
20
- @polyrex.element xpath
18
+
19
+ a = path.split('/')
20
+ a2 = []
21
+ (a2 << a.clone; a.pop) while a.any?
22
+
23
+ mask = "records/link[summary/name='%s']"
24
+
25
+ do
26
+ c = a2.shift; xpath = c.map{|x| mask % x}.join + '/summary/url/text()'
27
+ r = @polyrex.element xpath
28
+ end until r or a2.empty?
29
+
30
+ r + path.sub(c.join('/'),'')
21
31
  end
22
32
 
23
33
  def to_xml(options={})
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: polyrex-links
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.1
5
+ version: 0.1.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - James Robertson
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-08-03 00:00:00 +01:00
13
+ date: 2012-02-21 00:00:00 +00:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency