free_dom 0.1.0 → 0.2.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.tar.gz.sig +0 -0
- data/lib/free_dom.rb +60 -8
- metadata +2 -2
- 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: 0b25006295cb48501f306a796923819b86162ba2479c3daa84e490bc201d9364
|
|
4
|
+
data.tar.gz: 87796929372ea091459a75facb1a8d01b94d3368dbe8e99d6e37e4a8614b2149
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ec3355fdef23b6ff5d9c8c668db1a258dec3f4cd58cdd942e324e587f1b03729ae4f9d91a9df321ba4f2a97eb548da1565b881f5ad53c32d388fc8ad02e6e350
|
|
7
|
+
data.tar.gz: 850c75e8fa3fc0b91d13cd31d7702d311c9a6635bcbfe89ed6e8ac6ad2cb7a4767853dd0799511a4a550ae37d220ca210660587095b1489aa0c44a711635c7cf
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data.tar.gz.sig
CHANGED
|
Binary file
|
data/lib/free_dom.rb
CHANGED
|
@@ -7,24 +7,56 @@ require 'domle'
|
|
|
7
7
|
|
|
8
8
|
class FreeDom < Domle
|
|
9
9
|
|
|
10
|
-
def initialize(xml)
|
|
10
|
+
def initialize(xml, debug: false)
|
|
11
11
|
|
|
12
|
-
doc = Rexle.new
|
|
12
|
+
@doc, @debug = Rexle.new(xml), debug
|
|
13
13
|
|
|
14
14
|
h = {}
|
|
15
15
|
|
|
16
|
-
doc.root.each_recursive do |e|
|
|
16
|
+
@doc.root.each_recursive do |e|
|
|
17
17
|
h[e.name.to_sym] ||= {}
|
|
18
18
|
h[e.name.to_sym].merge!(e.attributes)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
@defined_elements = {}
|
|
22
22
|
|
|
23
|
-
h.each do |name,
|
|
23
|
+
h.each do |name, attributelist|
|
|
24
24
|
|
|
25
25
|
klass = Class.new(Domle::Element) do
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
a = attributelist.keys
|
|
28
|
+
|
|
29
|
+
triggers = a.select {|x| x =~ /^trigger_/ }
|
|
30
|
+
|
|
31
|
+
attr2_accessor *(a - triggers)
|
|
32
|
+
|
|
33
|
+
triggers.each do |x|
|
|
34
|
+
|
|
35
|
+
trigger = x.to_s[/(?<=^trigger_).*/].to_sym
|
|
36
|
+
puts 'trigger: ' + trigger.inspect if @debug
|
|
37
|
+
|
|
38
|
+
define_method(trigger) do
|
|
39
|
+
eval method(('on' + trigger.to_s).to_sym).call, $env
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
if trigger == :change then
|
|
43
|
+
|
|
44
|
+
#puts 'change found'
|
|
45
|
+
|
|
46
|
+
attribute = attributelist[x].to_sym
|
|
47
|
+
|
|
48
|
+
define_method((attribute.to_s + '=').to_sym) do |val|
|
|
49
|
+
oldval = attributes[attribute]
|
|
50
|
+
attributes[attribute] = val
|
|
51
|
+
#puts 'inside change='
|
|
52
|
+
@rexle.refresh if @rexle
|
|
53
|
+
change() unless val == oldval
|
|
54
|
+
val
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|
|
28
60
|
|
|
29
61
|
end
|
|
30
62
|
|
|
@@ -32,9 +64,31 @@ class FreeDom < Domle
|
|
|
32
64
|
@defined_elements.merge!({name => custom_class})
|
|
33
65
|
|
|
34
66
|
end
|
|
67
|
+
|
|
68
|
+
# remove the trigger declaration attributes
|
|
69
|
+
@doc.root.each_recursive do |e|
|
|
70
|
+
e.attributes.keys.select {|x| x =~ /^trigger_/ }\
|
|
71
|
+
.each {|x| e.attributes.delete x }
|
|
72
|
+
end
|
|
35
73
|
|
|
36
|
-
super(xml)
|
|
74
|
+
super(@doc.root.xml)
|
|
75
|
+
script()
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
# used within the scope of the script tags
|
|
81
|
+
#
|
|
82
|
+
def doc()
|
|
83
|
+
self
|
|
37
84
|
end
|
|
85
|
+
|
|
86
|
+
def script()
|
|
87
|
+
s = @doc.root.xpath('//script').map {|x| x.text.unescape }.join
|
|
88
|
+
eval s
|
|
89
|
+
$env = binding
|
|
90
|
+
end
|
|
91
|
+
|
|
38
92
|
|
|
39
93
|
private
|
|
40
94
|
|
|
@@ -43,5 +97,3 @@ class FreeDom < Domle
|
|
|
43
97
|
end
|
|
44
98
|
|
|
45
99
|
end
|
|
46
|
-
|
|
47
|
-
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: free_dom
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- James Robertson
|
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
|
35
35
|
VxSuuHhAXplX7wWmd1FzAAH5bk4OPlKGt5fxQbax+FSoEzTsnoDcLTY2i0WOxwRo
|
|
36
36
|
76nAi+UZoU87S6brj88/rtOL
|
|
37
37
|
-----END CERTIFICATE-----
|
|
38
|
-
date: 2020-04-
|
|
38
|
+
date: 2020-04-30 00:00:00.000000000 Z
|
|
39
39
|
dependencies:
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: domle
|
metadata.gz.sig
CHANGED
|
Binary file
|