polyrex-links 0.1.8 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a55eb5dc1b4b5a707bd3f9a44fbc7cec6884635a
4
- data.tar.gz: 8ca8073c0bee874ab3ff9a68af305a735ec73f5b
2
+ SHA256:
3
+ metadata.gz: 3195deb3e835d3551fcfa47a178a0665340e704674753a006293d586c2bd3a70
4
+ data.tar.gz: 75297f0afa0dd7b8dc9a317d7ef8bbd00c29d41a509a41a6279929a88f887b39
5
5
  SHA512:
6
- metadata.gz: 282a294f42ea204999b3cf4c9b3c09905f4bffae8620fe570a81d9f2d54abf8bc51492e95aed1a4193dd0067c2419a58c596277c7356e244a94e15dfa01dfc03
7
- data.tar.gz: 9c0cecebac2e7428dac11b41bca4b0b0c5f5d5e559f2c9eacd54b24d1f171ac32616f892032123b75c358bc12f5c465bd94ab8d45084cbd36c0f71f4f8e5e7e6
6
+ metadata.gz: 05d4a307e3a4393171ffd1f678c00e91607a3165857845c83e61217c99763260e454e2e8a9d53b3997e4943cb81033a3a6a33886c16cb1fd11c93559ef865721
7
+ data.tar.gz: 338fae386a335997ec904b8082ec53ab34a33156b41a9a825b1040b42fb4579470b72686cee6ea071b4ab8e4b7dff047b3aa3b185e5b6f301b1845b22cfc05d1
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/polyrex-links.rb CHANGED
@@ -6,17 +6,44 @@ require 'polyrex'
6
6
 
7
7
  class PolyrexLinks < Polyrex
8
8
 
9
- def initialize(x='links/link[name,url]')
9
+ def initialize(x='links/link[name,url]', delimiter: ' # ', debug: false)
10
10
  super(x)
11
- self.delimiter = ' # '
11
+ @delimiter = self.delimiter = delimiter
12
+ @debug = debug
12
13
  end
13
-
14
- def locate(path)
14
+
15
+ def find(s)
16
+
17
+ found = find_by_link_name s
18
+
19
+ if found then
20
+
21
+ path = backtrack_path found
22
+ [locate(path.join('/')), path.join('/')]
23
+
24
+ end
25
+
26
+ end
27
+
28
+ # Returns the Polyrex element for the given path
29
+ #
30
+ def link(s)
31
+
32
+ self.rxpath(s.split('/').map {|x| "link[name='%s']" % x}.join('/')).first
15
33
 
34
+ end
35
+
36
+ # Returns the url and remaining arguments for the given path
37
+ #
38
+ def locate(raw_path)
39
+
40
+ return nil if raw_path.nil? or raw_path.strip.empty?
41
+ path = raw_path.sub(/^\//,'')
16
42
  a = path.split('/')
17
43
  a2 = []
18
44
  (a2 << a.clone; a.pop) while a.any?
19
-
45
+ return nil if a2.empty?
46
+
20
47
  mask = "records/link[summary/name='%s']"
21
48
 
22
49
  begin
@@ -26,7 +53,48 @@ class PolyrexLinks < Polyrex
26
53
 
27
54
  # return the found path along with any remaining string which
28
55
  # it didn't find, or it will return nil.
29
- r ? [r + path.sub(c.join('/'),''), path.sub(c.join('/'),'')] : nil
56
+
57
+ puts "c: %s\npath: %s\nr: %s" % [c, path, r].map(&:inspect) if @debug
58
+
59
+ r ? [r, path.sub(c.join('/'),'')] : nil
30
60
  end
61
+
62
+
63
+ # Return a flat Hash object containing all the links. The link path is
64
+ # used as the key and the value is the url
65
+ #
66
+ def to_h()
67
+
68
+ h = {}
69
+
70
+ each_link {|key, value| h[key] = value }
71
+ h
72
+
73
+ end
74
+
75
+ private
76
+
77
+ def backtrack_path(e, a5=[])
78
+
79
+ backtrack_path(e.parent, a5) if e.parent?
80
+ a5 << e.name
81
+
82
+ return a5
83
+ end
84
+
85
+
86
+ def each_link()
87
+
88
+ a = []
89
+
90
+ self.each_recursive() do |record, _, i|
91
+
92
+ a.slice!(i..-1)
93
+ a[i] = record
94
+ yield(a.map(&:name).join('/'), record.url) if block_given?
95
+
96
+ end
97
+
98
+ end
31
99
 
32
100
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyrex-links
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,27 +10,32 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDXjCCAkagAwIBAgIBATANBgkqhkiG9w0BAQUFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTgwMzIxMTQzNzQ3WhcN
15
- MTkwMzIxMTQzNzQ3WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDUE5r+
17
- CoqxqOOXr3v0GW1pe7qKUAwPKVr6xJQwZgP+oNWstt/uuQe9ohWT14DigR/GphUw
18
- AOYEYXoy8qa5zzJV0q+LhS1OohliMQBG00vWXcHz9dMtVzcWp1xC68q3Tw9pM85g
19
- mCyqcM2onmB/7CUISigY1zIS2acmihWSzFasaL29d5XNOwFzhkuQUEfL+f4m35An
20
- nPuEY4HyEzA3d4acZOqV4O8bSYeiOu+M+aWdTE1wPUS150VtbR3jebyG9aWqsEad
21
- rQpvmo56nae1bc51HWudEY9t+y2WoT1wWE8/7H0HfobR12adcGElv/4WsfoWnCaM
22
- LEtkGqWVbEgiq/CbAgMBAAGjgYowgYcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
23
- HQYDVR0OBBYEFJ49MMj/X0rEWIHq31oVALOAEwIJMCYGA1UdEQQfMB2BG2dlbW1h
24
- c3RlckBqYW1lc3JvYmVydHNvbi5ldTAmBgNVHRIEHzAdgRtnZW1tYXN0ZXJAamFt
25
- ZXNyb2JlcnRzb24uZXUwDQYJKoZIhvcNAQEFBQADggEBAGw2ftJrTxQ25tkByit/
26
- 6jJI/StiPRVHdsfDDJF0/1lcNjkVXPVkwix3n8MiCNp+OuKujk+EpuVAvzX/fFYG
27
- 3tXM/alEykb+dLL1/D+evWLCxwPQmIl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sCAwEA
25
+ AaOBijCBhzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUke21GuFM
26
+ jVaog26Uc04gxKe1iCwwJgYDVR0RBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
27
+ c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
28
+ BgkqhkiG9w0BAQsFAAOCAYEAjIJYPq1LH/BCICN8vgvNFgGs21y/cfvb9xHYlzFW
29
+ rsugnb0Z/o4KFuR4F8JceTgBAhwCKnsXltjamYjw+VfcF/4KVtmgiFKjS35kTCu1
30
+ bTemc4gbHKjwz03kh35lDFD6sfqCumtifHBPNZjYXB3Nxlel+ECHLtj7NP4K14wJ
31
+ yu/k6V++dimd0zKocsIOSwuOUCbn9q3sXu0ZNippHdpyYtaj76BFURASv2xVj4KR
32
+ sIkI6KVVE15q6hrjxLInQX2GH6frDr6I6w7ltuDhI8I3TkW9C/W5vuoHyWCiG9qX
33
+ cBRqqQiCW7xMi8SCyoVCJydO3Js8E0gFrbg6R9XcsIt2yaktptXEcY4hm+yWlkJD
34
+ Nnidax6k9ikNRlpzL5AhDq6nRARm+7bJAr/4Ln3SswnLtXW6//WkQyReUJMDgRo9
35
+ 5x/50O2gHQvmLgSVk8EsWqPZ6B8tMZ9h/ttCIkW33ewCmHrrxH9suuyqbC/SaiEf
36
+ 2qE86MpuEcgDiX59WiP5GiBx
32
37
  -----END CERTIFICATE-----
33
- date: 2018-03-21 00:00:00.000000000 Z
38
+ date: 2021-05-24 00:00:00.000000000 Z
34
39
  dependencies:
35
40
  - !ruby/object:Gem::Dependency
36
41
  name: polyrex
@@ -38,20 +43,20 @@ dependencies:
38
43
  requirements:
39
44
  - - "~>"
40
45
  - !ruby/object:Gem::Version
41
- version: '1.1'
46
+ version: '1.2'
42
47
  - - ">="
43
48
  - !ruby/object:Gem::Version
44
- version: 1.1.13
49
+ version: 1.2.0
45
50
  type: :runtime
46
51
  prerelease: false
47
52
  version_requirements: !ruby/object:Gem::Requirement
48
53
  requirements:
49
54
  - - "~>"
50
55
  - !ruby/object:Gem::Version
51
- version: '1.1'
56
+ version: '1.2'
52
57
  - - ">="
53
58
  - !ruby/object:Gem::Version
54
- version: 1.1.13
59
+ version: 1.2.0
55
60
  description:
56
61
  email: james@jamesrobertson.eu
57
62
  executables: []
@@ -78,8 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
83
  - !ruby/object:Gem::Version
79
84
  version: '0'
80
85
  requirements: []
81
- rubyforge_project:
82
- rubygems_version: 2.6.13
86
+ rubygems_version: 3.1.2
83
87
  signing_key:
84
88
  specification_version: 4
85
89
  summary: A convenient gem for retrieving a link from a hierarchical lookup table from
metadata.gz.sig CHANGED
Binary file