domle 0.3.1 → 0.5.2

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.tar.gz.sig +0 -0
  4. data/lib/domle.rb +129 -25
  5. metadata +43 -43
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60ec7d7672b54a42cfcd69d4073231ec96e3c015b2f12884c55df456654fd7b4
4
- data.tar.gz: 8f110ef215d6be5fef49c16816a012839aa446d599fd48a259cfe5472f40f62b
3
+ metadata.gz: 9759262a9e9462c11b0bd60727ba3a177181b7beb730314014e9e808176d1072
4
+ data.tar.gz: cd4e7673d9d15dbe70645eb87426f1db05e2f7205e06e6b51c9b8f73676e6ba1
5
5
  SHA512:
6
- metadata.gz: 862aa72c582891835f857b82155adc390dbb9c7f408a1d59611cac64ba4f23ab70a3a4b71d581778e2f116bad2d663d3c1aceb5585a227123c2d64165f94db2f
7
- data.tar.gz: e40002835209948ac9bbd9047d176d6d3aadb986debc7108b913afba1f4a86b0d388ea62f7ec37facc02bab5f0a67865e449679b02b30eedddfdf475b563699a
6
+ metadata.gz: ca36ee2023a6ea8611ea642557986ce680cf9df7466e2cbc7f3fbc3ff4f4616889b173ba83157e0661404c43b8507f136e36774fa117e253b3869cc2117d9ecc
7
+ data.tar.gz: 1b601b39d8f10e5c56c0aaf5132aa74d3346fbdbc0fe894ec8ab5ef9b4cb11b0757b2f377391c99a93461a0d3bb43ce24eaa02b292f4efaa69786ece8940504d
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -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: VisualAttributes.new(parent: self), rexle: nil)
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)
@@ -71,7 +89,7 @@ class Domle < Rexle
71
89
  a.concat %i(id transform)
72
90
  # DOM events
73
91
  a.concat %i(onload onmousemove onmousedown onmouseenter
74
- onmouseleave onclick onscroll)
92
+ onmouseleave onclick onscroll onkeydown onkeyup)
75
93
 
76
94
  a.each do |attribute|
77
95
 
@@ -83,12 +101,26 @@ class Domle < Rexle
83
101
 
84
102
  define_method (attribute.to_s + '=').to_sym do |val|
85
103
  attributes[attribute] = val
86
- @rexle.refresh if @rexle
104
+ rexle().refresh if rexle?
105
+ attr_update(attribute, val)
87
106
  val
88
107
  end
89
108
 
90
109
  end
91
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
92
124
  end
93
125
 
94
126
  def active?()
@@ -99,6 +131,17 @@ class Domle < Rexle
99
131
  @active = v
100
132
  end
101
133
 
134
+ def classlist()
135
+
136
+ a = attributes[:class]
137
+ cl = ClassList.new(a, @rexle, self)
138
+
139
+
140
+
141
+
142
+ return cl
143
+ end
144
+
102
145
  def style()
103
146
  attributes.style(@rexle)
104
147
  end
@@ -111,6 +154,24 @@ class Domle < Rexle
111
154
  (x1..x2).include? x and (y1..y2).include? y
112
155
  end
113
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
114
175
  end
115
176
 
116
177
  class Script < Element
@@ -121,30 +182,67 @@ class Domle < Rexle
121
182
 
122
183
 
123
184
  end
185
+
186
+ attr_reader :event
124
187
 
125
- def initialize(x='<svg/>', callback: nil, rexle: self, debug: false)
188
+ def initialize(src='<svg/>', callback: nil, rexle: nil, debug: false)
126
189
 
127
- super RXFHelper.read(x).first, rexle: rexle
128
- find_add_css() if x
129
- @callback, @debug = callback, debug
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
+ }
130
210
 
131
211
  end
132
212
 
133
- def element_by_id(id)
134
- @doc.root.element("//*[@id='#{id}']")
135
- end
136
-
213
+ def addevent_listener(event, method_name)
214
+
215
+ @event[event.to_sym] << method_name
216
+
217
+ end
218
+
219
+
220
+ def element_by_id(id)
221
+ @doc.root.element("//*[@id='#{id}']")
222
+ end
137
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
+
138
232
  def refresh()
139
233
  @callback.refresh if @callback
140
234
  end
141
235
 
236
+ def refresh_css(node)
237
+ find_add_css(node.parent)
238
+ end
239
+
142
240
  protected
143
241
 
144
242
  def add_default_css()
145
243
  end
146
244
 
147
- def add_external_css()
245
+ def add_external_css(node=nil)
148
246
 
149
247
  # check for an external CSS file
150
248
  if @instructions and @instructions.any? then
@@ -159,29 +257,35 @@ class Domle < Rexle
159
257
  end
160
258
  end
161
259
 
162
- add_css hrefs.map{|x| RXFHelper.read(x).first}.join
260
+ add_css hrefs.map{|x| RXFHelper.read(x).first}.join, node
163
261
 
164
262
  end
165
263
 
166
264
  end
167
265
 
168
- def add_inline_css()
169
- @doc.root.xpath('//style').each {|e| add_css e.text }
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 }
170
269
  end
171
270
 
172
- def find_add_css()
173
- add_default_css()
174
- add_inline_css()
175
- add_external_css()
176
- end
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
177
278
 
178
279
  private
179
280
 
180
- def add_css(s, override: true)
181
-
182
- css = CSSLite.new s
183
- css.propagate self.root
184
-
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
185
289
  end
186
290
 
187
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.3.1
4
+ version: 0.5.2
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
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHh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mTTjrWtRvzpkIsOATH+02GVzq6IXp92bOlo3jux6IogeMTKUI
33
- NHDkO5fcGMCFJPYiRuO+G6Q8a84D5ygQJSh1vcVz5UOt/sbHkzXB2ZXzsSZxARAo
34
- 7WUufgoTkSx2l89paohsgp6nKxhUOS3dbrRugCOShy+F/mlA0zNc1k0l9AmCX2az
35
- 5W+/h8msUafjVr6ihNHTXefecVsjVhacb6l0hBYUNzXDpkhCjnNUaSxcS0e4FavI
36
- JHHC9WlNneDJrmTdGxNUWsw6
28
+ BgkqhkiG9w0BAQsFAAOCAYEATKO4gsH586vrhwVMsn8y4MNk+oNmqLaV5/uQzki6
29
+ I3jSu/1NOnHgOwZ+qj7FtGQIhlWrk3B2Yl+1DnF/YXmkppV7Ge5DLhpRRxXW2ZfA
30
+ SUc9ShIkYXrgfY1r7oL5iMSsLUp+kNA8RlRmhxhdRH8rm80nlvoYtJH/kGN9xgNZ
31
+ 9swoqkehC7nNf6RzRiFd3z7xCnNOnAqTzvIdIm0CBwhGAixGLRfOit3v3/iIyjSe
32
+ jIWH0OKqh/m8vvFCTCHFtr5gR+J3sBfJfg+Y+TH2Hi/GOkvU+SZ1uyWWAkuGxVnX
33
+ JYmxw6FYVTYOv/r2nz/sVQWRDxYYjV5LcZ1ItJS9MVdvb9vDYzQw3clEt+K5DjQU
34
+ iCUNL5rwIkLnLoAc4c6M3bTze3UExyNDNjwQjuUV6Kyl/105/90y44FgAizwS6xu
35
+ ewt0cFO7UqEB/yC8KNeXJjd19INo+w98LYjFZQEzLAg15Sz7ca5bUbr/LuYQUk4y
36
+ Lvi3w1KUp4YuUbhbhnEQXuPH
37
37
  -----END CERTIFICATE-----
38
- date: 2019-02-26 00:00:00.000000000 Z
38
+ date: 2020-06-20 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.1
49
+ version: 1.5.6
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
@@ -56,47 +56,47 @@ dependencies:
56
56
  version: '1.5'
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 1.5.1
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.1.3
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.1.3
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
83
83
  requirements:
84
- - - "~>"
85
- - !ruby/object:Gem::Version
86
- version: '0.9'
87
84
  - - ">="
88
85
  - !ruby/object:Gem::Version
89
- version: 0.9.4
86
+ version: 1.0.0
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.0'
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: '0.9'
97
94
  - - ">="
98
95
  - !ruby/object:Gem::Version
99
- version: 0.9.4
96
+ version: 1.0.0
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '1.0'
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.1
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