domle 0.5.3 → 0.6.0
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/lib/domle.rb +99 -98
- data.tar.gz.sig +0 -0
- metadata +43 -43
- 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: aab7af7623e3906158d563c1bdb4703c4488cc84e0b14e5e7b35707fc0789041
|
4
|
+
data.tar.gz: 6a7009e972e5d19abc92803a8b5c8f7f1e28ff8131328140d90fb325019592b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31fd753ab43d345211ebe2fe248110b3a1f95cbbaca53dee46fcb7b80131e98cb28b9c3ac936ac80d78e14e3bb1df633ac84805adddb6d34fd82cdb4a7cfe3e2
|
7
|
+
data.tar.gz: 1403d882dac52ea0f4e2b30ccff402a78355e48fada0cd62d776e73bb75f300bc83c7d406cd2f851147cf82d552923fc77b4f205eaf055ab2c9ca6c84b9c14ad
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/domle.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
require 'rexle'
|
6
6
|
require 'csslite'
|
7
|
-
require '
|
7
|
+
require 'rxfreader'
|
8
8
|
|
9
9
|
|
10
10
|
class Style < Hash
|
@@ -15,32 +15,32 @@ class Style < Hash
|
|
15
15
|
super().merge! h
|
16
16
|
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def []=(k,v)
|
20
20
|
|
21
21
|
super(k,v)
|
22
22
|
@parent[:style] = self.map{|x| x.join(':') }.join(';')
|
23
|
-
|
23
|
+
|
24
24
|
if @parent.callback and @parent.callback.respond_to? :refresh then
|
25
|
-
@parent.callback.refresh
|
25
|
+
@parent.callback.refresh
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
class VisualAttributes < Attributes
|
32
|
-
|
32
|
+
|
33
33
|
attr_reader :callback
|
34
|
-
|
34
|
+
|
35
35
|
def initialize(x, parent: nil)
|
36
36
|
@callback = parent
|
37
37
|
self.merge! x if x
|
38
|
-
end
|
39
|
-
|
38
|
+
end
|
39
|
+
|
40
40
|
def style(parent=nil)
|
41
|
-
|
41
|
+
|
42
42
|
@callback ||= parent
|
43
|
-
|
43
|
+
|
44
44
|
if @style.nil? then
|
45
45
|
|
46
46
|
h = self[:style].split(';').inject({}) do |r, x|
|
@@ -53,52 +53,53 @@ class VisualAttributes < Attributes
|
|
53
53
|
end
|
54
54
|
@style
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
end
|
58
58
|
|
59
59
|
class Domle < Rexle
|
60
60
|
using ColouredText
|
61
|
-
|
61
|
+
|
62
62
|
class Element < Rexle::Element
|
63
|
-
|
63
|
+
|
64
64
|
|
65
65
|
class ClassList
|
66
|
-
|
66
|
+
|
67
67
|
def initialize(a, rexle, node)
|
68
68
|
@a, @rexle, @node = a, rexle, node
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
def toggle(name)
|
72
72
|
@a.include?(name) ? @a.delete(name) : @a << name
|
73
73
|
puts '@rexle?: ' + @rexle.inspect if @debug
|
74
74
|
@rexle.refresh_css(@node) if @rexle
|
75
|
-
end
|
76
|
-
end
|
75
|
+
end
|
76
|
+
end
|
77
77
|
|
78
78
|
@default = {}
|
79
79
|
@attr_map = {}
|
80
80
|
attr_reader :attr_map
|
81
|
-
|
81
|
+
|
82
82
|
def initialize(name=self.class.to_s.downcase[/\w+$/], value: nil, \
|
83
83
|
attributes: {}, rexle: nil)
|
84
|
-
|
84
|
+
|
85
85
|
attributes.merge!(style: '') unless attributes.has_key? :style
|
86
|
-
super(name, value: value, attributes: VisualAttributes.new(attributes),
|
87
|
-
|
86
|
+
super(name, value: value, attributes: VisualAttributes.new(attributes),
|
87
|
+
rexle: rexle)
|
88
|
+
|
88
89
|
end
|
89
|
-
|
90
|
+
|
90
91
|
def self.attr2_accessor(*a)
|
91
92
|
|
92
93
|
a.concat %i(id transform)
|
93
|
-
# DOM events
|
94
|
-
a.concat %i(onload onmousemove onmousedown onmouseenter
|
95
|
-
onmouseleave onclick onscroll onkeydown onkeyup)
|
96
|
-
|
94
|
+
# DOM events
|
95
|
+
a.concat %i(onload onmousemove onmousedown onmouseenter
|
96
|
+
onmouseleave onclick onscroll onkeydown onkeyup)
|
97
|
+
|
97
98
|
a.each do |attribute|
|
98
99
|
|
99
100
|
class_eval do
|
100
101
|
|
101
|
-
define_method attribute.to_s.gsub('-','_').to_sym do
|
102
|
+
define_method attribute.to_s.gsub('-','_').to_sym do
|
102
103
|
attributes[attribute]
|
103
104
|
end
|
104
105
|
|
@@ -111,53 +112,53 @@ class Domle < Rexle
|
|
111
112
|
|
112
113
|
end
|
113
114
|
end
|
114
|
-
|
115
|
+
|
115
116
|
def rexle?()
|
116
117
|
not @rexle.nil?
|
117
118
|
end
|
118
|
-
|
119
|
+
|
119
120
|
def rexle()
|
120
121
|
@rexle
|
121
122
|
end
|
122
|
-
|
123
|
+
|
123
124
|
end
|
124
|
-
|
125
|
+
|
125
126
|
def self.attr_mapper(h)
|
126
127
|
@attr_map = h
|
127
128
|
end
|
128
|
-
|
129
|
+
|
129
130
|
def active?()
|
130
131
|
@active
|
131
132
|
end
|
132
|
-
|
133
|
+
|
133
134
|
def active=(v)
|
134
135
|
@active = v
|
135
|
-
end
|
136
|
-
|
136
|
+
end
|
137
|
+
|
137
138
|
def classlist()
|
138
|
-
|
139
|
+
|
139
140
|
a = attributes[:class]
|
140
141
|
cl = ClassList.new(a, @rexle, self)
|
141
|
-
|
142
142
|
|
143
|
-
|
144
|
-
|
143
|
+
|
144
|
+
|
145
|
+
|
145
146
|
return cl
|
146
147
|
end
|
147
|
-
|
148
|
+
|
148
149
|
def style()
|
149
150
|
attributes.style(@rexle)
|
150
151
|
end
|
151
|
-
|
152
|
-
|
152
|
+
|
153
|
+
|
153
154
|
def hotspot?(x,y)
|
154
155
|
|
155
156
|
(boundary.first.is_a?(Array) ? boundary : [boundary]).all? do |box|
|
156
157
|
x1, y1, x2, y2 = box
|
157
158
|
(x1..x2).include? x and (y1..y2).include? y
|
158
159
|
end
|
159
|
-
end
|
160
|
-
|
160
|
+
end
|
161
|
+
|
161
162
|
def obj=(v)
|
162
163
|
@obj = v
|
163
164
|
end
|
@@ -165,27 +166,27 @@ class Domle < Rexle
|
|
165
166
|
def obj()
|
166
167
|
@obj
|
167
168
|
end
|
168
|
-
|
169
|
-
|
169
|
+
|
170
|
+
|
170
171
|
private
|
171
|
-
|
172
|
+
|
172
173
|
def attr_update(name, val)
|
173
174
|
return unless @attr_map
|
174
175
|
puts 'inside attr_update, @attr_map: ' + @attr_map.inspect if @debug
|
175
|
-
name = (@attr_map[name].to_s + '=').to_sym
|
176
|
+
name = (@attr_map[name].to_s + '=').to_sym
|
176
177
|
@obj.method(name).call(val) if @obj.respond_to? name
|
177
178
|
end
|
178
179
|
end
|
179
|
-
|
180
|
+
|
180
181
|
class Script < Element
|
181
182
|
|
182
|
-
end
|
183
|
-
|
183
|
+
end
|
184
|
+
|
184
185
|
class Style < Element
|
185
|
-
|
186
|
+
|
186
187
|
|
187
188
|
end
|
188
|
-
|
189
|
+
|
189
190
|
attr_reader :event
|
190
191
|
|
191
192
|
def initialize(src='<svg/>', callback: nil, rexle: nil, debug: false)
|
@@ -193,14 +194,14 @@ class Domle < Rexle
|
|
193
194
|
@callback, @debug, @rexle = callback, debug, rexle
|
194
195
|
puts 'inside Domle initialize'.info if @debug
|
195
196
|
puts 'src:' + src.inspect if @debug
|
196
|
-
|
197
|
-
super(
|
197
|
+
|
198
|
+
super(RXFReader.read(src).first, rexle: self)
|
198
199
|
@debug = debug
|
199
|
-
|
200
|
+
|
200
201
|
puts 'before find add_css' if @debug
|
201
202
|
find_add_css() if src
|
202
203
|
|
203
|
-
|
204
|
+
|
204
205
|
@event = {
|
205
206
|
keydown: [],
|
206
207
|
keyup: [],
|
@@ -210,47 +211,47 @@ class Domle < Rexle
|
|
210
211
|
mouseleave: [],
|
211
212
|
scroll: []
|
212
213
|
}
|
213
|
-
|
214
|
-
end
|
215
|
-
|
214
|
+
|
215
|
+
end
|
216
|
+
|
216
217
|
def addevent_listener(event, method_name)
|
217
|
-
|
218
|
+
|
218
219
|
@event[event.to_sym] << method_name
|
219
|
-
|
220
|
+
|
220
221
|
end
|
221
|
-
|
222
|
-
|
222
|
+
|
223
|
+
|
223
224
|
def element_by_id(id)
|
224
225
|
@doc.root.element("//*[@id='#{id}']")
|
225
226
|
end
|
226
|
-
|
227
|
+
|
227
228
|
def elements_by_name(name)
|
228
229
|
@doc.root.xpath("//*[@name='#{name}']")
|
229
|
-
end
|
230
|
-
|
230
|
+
end
|
231
|
+
|
231
232
|
def elements_by_tagname(name)
|
232
233
|
@doc.root.xpath("//#{name}")
|
233
|
-
end
|
234
|
-
|
234
|
+
end
|
235
|
+
|
235
236
|
def refresh()
|
236
237
|
@callback.refresh if @callback and @callback.respond_to? :refresh
|
237
238
|
end
|
238
|
-
|
239
|
+
|
239
240
|
def refresh_css(node)
|
240
241
|
find_add_css(node.parent)
|
241
242
|
end
|
242
|
-
|
243
|
+
|
243
244
|
protected
|
244
|
-
|
245
|
+
|
245
246
|
def add_default_css()
|
246
247
|
end
|
247
|
-
|
248
|
+
|
248
249
|
def add_external_css(node=nil)
|
249
|
-
|
250
|
+
|
250
251
|
# check for an external CSS file
|
251
252
|
if @instructions and @instructions.any? then
|
252
253
|
|
253
|
-
hrefs = @instructions.inject([]) do |r,x|
|
254
|
+
hrefs = @instructions.inject([]) do |r,x|
|
254
255
|
|
255
256
|
if x[0] =~ /xml-stylesheet/i and x[1] =~ /text\/css/i then
|
256
257
|
|
@@ -259,28 +260,28 @@ class Domle < Rexle
|
|
259
260
|
r
|
260
261
|
end
|
261
262
|
end
|
262
|
-
|
263
|
+
|
263
264
|
add_css hrefs.map{|x| RXFHelper.read(x).first}.join, node
|
264
|
-
|
265
|
+
|
265
266
|
end
|
266
|
-
|
267
|
+
|
267
268
|
end
|
268
|
-
|
269
|
+
|
269
270
|
def add_inline_css(node=nil)
|
270
271
|
puts 'inside add_inline_css' if @debug
|
271
|
-
@doc.root.xpath('//style').each {|e| add_css e.text.to_s, node }
|
272
|
+
@doc.root.xpath('//style').each {|e| add_css e.text.to_s, node }
|
272
273
|
end
|
273
|
-
|
274
|
+
|
274
275
|
def find_add_css(node=nil)
|
275
|
-
|
276
|
+
|
276
277
|
puts 'inside find_add_css' if @debug
|
277
278
|
add_default_css() unless node
|
278
279
|
add_inline_css(node)
|
279
280
|
add_external_css(node)
|
280
|
-
end
|
281
|
-
|
281
|
+
end
|
282
|
+
|
282
283
|
private
|
283
|
-
|
284
|
+
|
284
285
|
def add_css(s, node=@doc, override: true)
|
285
286
|
|
286
287
|
puts 'add_css s: ' + s.inspect if @debug
|
@@ -295,9 +296,9 @@ class Domle < Rexle
|
|
295
296
|
#
|
296
297
|
def defined_elements()
|
297
298
|
{
|
298
|
-
doc: Rexle::Element
|
299
|
+
doc: Rexle::Element
|
299
300
|
}
|
300
|
-
end
|
301
|
+
end
|
301
302
|
|
302
303
|
def scan_element(name, attributes=nil, *children)
|
303
304
|
|
@@ -312,35 +313,35 @@ class Domle < Rexle
|
|
312
313
|
if children then
|
313
314
|
|
314
315
|
children.each do |x|
|
315
|
-
|
316
|
+
|
316
317
|
if x.is_a? Array then
|
317
318
|
|
318
|
-
element.add_element scan_element(*x)
|
319
|
-
|
319
|
+
element.add_element scan_element(*x)
|
320
|
+
|
320
321
|
elsif x.is_a? String then
|
321
322
|
|
322
323
|
if x.is_a? String then
|
323
324
|
|
324
325
|
element.add_element(x) if x.strip.length > 0
|
325
|
-
|
326
|
+
|
326
327
|
elsif x.name == '![' then
|
327
328
|
|
328
329
|
e = Rexle::CData.new(x)
|
329
330
|
element.add_element e
|
330
|
-
|
331
|
+
|
331
332
|
elsif x.name == '!-' then
|
332
333
|
|
333
334
|
e = Rexle::Comment.new(x)
|
334
335
|
element.add_element e
|
335
|
-
|
336
|
+
|
336
337
|
end
|
337
|
-
|
338
|
+
|
338
339
|
end
|
339
340
|
end
|
340
341
|
end
|
341
|
-
|
342
|
+
|
342
343
|
return element
|
343
344
|
end
|
344
|
-
|
345
|
-
|
345
|
+
|
346
|
+
|
346
347
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: domle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
/
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjIwMjIzMTkyNDE0WhcN
|
15
|
+
MjMwMjIzMTkyNDE0WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDDoHg1
|
17
|
+
dlm44omi2JlyhehpzeodmVum7unwyXkZEAHsEKh+mXlzYBGdWxbY+YX1KMQcYRol
|
18
|
+
EcE4egHY+2lhb2Vnv1t8Rh3dwfcWLN/ZWQ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
32
|
+
jxFFkKYXB2MlEnVr6Gb59v44+VEGuOidO3jykPJWMrIdwKnEZZH8T2yTlkQrlMP5
|
33
|
+
8WabMF23roEt7bPn1PS2d6h3y5JeKS7LNJFE3fGZ8nyDjDYqB9n81a4GsFubFb3c
|
34
|
+
cDX7Urk8FPXCDoY9BNaqCEEZ7EZ2okz1eUW6rfJfxd2HMT9dkYAEB/EZr7saW9NN
|
35
|
+
WmNALyRNdE9qUZs79H0es8GRxFLqo3hKy9wwo/e71PapN5hBmiblML2i9KQjKH8F
|
36
|
+
5VlN3/i+KUFlMQf3KDX18ddy
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2022-02-23 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.14
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -56,49 +56,49 @@ dependencies:
|
|
56
56
|
version: '1.5'
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 1.5.
|
59
|
+
version: 1.5.14
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: csslite
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
|
-
- - ">="
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: 0.2.0
|
67
64
|
- - "~>"
|
68
65
|
- !ruby/object:Gem::Version
|
69
66
|
version: '0.2'
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.2.0
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- - ">="
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: 0.2.0
|
77
74
|
- - "~>"
|
78
75
|
- !ruby/object:Gem::Version
|
79
76
|
version: '0.2'
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 0.2.0
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
|
-
name:
|
81
|
+
name: rxfreader
|
82
82
|
requirement: !ruby/object:Gem::Requirement
|
83
83
|
requirements:
|
84
|
-
- - ">="
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
version: 1.0.0
|
87
84
|
- - "~>"
|
88
85
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
86
|
+
version: '0.2'
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.2.1
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 1.0.0
|
97
94
|
- - "~>"
|
98
95
|
- !ruby/object:Gem::Version
|
99
|
-
version: '
|
96
|
+
version: '0.2'
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 0.2.1
|
100
100
|
description:
|
101
|
-
email:
|
101
|
+
email: digital.robertson@gmail.com
|
102
102
|
executables: []
|
103
103
|
extensions: []
|
104
104
|
extra_rdoc_files: []
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
|
-
rubygems_version: 3.
|
126
|
+
rubygems_version: 3.2.22
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: Domle (DOM + Rexle) is the document object model used by the Svgle gem
|
metadata.gz.sig
CHANGED
Binary file
|