weblet 0.2.2 → 0.3.2
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/weblet.rb +50 -14
- metadata +24 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0f32000335f285a84e9b8d8c65c1538af4ebbbe436800e7be9495eb93d8dcf6
|
4
|
+
data.tar.gz: 49b57498d30f41b1d493f75f38323738535afd44b4635ab5b1946dcb1a544776
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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('/'
|
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?
|
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.
|
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-
|
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.
|
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.
|
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
|