weblet 0.2.3 → 0.3.3

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
2
  SHA256:
3
- metadata.gz: bc94ddba2ec7b157db2ad2e536a796c46ae6a829536f12631331c5fa6f29e797
4
- data.tar.gz: 5175e71457a2c80638175ba58b828d4cb92827e015ef54228e32164d770c3b6e
3
+ metadata.gz: 84328a442455cb403946363b167a422151842600101026ed880f9efa3f7bae5f
4
+ data.tar.gz: eb5786ae7f0b2991b8d7b4b3475011bed15fa89641b3a0644707e2a506f9e328
5
5
  SHA512:
6
- metadata.gz: 8c0f683f4aa1a07beb26cdeb5d2e7f5d5669bd5da389874d6d95b1c7d7ebbcba365d40357d30354b0147974aadef0a42e6eae59b22702e2880483a535e6aa5a5
7
- data.tar.gz: 9ae047f6215a0435a60958c90eb1ee72bab8dec7fb739e69985b0646a99e2c452f3b6a8735522f4b099b6ef29a1330f32c6dd73a345235b3b225e1bb6b38205a
6
+ metadata.gz: 1bb9ecfb115c39da76cbc5b49871a8391985ec6eae1caf825b75457c65a754b36e7ed00cf38af8fcdff6a2cb0482b8634230ffca072582724d793162bb863b63
7
+ data.tar.gz: 3bc984b898e9c2a4d92a9e09a37835c1cc5666f4f4c019668aab423b3b922b9d28af924b428b599d1a92ff2d7dd670f9fe8a5018d389416e00773ce215ee95b0
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/weblet.rb CHANGED
@@ -12,11 +12,16 @@ class WebletBuilder
12
12
 
13
13
  @marker, @debug = marker, debug
14
14
 
15
+ s.strip!
16
+
15
17
  # the default marker is the hash symbol (#) but the client can set their
16
18
  # own marker by simply using their custom symbol in the 1st line of input
17
19
  @marker ||= s[0]
18
20
 
19
- @a = build(scan(s.strip))
21
+ a = scan(s.strip)
22
+ puts 'a: ' + a.inspect if @debug
23
+
24
+ @a = build(a)
20
25
  @a.unshift *['weblet', {}, '']
21
26
 
22
27
  end
@@ -38,21 +43,23 @@ class WebletBuilder
38
43
 
39
44
  def build(a)
40
45
 
46
+ puts 'a: ' + a.inspect if @debug
47
+
41
48
  a.map do |x|
42
49
 
43
50
  puts 'x: ' + x.inspect if @debug
44
51
 
45
- if x.is_a? String then
46
- head, body = x.split("\n", 2)
52
+ if x[0].is_a? String then
53
+
54
+ head, body = x[0].split("\n", 2)
47
55
  [:node, {id: head[/#{@marker}(\w+)/,1]}, '',['![', {}, body.strip]]
48
- elsif x.length < 2
49
- x.flatten!(1)
50
- head, body = x.shift.split("\n", 2)
51
- [:node, {id: head[/#{@marker}(\w+)/,1].rstrip}, '',['![', {}, body.rstrip, ]]
52
- else
53
- x.flatten!(1)
54
- head, body = x.shift.split("\n", 2)
55
- [:node, {id: head[/#{@marker}(\w+)/,1].rstrip}, body.rstrip, *build(x)]
56
+
57
+ elsif x[0] and x[0].is_a? Array
58
+
59
+ head, body = x[0][0].split("\n", 2)
60
+ [:node, {id: head[/#{@marker}(\w+)/,1]}, '', \
61
+ ['![', {}, body.to_s.strip], *build(x[1..-1])]
62
+
56
63
  end
57
64
 
58
65
  end
@@ -87,13 +94,21 @@ class Weblet
87
94
 
88
95
  def render(*args)
89
96
 
97
+ @b = args.pop if args.last.is_a? Binding
98
+
90
99
  if args.first.is_a? String then
91
- path = args.first.split('/',2).map(&:to_sym)
100
+ path = args.first.split('/').map(&:to_sym)
92
101
  else
93
102
  path = *args.flatten(1)
94
103
  end
95
104
 
96
- r = @h.dig *path
105
+ #r = @h.dig *path
106
+ r = digx(@h, path)
107
+
108
+ # check for interpolated substitution tags e.g/ <:card/svg/link>
109
+ r.gsub!(/<:([^>]+)>/) {|x| self.render($1) } if r
110
+
111
+ puts 'r: ' + r.inspect if @debug
97
112
 
98
113
  if r.nil? then
99
114
  found = @doc.root.element("//node[@id='#{path.join}']")
@@ -105,6 +120,20 @@ class Weblet
105
120
  end
106
121
 
107
122
  private
123
+
124
+ def digx(obj, a)
125
+
126
+ h = obj.is_a?(Array) ? obj.last : obj
127
+
128
+ r = h.dig(a.shift)
129
+
130
+ if a.any? then
131
+ digx(r, a)
132
+ else
133
+ r.is_a?(Array) ? r.first : r
134
+ end
135
+
136
+ end
108
137
 
109
138
  def scan(node)
110
139
 
@@ -116,7 +145,14 @@ class Weblet
116
145
 
117
146
  puts 'nodes: ' + nodes.inspect if @debug
118
147
 
119
- r = nodes.any? ? scan(e) : e.cdatas.join()
148
+ r = if nodes.any? then
149
+
150
+ r2 = scan(e)
151
+ e.cdatas.any? ? [e.cdatas.join(), r2] : r2
152
+
153
+ else
154
+ e.cdatas.join()
155
+ end
120
156
 
121
157
  [e.attributes[:id].to_sym, r]
122
158
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weblet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  mKbvoKGru7nPXh4E/ArWQ70Yz24o3lwGZW3XLzwdLPKB8MiOOGuTARkCWFEYT5tE
36
36
  We42rjyhFeidBuSZp6/7Wwlo
37
37
  -----END CERTIFICATE-----
38
- date: 2021-04-03 00:00:00.000000000 Z
38
+ date: 2021-04-05 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rexle
@@ -46,7 +46,7 @@ dependencies:
46
46
  version: '1.5'
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 1.5.10
49
+ version: 1.5.11
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
@@ -56,7 +56,7 @@ dependencies:
56
56
  version: '1.5'
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 1.5.10
59
+ version: 1.5.11
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: rxfhelper
62
62
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
Binary file