weblet 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/weblet.rb +46 -38
  4. data.tar.gz.sig +0 -0
  5. metadata +24 -24
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44c3165f75000e5c2ad59d99ab37d672a631389fb1241b9e739ccf58aaf64b5d
4
- data.tar.gz: 371470bb1005b3291e69cbba8d8d04a17c1afc4ae876cded7f30c0277362700c
3
+ metadata.gz: 9cdf3dd81231ca9ee4385a6bb250af42f86677e30951cea62e74c5dac3a2ed19
4
+ data.tar.gz: 0f5aead405414359f202d14c97f4da26fb102d55a5b077822a4f2ebf1087c5d1
5
5
  SHA512:
6
- metadata.gz: e76ced239f76106bd12abe6733dabed1f197c381dc868a785d59e16f66f34be08bb5defa704b031403f5e680a15511afa59361cc7fe309e83b5a4919a6d7c08e
7
- data.tar.gz: 0c4fe8b26f780ca467f6e53ddfcd9852ff7c10a88a2925cd1909ba3179199a358adcf5ec282f29c3f003b93327c431473fd4df6483c51495fb3490d6043c93a7
6
+ metadata.gz: c2062764f51b7343e8800a9e32a823efed674af59c8e088705916e53da12b61d61c5f42ae7778940fb1f214507e672bdbb4d1dc460219ca585f23dc7a8624c7e
7
+ data.tar.gz: 6bca43e05423533b06f0ad10645c0ef8e0d9376a6335d6a26302946d18e6f8cbf0db1941da34b7c112896e1d73248111c76509e52ede277c17b0f0d70726454c
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/weblet.rb CHANGED
@@ -93,13 +93,27 @@ class Weblet
93
93
  puts 'obj: ' + obj.inspect if @debug
94
94
  @doc = Rexle.new(obj)
95
95
  @h = scan @doc.root
96
+ @kvp = scan2keypair(@h).to_h
96
97
 
97
98
  end
98
99
 
100
+ def [](key)
101
+ @kvp[key.to_s]
102
+ end
103
+
104
+ def []=(key, value)
105
+ @kvp[key.to_s] = value
106
+ end
107
+
99
108
  def to_h()
100
109
  @h
101
110
  end
102
111
 
112
+ # key-value pair
113
+ def to_kvp()
114
+ @kvp
115
+ end
116
+
103
117
  def to_outline()
104
118
  treeize(scan_h(@h))
105
119
  end
@@ -108,59 +122,26 @@ class Weblet
108
122
  @doc.root.xml pretty: true
109
123
  end
110
124
 
111
- def render(*args)
112
-
113
- b = args.pop if args.last.is_a? Binding
114
-
115
- if args.first.is_a? String then
116
- path = args.first.split('/').map(&:to_sym)
117
- else
118
- path = *args.flatten(1)
119
- end
125
+ def render(rawkey, bindingx=nil)
120
126
 
121
- #r = @h.dig *path
122
- r = digx(@h, path)
127
+ key = rawkey.to_s
128
+ return unless @kvp.has_key?(key)
123
129
 
124
130
  # check for interpolated substitution tags e.g/ <:card/svg/link>
125
- r.gsub!(/<:([^>]+)>/) {|x| self.render($1) } if r
131
+ r = @kvp[key].gsub(/<:([^>]+)>/) {|x| self.render($1) }
126
132
 
127
- puts 'r: ' + r.inspect if @debug
128
-
129
- if r.nil? then
130
- found = @doc.root.element("//node[@id='#{path.join}']")
131
- r = found.cdatas.join if found
132
- end
133
-
134
- eval('%Q(' + r + ')', b) if r
133
+ eval('%Q(' + r + ')', bindingx)
135
134
 
136
135
  end
137
136
 
138
137
  private
139
138
 
140
- def digx(obj, a)
141
-
142
- h = obj.is_a?(Array) ? obj.last : obj
143
-
144
- r = h.dig(a.shift)
145
-
146
- if a.any? then
147
- digx(r, a)
148
- else
149
- r.is_a?(Array) ? r.first : r
150
- end
151
-
152
- end
153
-
154
139
  def scan(node)
155
140
 
156
141
  a = node.elements.map do |e|
157
142
 
158
- puts 'e: ' + e.inspect if @debug
159
-
160
143
  nodes = e.xpath('node')
161
144
 
162
- puts 'nodes: ' + nodes.inspect if @debug
163
-
164
145
  r = if nodes.any? then
165
146
 
166
147
  r2 = scan(e)
@@ -199,5 +180,32 @@ class Weblet
199
180
 
200
181
  end
201
182
 
183
+ def scan2keypair(h, trail=nil)
184
+
185
+ h.inject([]) do |r,x|
186
+
187
+ if x.last.is_a? String then
188
+
189
+ key, val = x
190
+
191
+ new_key = if r.last and r.last.first.length > 0 then
192
+ key.to_s
193
+ else
194
+ key.to_s
195
+ end
196
+
197
+ r << [[trail, new_key].compact.join('/'), val]
198
+
199
+ else
200
+
201
+ new_key = x.first.to_s
202
+ r << [new_key, x.last.first]
203
+ r.concat scan2keypair(x.last.last, [trail, new_key].compact.join('/'))
204
+
205
+ end
206
+
207
+ end
208
+
209
+ end
202
210
 
203
211
  end
data.tar.gz.sig CHANGED
Binary file
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.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -11,31 +11,31 @@ cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjEwNDAyMjA1NjE2WhcN
15
- MjIwNDAyMjA1NjE2WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDeT7iZ
17
- 2Rq2gB9JMjpvuSywAjBJd904yMTINVnue+yGshnh6t2xg9BPXbnuSdjS8pg2vyJ4
18
- EgkwsZvsTbAgeg0D/+fDxPKNj4765QwLDOWGGNgD7XbLwOcqVdtmqxH8Q3/vgklC
19
- OlPJxI5ea/gEHVezAiaKYBhIUQ+9unBQdTiOfO4pmSWoxYZ9ecqip9E1Pg+/F6S8
20
- Fghu8Krax3y7rLuox0NQv8ow+HZRW8axWu2rlaGc3wnVzY+UFTMJhwNdl0/k0BMS
21
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hwKjVazss2N+EHTwCNBuOu6tK69bzTf1j0cm6KRcJ5jxzkpZr+
31
+ N7376dc4ukN7rhBqjKnjYZln/TKbP4eRwqhOEerBVDn1/W6BzZMCkJGB9BQpp4/B
32
+ XH6/f4U2XBLY5kGDq0YeVnKaoqjyyMtEh93qTIukESvIjlMWuh5pUktikPsrhqly
33
+ f07hewJIYm5TfvecZtS9aCRJiAIEQBCZ5zAeisxCJKJzoHkHltoYmPZ0z7LanOWy
34
+ JnNGpUAfgxmo+dQH+d6tbe9rVXNyk2FINurCKGx3N7OJsfJWueTiHXENks2men9q
35
+ 35oUH2ouHjXtvit5hQCmL2+hQV/HFZj86eWeg422XrNjGwBbyQwueRmGDSR5jAbO
36
+ /gJR3jXcFcpOgDnvL6xGYhfn
37
37
  -----END CERTIFICATE-----
38
- date: 2022-02-21 00:00:00.000000000 Z
38
+ date: 2022-04-19 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rexle
metadata.gz.sig CHANGED
Binary file