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