domle 0.4.1 → 0.5.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.tar.gz.sig +0 -0
  4. data/lib/domle.rb +85 -24
  5. metadata +12 -12
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e07d0add095c38076dedbab5af6a7ddfeef11ee1fdee619632fc49777e5cb005
4
- data.tar.gz: 64778a5462f04e3a5edb93dfbedf802fd839f23ce8b1940659811305f1cc1ca8
3
+ metadata.gz: 4aae0c6c1cf14054879f710475a65bd756a849f30d2c4b220d6974f5d6b2d702
4
+ data.tar.gz: b32f5ea3a8ec6af2f9c86f0027233b7ceb3ae6f61dcd38db9dd8be60edb4035b
5
5
  SHA512:
6
- metadata.gz: 5df146c6366edea6906c9bdd0f9dfb15de4975a87657f943c25ebf1ad90e24acf4080bb58f04157aa49fadd5c25fdae40ac6a8117fc6f170c7ef3c1fcfadeab3
7
- data.tar.gz: bf72c5c38dc30a7d98dbc211762e5c1f42a2df3ac91a13b0144a2b39c2b1808abdeabe1898322fc863485047ab208fa9bbf4849c7f2cf2c44639f3ad2880eade
6
+ metadata.gz: b699d13d11215c3f48cb7c24355ef17ad7e2bb110a7a05137504674c20028e8641e9a4065aefa4a8da051bd6980121b9d0a78abbe5184ea53cb4c4f17da0732f
7
+ data.tar.gz: 0af2dcf1fa3138453a3fc5e5c91e26b6ff33ebc113e6788a301fa936f702cef0c14324013f8efa75dfc2f9e2d74780c32a629709409821327ef6c133598b51ff
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -56,8 +56,24 @@ end
56
56
  class Domle < Rexle
57
57
 
58
58
  class Element < Rexle::Element
59
+
60
+
61
+ class ClassList
62
+
63
+ def initialize(a, rexle, node)
64
+ @a, @rexle, @node = a, rexle, node
65
+ end
66
+
67
+ def toggle(name)
68
+ @a.include?(name) ? @a.delete(name) : @a << name
69
+ puts '@rexle?: ' + @rexle.inspect
70
+ @rexle.refresh_css(@node) if @rexle
71
+ end
72
+ end
59
73
 
60
74
  @default = {}
75
+ @attr_map = {}
76
+
61
77
  def initialize(name=self.class.to_s.downcase[/\w+$/], value: nil, \
62
78
  attributes: VisualAttributes.new(parent: self), rexle: nil)
63
79
 
@@ -83,12 +99,26 @@ class Domle < Rexle
83
99
 
84
100
  define_method (attribute.to_s + '=').to_sym do |val|
85
101
  attributes[attribute] = val
86
- @rexle.refresh if @rexle
102
+ rexle().refresh if rexle?
103
+ attr_update(attribute, val)
87
104
  val
88
105
  end
89
106
 
90
107
  end
91
108
  end
109
+
110
+ def rexle?()
111
+ not @rexle.nil?
112
+ end
113
+
114
+ def rexle()
115
+ @rexle
116
+ end
117
+
118
+ end
119
+
120
+ def self.attr_mapper(h)
121
+ @attr_map = h
92
122
  end
93
123
 
94
124
  def active?()
@@ -102,12 +132,12 @@ class Domle < Rexle
102
132
  def classlist()
103
133
 
104
134
  a = attributes[:class]
135
+ cl = ClassList.new(a, @rexle, self)
136
+
137
+
105
138
 
106
- def a.toggle(name)
107
- self.include?(name) ? self.delete(name) : self << name
108
- end
109
139
 
110
- return a
140
+ return cl
111
141
  end
112
142
 
113
143
  def style()
@@ -122,6 +152,12 @@ class Domle < Rexle
122
152
  (x1..x2).include? x and (y1..y2).include? y
123
153
  end
124
154
  end
155
+
156
+ private
157
+
158
+ def attr_update(name, val)
159
+
160
+ end
125
161
  end
126
162
 
127
163
  class Script < Element
@@ -135,11 +171,19 @@ class Domle < Rexle
135
171
 
136
172
  attr_reader :event
137
173
 
138
- def initialize(x='<svg/>', callback: nil, rexle: self, debug: false)
174
+ def initialize(src='<svg/>', callback: nil, rexle: nil, debug: false)
175
+
176
+ @callback, @debug, @rexle = callback, debug, rexle
177
+ puts 'inside Domle initialize'.info if @debug
178
+ puts 'src:' + src.inspect if @debug
179
+
180
+ @debug = debug = false
181
+ super(RXFHelper.read(src).first, rexle: self, debug: debug)
182
+ @debug = debug = true
183
+
184
+ puts 'before find add_css' if @debug
185
+ find_add_css() if src
139
186
 
140
- super RXFHelper.read(x).first, rexle: rexle
141
- find_add_css() if x
142
- @callback, @debug = callback, debug
143
187
 
144
188
  @event = {
145
189
  keydown: [],
@@ -162,19 +206,30 @@ class Domle < Rexle
162
206
 
163
207
  def element_by_id(id)
164
208
  @doc.root.element("//*[@id='#{id}']")
165
- end
209
+ end
166
210
 
211
+ def elements_by_name(name)
212
+ @doc.root.xpath("//*[@name='#{name}']")
213
+ end
214
+
215
+ def elements_by_tagname(name)
216
+ @doc.root.xpath("//#{name}")
217
+ end
167
218
 
168
219
  def refresh()
169
220
  @callback.refresh if @callback
170
221
  end
171
222
 
223
+ def refresh_css(node)
224
+ find_add_css(node.parent)
225
+ end
226
+
172
227
  protected
173
228
 
174
229
  def add_default_css()
175
230
  end
176
231
 
177
- def add_external_css()
232
+ def add_external_css(node=nil)
178
233
 
179
234
  # check for an external CSS file
180
235
  if @instructions and @instructions.any? then
@@ -189,29 +244,35 @@ class Domle < Rexle
189
244
  end
190
245
  end
191
246
 
192
- add_css hrefs.map{|x| RXFHelper.read(x).first}.join
247
+ add_css hrefs.map{|x| RXFHelper.read(x).first}.join, node
193
248
 
194
249
  end
195
250
 
196
251
  end
197
252
 
198
- def add_inline_css()
199
- @doc.root.xpath('//style').each {|e| add_css e.text }
253
+ def add_inline_css(node=nil)
254
+ puts 'inside add_inline_css' if @debug
255
+ @doc.root.xpath('//style').each {|e| add_css e.text.to_s, node }
200
256
  end
201
257
 
202
- def find_add_css()
203
- add_default_css()
204
- add_inline_css()
205
- add_external_css()
206
- end
258
+ def find_add_css(node=nil)
259
+
260
+ puts 'inside find_add_css' if @debug
261
+ add_default_css() unless node
262
+ add_inline_css(node)
263
+ add_external_css(node)
264
+ end
207
265
 
208
266
  private
209
267
 
210
- def add_css(s, override: true)
211
-
212
- css = CSSLite.new s
213
- css.propagate self.root
214
-
268
+ def add_css(s, node=@doc, override: true)
269
+
270
+ puts 'add_css s: ' + s.inspect if @debug
271
+ css = CSSLite.new s, debug: @debug
272
+ node ||= @doc
273
+ puts 'before propagate node: ' + node.inspect
274
+ css.propagate node
275
+ puts node.xml if @debug
215
276
  end
216
277
 
217
278
  # 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.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  ewt0cFO7UqEB/yC8KNeXJjd19INo+w98LYjFZQEzLAg15Sz7ca5bUbr/LuYQUk4y
36
36
  Lvi3w1KUp4YuUbhbhnEQXuPH
37
37
  -----END CERTIFICATE-----
38
- date: 2020-05-02 00:00:00.000000000 Z
38
+ date: 2020-05-12 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.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.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.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
metadata.gz.sig CHANGED
Binary file