polyrex-links 0.3.0 → 0.4.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: 0c19a57b19f29fe68ed02141780c528fcad7a458
4
- data.tar.gz: 7b6c337aa34e83f6e8eb29b060b9bed8854d24bf
2
+ SHA256:
3
+ metadata.gz: 86256bfb4e9270cadb10cb266ee9cb689f78acb29f8f59022cb97acb3765bc95
4
+ data.tar.gz: 489a261c8e3afb75dd57153fb1a8c16f38a9adf2e04876779fb9b2da5498b97e
5
5
  SHA512:
6
- metadata.gz: 6153344d80dd0301dc24ac503c8d398cc5d656b312d687e222e2094767470a016268b70b34a6db55f3c8a5bbb4ec2a34b536904cf67018c3a66eeccfb672a0d9
7
- data.tar.gz: f725ada1262e23a49a55919629408e26faf9dc48bff53cf98bb308c62607eb99bda5e3ea7d6cc2cb91787e81fdb019bfe7f196503728b9cbfabdc3c8b21a8bef
6
+ metadata.gz: 6ad0eabd37defceab3c1c97a57bf369f81d8c72d0dd224bedd577e569dc1b1acdeaa97afb644fb4f7bd6aa0cdfbc18f7c07c61c13e13c8202e237c41dbdd988c
7
+ data.tar.gz: 76a4f2e4ae7932449a2cfb80e8efe5966886af0623d584fe740721d0f7bd9ec00bd66bda549e33f07ae97d3132daa5ca34a49810cdcd8f2cdd392e7df8455f0b
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/polyrex-links.rb CHANGED
@@ -6,30 +6,67 @@ require 'polyrex'
6
6
 
7
7
  class PolyrexLinks < Polyrex
8
8
 
9
- def initialize(x='links/link[name,url]', delimiter: ' # ', debug: false)
10
- super(x)
9
+ def initialize(rawx='links/link[title,url]', delimiter: ' # ', debug: false)
10
+
11
+ x, _ = RXFHelper.read(rawx)
12
+ obj = x.lstrip.sub(/<\?polyrex-links\?>/,
13
+ '<?polyrex schema="links/link[title,url]" delimiter=" # "?>')
14
+ puts 'obj: ' + x.inspect if debug
15
+
16
+ super(obj)
11
17
  @delimiter = self.delimiter = delimiter
12
18
  @debug = debug
19
+
20
+ end
21
+
22
+ def find(s)
23
+
24
+ found = find_by_link_title s
25
+
26
+ if found then
27
+
28
+ path = backtrack_path found
29
+ [link(path.join('/')), path.join('/')]
30
+
31
+ end
32
+
33
+ end
34
+
35
+ def migrate(raws)
36
+
37
+ s, _ = RXFHelper.read(raws)
38
+ pl = PolyrexLinks.new("<?polyrex-links?>\n\n" +
39
+ s.sub(/<\?[^\?]+\?>/,'').lstrip)
40
+
41
+ pl.each_recursive do |x|
42
+ link, linkpath = find(x.title)
43
+ x.url = link.url if link and link.url
44
+ end
45
+
46
+ pl
47
+
13
48
  end
14
49
 
15
50
  # Returns the Polyrex element for the given path
16
51
  #
17
52
  def link(s)
18
53
 
19
- self.rxpath(s.split('/').map {|x| "link[name='%s']" % x}.join('/')).first
54
+ self.rxpath(s.split('/').map {|x| "link[title='%s']" % x}.join('/')).first
20
55
 
21
56
  end
22
57
 
23
58
  # Returns the url and remaining arguments for the given path
24
59
  #
25
60
  def locate(raw_path)
26
-
61
+
62
+ return nil if raw_path.nil? or raw_path.strip.empty?
27
63
  path = raw_path.sub(/^\//,'')
28
64
  a = path.split('/')
29
65
  a2 = []
30
66
  (a2 << a.clone; a.pop) while a.any?
31
-
32
- mask = "records/link[summary/name='%s']"
67
+ return nil if a2.empty?
68
+
69
+ mask = "records/link[summary/title='%s']"
33
70
 
34
71
  begin
35
72
  c = a2.shift; xpath = c.map{|x| mask % x}.join + '/summary/url/text()'
@@ -57,8 +94,20 @@ class PolyrexLinks < Polyrex
57
94
 
58
95
  end
59
96
 
97
+ def to_s()
98
+ "<?polyrex-links?>\n\n" + super(header: false)
99
+ end
100
+
60
101
  private
61
102
 
103
+ def backtrack_path(e, a5=[])
104
+
105
+ backtrack_path(e.parent, a5) if e.parent?
106
+ a5 << e.title
107
+
108
+ return a5
109
+ end
110
+
62
111
 
63
112
  def each_link()
64
113
 
@@ -68,7 +117,7 @@ class PolyrexLinks < Polyrex
68
117
 
69
118
  a.slice!(i..-1)
70
119
  a[i] = record
71
- yield(a.map(&:name).join('/'), record.url) if block_given?
120
+ yield(a.map(&:title).join('/'), record.url) if block_given?
72
121
 
73
122
  end
74
123
 
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.3.0
4
+ version: 0.4.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/X0rEWIHq31oVALOAEwIJMCYGA1Ud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33
- date: 2018-04-12 00:00:00.000000000 Z
38
+ date: 2021-05-25 00:00:00.000000000 Z
34
39
  dependencies:
35
40
  - !ruby/object:Gem::Dependency
36
41
  name: polyrex
@@ -38,22 +43,22 @@ dependencies:
38
43
  requirements:
39
44
  - - "~>"
40
45
  - !ruby/object:Gem::Version
41
- version: '1.2'
46
+ version: '1.3'
42
47
  - - ">="
43
48
  - !ruby/object:Gem::Version
44
- version: 1.2.0
49
+ version: 1.3.2
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.2'
56
+ version: '1.3'
52
57
  - - ">="
53
58
  - !ruby/object:Gem::Version
54
- version: 1.2.0
59
+ version: 1.3.2
55
60
  description:
56
- email: james@jamesrobertson.eu
61
+ email: digital.robertson@gmail.com
57
62
  executables: []
58
63
  extensions: []
59
64
  extra_rdoc_files: []
@@ -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