polyrex-links 0.2.0 → 0.3.0
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/polyrex-links.rb +43 -3
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c19a57b19f29fe68ed02141780c528fcad7a458
|
4
|
+
data.tar.gz: 7b6c337aa34e83f6e8eb29b060b9bed8854d24bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6153344d80dd0301dc24ac503c8d398cc5d656b312d687e222e2094767470a016268b70b34a6db55f3c8a5bbb4ec2a34b536904cf67018c3a66eeccfb672a0d9
|
7
|
+
data.tar.gz: f725ada1262e23a49a55919629408e26faf9dc48bff53cf98bb308c62607eb99bda5e3ea7d6cc2cb91787e81fdb019bfe7f196503728b9cbfabdc3c8b21a8bef
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/polyrex-links.rb
CHANGED
@@ -8,10 +8,20 @@ class PolyrexLinks < Polyrex
|
|
8
8
|
|
9
9
|
def initialize(x='links/link[name,url]', delimiter: ' # ', debug: false)
|
10
10
|
super(x)
|
11
|
-
self.delimiter = delimiter
|
11
|
+
@delimiter = self.delimiter = delimiter
|
12
12
|
@debug = debug
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
|
+
# Returns the Polyrex element for the given path
|
16
|
+
#
|
17
|
+
def link(s)
|
18
|
+
|
19
|
+
self.rxpath(s.split('/').map {|x| "link[name='%s']" % x}.join('/')).first
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
# Returns the url and remaining arguments for the given path
|
24
|
+
#
|
15
25
|
def locate(raw_path)
|
16
26
|
|
17
27
|
path = raw_path.sub(/^\//,'')
|
@@ -30,8 +40,38 @@ class PolyrexLinks < Polyrex
|
|
30
40
|
# it didn't find, or it will return nil.
|
31
41
|
|
32
42
|
puts "c: %s\npath: %s\nr: %s" % [c, path, r].map(&:inspect) if @debug
|
33
|
-
|
43
|
+
|
34
44
|
r ? [r, path.sub(c.join('/'),'')] : nil
|
35
45
|
end
|
46
|
+
|
47
|
+
|
48
|
+
# Return a flat Hash object containing all the links. The link path is
|
49
|
+
# used as the key and the value is the url
|
50
|
+
#
|
51
|
+
def to_h()
|
52
|
+
|
53
|
+
h = {}
|
54
|
+
|
55
|
+
each_link {|key, value| h[key] = value }
|
56
|
+
h
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
|
63
|
+
def each_link()
|
64
|
+
|
65
|
+
a = []
|
66
|
+
|
67
|
+
self.each_recursive() do |record, _, i|
|
68
|
+
|
69
|
+
a.slice!(i..-1)
|
70
|
+
a[i] = record
|
71
|
+
yield(a.map(&:name).join('/'), record.url) if block_given?
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
36
76
|
|
37
77
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
BPwFsWAbLaLB8f5sRH9pSgr7gqm3ky2fSBk//wtYHz86+AKvwZ0E3pvp6FuWl5Az
|
31
31
|
iPQ=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2018-04-
|
33
|
+
date: 2018-04-12 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: polyrex
|
metadata.gz.sig
CHANGED
Binary file
|