domle 0.2.2 → 0.5.1
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/domle.rb +139 -25
- metadata +37 -37
- 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: ffedd3974a12290417326278c4df2f79c97e64303eec8e5c4fa3e3875b4d2663
|
4
|
+
data.tar.gz: b2be643717e9f483a671c57e2fde3ec2c423cdc25d5c905a6fc594a17ec00853
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cdf45a19fbf66d9a57cb563fb9db01f3a874b748530e1f94343c8ec6202dc3b9b5b85d6bc19e45d0012a859a928de9567aa41a12f84e69bdce0245cb3b264fa
|
7
|
+
data.tar.gz: 12fb235afb980a62648b90b98cdef319deedf2036b903de80a882bef333a556e6cb3823e8e60d00b6f78934572af957e5ddcba7d98c358bef000bd9046d7d623
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/domle.rb
CHANGED
@@ -54,12 +54,30 @@ class VisualAttributes < Attributes
|
|
54
54
|
end
|
55
55
|
|
56
56
|
class Domle < Rexle
|
57
|
+
using ColouredText
|
57
58
|
|
58
59
|
class Element < Rexle::Element
|
60
|
+
|
61
|
+
|
62
|
+
class ClassList
|
63
|
+
|
64
|
+
def initialize(a, rexle, node)
|
65
|
+
@a, @rexle, @node = a, rexle, node
|
66
|
+
end
|
67
|
+
|
68
|
+
def toggle(name)
|
69
|
+
@a.include?(name) ? @a.delete(name) : @a << name
|
70
|
+
puts '@rexle?: ' + @rexle.inspect if @debug
|
71
|
+
@rexle.refresh_css(@node) if @rexle
|
72
|
+
end
|
73
|
+
end
|
59
74
|
|
60
75
|
@default = {}
|
76
|
+
@attr_map = {}
|
77
|
+
attr_reader :attr_map
|
78
|
+
|
61
79
|
def initialize(name=self.class.to_s.downcase[/\w+$/], value: nil, \
|
62
|
-
attributes:
|
80
|
+
attributes: {}, rexle: nil)
|
63
81
|
|
64
82
|
attributes.merge!(style: '') unless attributes.has_key? :style
|
65
83
|
super(name, value: value, attributes: VisualAttributes.new(attributes), rexle: rexle)
|
@@ -69,7 +87,9 @@ class Domle < Rexle
|
|
69
87
|
def self.attr2_accessor(*a)
|
70
88
|
|
71
89
|
a.concat %i(id transform)
|
72
|
-
|
90
|
+
# DOM events
|
91
|
+
a.concat %i(onload onmousemove onmousedown onmouseenter
|
92
|
+
onmouseleave onclick onscroll onkeydown onkeyup)
|
73
93
|
|
74
94
|
a.each do |attribute|
|
75
95
|
|
@@ -81,12 +101,45 @@ class Domle < Rexle
|
|
81
101
|
|
82
102
|
define_method (attribute.to_s + '=').to_sym do |val|
|
83
103
|
attributes[attribute] = val
|
84
|
-
|
104
|
+
rexle().refresh if rexle?
|
105
|
+
attr_update(attribute, val)
|
85
106
|
val
|
86
107
|
end
|
87
108
|
|
88
109
|
end
|
89
110
|
end
|
111
|
+
|
112
|
+
def rexle?()
|
113
|
+
not @rexle.nil?
|
114
|
+
end
|
115
|
+
|
116
|
+
def rexle()
|
117
|
+
@rexle
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.attr_mapper(h)
|
123
|
+
@attr_map = h
|
124
|
+
end
|
125
|
+
|
126
|
+
def active?()
|
127
|
+
@active
|
128
|
+
end
|
129
|
+
|
130
|
+
def active=(v)
|
131
|
+
@active = v
|
132
|
+
end
|
133
|
+
|
134
|
+
def classlist()
|
135
|
+
|
136
|
+
a = attributes[:class]
|
137
|
+
cl = ClassList.new(a, @rexle, self)
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
return cl
|
90
143
|
end
|
91
144
|
|
92
145
|
def style()
|
@@ -101,6 +154,24 @@ class Domle < Rexle
|
|
101
154
|
(x1..x2).include? x and (y1..y2).include? y
|
102
155
|
end
|
103
156
|
end
|
157
|
+
|
158
|
+
def obj=(v)
|
159
|
+
@obj = v
|
160
|
+
end
|
161
|
+
|
162
|
+
def obj()
|
163
|
+
@obj
|
164
|
+
end
|
165
|
+
|
166
|
+
|
167
|
+
private
|
168
|
+
|
169
|
+
def attr_update(name, val)
|
170
|
+
return unless @attr_map
|
171
|
+
puts 'inside attr_update, @attr_map: ' + @attr_map.inspect if @debug
|
172
|
+
name = (@attr_map[name].to_s + '=').to_sym
|
173
|
+
@obj.method(name).call(val) if @obj.respond_to? name
|
174
|
+
end
|
104
175
|
end
|
105
176
|
|
106
177
|
class Script < Element
|
@@ -111,30 +182,67 @@ class Domle < Rexle
|
|
111
182
|
|
112
183
|
|
113
184
|
end
|
185
|
+
|
186
|
+
attr_reader :event
|
114
187
|
|
115
|
-
def initialize(
|
188
|
+
def initialize(src='<svg/>', callback: nil, rexle: nil, debug: false)
|
116
189
|
|
117
|
-
|
118
|
-
|
119
|
-
|
190
|
+
@callback, @debug, @rexle = callback, debug, rexle
|
191
|
+
puts 'inside Domle initialize'.info if @debug
|
192
|
+
puts 'src:' + src.inspect if @debug
|
193
|
+
|
194
|
+
super(RXFHelper.read(src).first, rexle: self)
|
195
|
+
@debug = debug
|
196
|
+
|
197
|
+
puts 'before find add_css' if @debug
|
198
|
+
find_add_css() if src
|
199
|
+
|
200
|
+
|
201
|
+
@event = {
|
202
|
+
keydown: [],
|
203
|
+
keyup: [],
|
204
|
+
mousemove: [],
|
205
|
+
mousedown: [],
|
206
|
+
mouseenter: [],
|
207
|
+
mouseleave: [],
|
208
|
+
scroll: []
|
209
|
+
}
|
120
210
|
|
121
211
|
end
|
122
212
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
213
|
+
def addevent_listener(event, method_name)
|
214
|
+
|
215
|
+
@event[event.to_sym] << method_name
|
216
|
+
|
217
|
+
end
|
218
|
+
|
127
219
|
|
220
|
+
def element_by_id(id)
|
221
|
+
@doc.root.element("//*[@id='#{id}']")
|
222
|
+
end
|
223
|
+
|
224
|
+
def elements_by_name(name)
|
225
|
+
@doc.root.xpath("//*[@name='#{name}']")
|
226
|
+
end
|
227
|
+
|
228
|
+
def elements_by_tagname(name)
|
229
|
+
@doc.root.xpath("//#{name}")
|
230
|
+
end
|
231
|
+
|
128
232
|
def refresh()
|
129
233
|
@callback.refresh if @callback
|
130
234
|
end
|
131
235
|
|
236
|
+
def refresh_css(node)
|
237
|
+
find_add_css(node.parent)
|
238
|
+
end
|
239
|
+
|
132
240
|
protected
|
133
241
|
|
134
242
|
def add_default_css()
|
135
243
|
end
|
136
244
|
|
137
|
-
def add_external_css()
|
245
|
+
def add_external_css(node=nil)
|
138
246
|
|
139
247
|
# check for an external CSS file
|
140
248
|
if @instructions and @instructions.any? then
|
@@ -149,29 +257,35 @@ class Domle < Rexle
|
|
149
257
|
end
|
150
258
|
end
|
151
259
|
|
152
|
-
add_css hrefs.map{|x| RXFHelper.read(x).first}.join
|
260
|
+
add_css hrefs.map{|x| RXFHelper.read(x).first}.join, node
|
153
261
|
|
154
262
|
end
|
155
263
|
|
156
264
|
end
|
157
265
|
|
158
|
-
def add_inline_css()
|
159
|
-
|
266
|
+
def add_inline_css(node=nil)
|
267
|
+
puts 'inside add_inline_css' if @debug
|
268
|
+
@doc.root.xpath('//style').each {|e| add_css e.text.to_s, node }
|
160
269
|
end
|
161
270
|
|
162
|
-
def find_add_css()
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
271
|
+
def find_add_css(node=nil)
|
272
|
+
|
273
|
+
puts 'inside find_add_css' if @debug
|
274
|
+
add_default_css() unless node
|
275
|
+
add_inline_css(node)
|
276
|
+
add_external_css(node)
|
277
|
+
end
|
167
278
|
|
168
279
|
private
|
169
280
|
|
170
|
-
def add_css(s, override: true)
|
171
|
-
|
172
|
-
|
173
|
-
css.
|
174
|
-
|
281
|
+
def add_css(s, node=@doc, override: true)
|
282
|
+
|
283
|
+
puts 'add_css s: ' + s.inspect if @debug
|
284
|
+
css = CSSLite.new s, debug: @debug
|
285
|
+
node ||= @doc
|
286
|
+
puts 'before propagate node: ' + node.inspect if @debug
|
287
|
+
css.propagate node
|
288
|
+
puts node.xml if @debug
|
175
289
|
end
|
176
290
|
|
177
291
|
# override this method in your own class
|
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.5.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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjAwNTAxMTMxNjQ5WhcN
|
15
|
+
MjEwNTAxMTMxNjQ5WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDNesSu
|
17
|
+
sygIaXbswwwwIdCy5SkfMqbxiDiQf6vXceCVmoAx7lPQcPXApty8VE6JeA1SXIPI
|
18
|
+
O3m+1x6bK3c3KJdXBjebuWwnMI93y2zevnLJaTCogWqprucrwv0HPlcsNPRPNbWY
|
19
|
+
rR4W5yU+bZfT3R9XoQWXC6emzlXmzIZTAMKtPoH88p5L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kuGxVnX
|
33
|
+
JYmxw6FYVTYOv/r2nz/sVQWRDxYYjV5LcZ1ItJS9MVdvb9vDYzQw3clEt+K5DjQU
|
34
|
+
iCUNL5rwIkLnLoAc4c6M3bTze3UExyNDNjwQjuUV6Kyl/105/90y44FgAizwS6xu
|
35
|
+
ewt0cFO7UqEB/yC8KNeXJjd19INo+w98LYjFZQEzLAg15Sz7ca5bUbr/LuYQUk4y
|
36
|
+
Lvi3w1KUp4YuUbhbhnEQXuPH
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2020-06-07 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.6
|
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.
|
59
|
+
version: 1.5.6
|
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.1'
|
67
64
|
- - ">="
|
68
65
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0.
|
66
|
+
version: 0.2.0
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.2'
|
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.1'
|
77
74
|
- - ">="
|
78
75
|
- !ruby/object:Gem::Version
|
79
|
-
version: 0.
|
76
|
+
version: 0.2.0
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0.2'
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rxfhelper
|
82
82
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,7 +86,7 @@ dependencies:
|
|
86
86
|
version: '0.9'
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.9.
|
89
|
+
version: 0.9.4
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -96,7 +96,7 @@ dependencies:
|
|
96
96
|
version: '0.9'
|
97
97
|
- - ">="
|
98
98
|
- !ruby/object:Gem::Version
|
99
|
-
version: 0.9.
|
99
|
+
version: 0.9.4
|
100
100
|
description:
|
101
101
|
email: james@jamesrobertson.eu
|
102
102
|
executables: []
|
@@ -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.0.
|
126
|
+
rubygems_version: 3.0.3
|
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
|