weblet 0.2.2 → 0.3.2

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.tar.gz.sig +0 -0
  4. data/lib/weblet.rb +50 -14
  5. metadata +24 -4
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1b3fa491f5536efe9eba1c3c3a0832c05d200e964af91b907a37bc585903261
4
- data.tar.gz: baa8a63a3292328e12eb67b03e9d0ac5e89d931d1e6c0a77d0002ae5484a58b7
3
+ metadata.gz: f0f32000335f285a84e9b8d8c65c1538af4ebbbe436800e7be9495eb93d8dcf6
4
+ data.tar.gz: 49b57498d30f41b1d493f75f38323738535afd44b4635ab5b1946dcb1a544776
5
5
  SHA512:
6
- metadata.gz: c10707bb0f4e4134565c0d3043dd5d1d571bf10e2451ff641c17bcd9786cb540ed2afa45b481d18494f5c1cab67f3b5e906590d2abc520cdf03a596e5a661ce4
7
- data.tar.gz: 9387796aab5fd12979e1b5d0d7a05116e77b8400a2f73e4f21446616118f7065e92dc1f19f6e94a872e846ded6c96564ee5bfb3a57dc661b9fa592961b1bd08b
6
+ metadata.gz: f10d8b6c10928cf4b72fbd2ca96a00ef38fac45ee072758f36c7234a1d902d23bfd3b04d880fe62a83120c96193cff734e86b18dc50c55274cf428cf0f01e31d
7
+ data.tar.gz: ee926e36ed3b780a7efd4e0b651bb9bd21f4315107d92b1ab381938ca946eb191620573ba49f39990d6606ad0ae43ff0e77591d60bc6f7297010f581673a7501
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.2
4
+ version: 0.3.2
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-04 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,27 @@ 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
+ - !ruby/object:Gem::Dependency
61
+ name: rxfhelper
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '1.1'
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 1.1.3
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '1.1'
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 1.1.3
60
80
  description:
61
81
  email: digital.robertson@gmail.com
62
82
  executables: []
metadata.gz.sig CHANGED
Binary file