weblet 0.3.5 → 0.4.0

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 +45 -45
  4. data.tar.gz.sig +0 -0
  5. metadata +10 -11
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e27f4831158495cbf179b607ccb378ae7a966d27abf52cb62a2381d45efcbf43
4
- data.tar.gz: c9e3288adb19d3b9f01288932e852970cfb7ab86922ef8fce7de7e61db7af530
3
+ metadata.gz: 44c3165f75000e5c2ad59d99ab37d672a631389fb1241b9e739ccf58aaf64b5d
4
+ data.tar.gz: 371470bb1005b3291e69cbba8d8d04a17c1afc4ae876cded7f30c0277362700c
5
5
  SHA512:
6
- metadata.gz: 8b61a25a7e5c1a44e1949f99fa040a1be54e6c534d358de2dda6deee1d5f8353adf4a59405e7eb581e7ee4ce05f4baf34c773b61e3591ecc3e62095df7addec8
7
- data.tar.gz: 65fd2f1ed959b189c87fd630fef8284db76e4d242ce95f5bd038ce9cc22082e14a080009fb9c2cac29fe2f7d71b79ad8cbd3344fee069265cf922121366af535
6
+ metadata.gz: e76ced239f76106bd12abe6733dabed1f197c381dc868a785d59e16f66f34be08bb5defa704b031403f5e680a15511afa59361cc7fe309e83b5a4919a6d7c08e
7
+ data.tar.gz: 0c4fe8b26f780ca467f6e53ddfcd9852ff7c10a88a2925cd1909ba3179199a358adcf5ec282f29c3f003b93327c431473fd4df6483c51495fb3490d6043c93a7
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/weblet.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  # file: weblet.rb
4
4
 
5
5
  require 'rexle'
6
- require 'rxfhelper'
6
+ require 'rxfreader'
7
7
 
8
8
 
9
9
  class WebletBuilder
@@ -11,19 +11,19 @@ class WebletBuilder
11
11
  def initialize(s, marker: nil, debug: false)
12
12
 
13
13
  @marker, @debug = marker, debug
14
-
14
+
15
15
  s.strip!
16
-
17
- # the default marker is the hash symbol (#) but the client can set their
16
+
17
+ # the default marker is the hash symbol (#) but the client can set their
18
18
  # own marker by simply using their custom symbol in the 1st line of input
19
19
  @marker ||= s[0]
20
-
20
+
21
21
  a = scan(s.strip)
22
22
  puts 'a: ' + a.inspect if @debug
23
-
23
+
24
24
  @a = build(a)
25
25
  @a.unshift *['weblet', {}, '']
26
-
26
+
27
27
  end
28
28
 
29
29
  def to_a()
@@ -38,42 +38,42 @@ class WebletBuilder
38
38
  return a unless a.length > 1
39
39
 
40
40
  a.map {|x| scan(x, indent+1)}
41
-
41
+
42
42
  end
43
43
 
44
44
  def build(a)
45
45
 
46
46
  puts 'a: ' + a.inspect if @debug
47
-
47
+
48
48
  a.map do |x|
49
-
49
+
50
50
  puts 'x: ' + x.inspect if @debug
51
-
51
+
52
52
  if x.is_a? String then
53
-
53
+
54
54
  head, body = x.split("\n", 2)
55
55
  puts 'head: ' + head.inspect if @debug
56
56
  puts 'body: ' + body.inspect if @debug
57
57
  puts 'marker: ' + @marker.inspect if @debug
58
-
58
+
59
59
  [:node, {id: head[/#{@marker}(\w+)/,1]}, '',['![', {}, body.strip]]
60
-
61
- elsif x[0].is_a? String
62
-
60
+
61
+ elsif x[0].is_a? String
62
+
63
63
  head, body = x[0].split("\n", 2)
64
64
  puts 'body: ' + body.inspect if @debug
65
65
  puts 'marker: ' + @marker.inspect if @debug
66
-
66
+
67
67
  [:node, {id: head[/#{@marker}(\w+)/,1]}, '',['![', {}, body.strip]]
68
-
68
+
69
69
  elsif x[0] and x[0].is_a? Array
70
-
70
+
71
71
  head, body = x[0][0].split("\n", 2)
72
72
  [:node, {id: head[/#{@marker}(\w+)/,1]}, '', \
73
73
  ['![', {}, body.to_s.strip], *build(x[1..-1])]
74
-
74
+
75
75
  end
76
-
76
+
77
77
  end
78
78
 
79
79
  end
@@ -83,10 +83,10 @@ end
83
83
  class Weblet
84
84
 
85
85
  def initialize(raws, marker: nil, debug: false)
86
-
86
+
87
87
  @debug = debug
88
-
89
- s, _ = RXFHelper.read(raws.strip)
88
+
89
+ s, _ = RXFReader.read(raws.strip)
90
90
 
91
91
  obj = s[0] == '<' ? s : WebletBuilder.new(s, marker: marker, \
92
92
  debug: debug).to_a
@@ -99,19 +99,19 @@ class Weblet
99
99
  def to_h()
100
100
  @h
101
101
  end
102
-
102
+
103
103
  def to_outline()
104
104
  treeize(scan_h(@h))
105
105
  end
106
-
106
+
107
107
  def to_xml()
108
108
  @doc.root.xml pretty: true
109
109
  end
110
110
 
111
111
  def render(*args)
112
-
112
+
113
113
  b = args.pop if args.last.is_a? Binding
114
-
114
+
115
115
  if args.first.is_a? String then
116
116
  path = args.first.split('/').map(&:to_sym)
117
117
  else
@@ -120,23 +120,23 @@ class Weblet
120
120
 
121
121
  #r = @h.dig *path
122
122
  r = digx(@h, path)
123
-
123
+
124
124
  # check for interpolated substitution tags e.g/ <:card/svg/link>
125
125
  r.gsub!(/<:([^>]+)>/) {|x| self.render($1) } if r
126
-
126
+
127
127
  puts 'r: ' + r.inspect if @debug
128
-
128
+
129
129
  if r.nil? then
130
130
  found = @doc.root.element("//node[@id='#{path.join}']")
131
131
  r = found.cdatas.join if found
132
132
  end
133
-
133
+
134
134
  eval('%Q(' + r + ')', b) if r
135
135
 
136
136
  end
137
137
 
138
138
  private
139
-
139
+
140
140
  def digx(obj, a)
141
141
 
142
142
  h = obj.is_a?(Array) ? obj.last : obj
@@ -149,33 +149,33 @@ class Weblet
149
149
  r.is_a?(Array) ? r.first : r
150
150
  end
151
151
 
152
- end
152
+ end
153
153
 
154
154
  def scan(node)
155
155
 
156
156
  a = node.elements.map do |e|
157
-
157
+
158
158
  puts 'e: ' + e.inspect if @debug
159
159
 
160
160
  nodes = e.xpath('node')
161
-
161
+
162
162
  puts 'nodes: ' + nodes.inspect if @debug
163
-
163
+
164
164
  r = if nodes.any? then
165
-
165
+
166
166
  r2 = scan(e)
167
167
  e.cdatas.any? ? [e.cdatas.join(), r2] : r2
168
-
168
+
169
169
  else
170
170
  e.cdatas.join()
171
171
  end
172
172
 
173
173
  [e.attributes[:id].to_sym, r]
174
-
174
+
175
175
  end.to_h
176
-
176
+
177
177
  end
178
-
178
+
179
179
  def scan_h(h)
180
180
 
181
181
  a = h.map do |key, value|
@@ -183,7 +183,7 @@ class Weblet
183
183
  end
184
184
 
185
185
  end
186
-
186
+
187
187
  def treeize(a, indent=-2)
188
188
 
189
189
  indent += 1
@@ -198,6 +198,6 @@ class Weblet
198
198
  end.join("\n")
199
199
 
200
200
  end
201
-
202
-
201
+
202
+
203
203
  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.3.5
4
+ version: 0.4.0
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-11 00:00:00.000000000 Z
38
+ date: 2022-02-21 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.11
49
+ version: 1.5.14
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
@@ -56,27 +56,27 @@ dependencies:
56
56
  version: '1.5'
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 1.5.11
59
+ version: 1.5.14
60
60
  - !ruby/object:Gem::Dependency
61
- name: rxfhelper
61
+ name: rxfreader
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: '1.1'
66
+ version: '0.1'
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 1.1.3
69
+ version: 0.1.2
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '1.1'
76
+ version: '0.1'
77
77
  - - ">="
78
78
  - !ruby/object:Gem::Version
79
- version: 1.1.3
79
+ version: 0.1.2
80
80
  description:
81
81
  email: digital.robertson@gmail.com
82
82
  executables: []
@@ -103,8 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  requirements: []
106
- rubyforge_project:
107
- rubygems_version: 2.7.10
106
+ rubygems_version: 3.2.22
108
107
  signing_key:
109
108
  specification_version: 4
110
109
  summary: Intended for retrieving HTML templates from a convenient to use Hash-like
metadata.gz.sig CHANGED
Binary file