domle 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '095273c8d4b59bef87813d8a194acf0e902701e5'
4
- data.tar.gz: 34b78661a39f79736fd008ead34c3dd83ae0d504
3
+ metadata.gz: bfac702b0d6ea21c27356c4aca7764d3fd144f61
4
+ data.tar.gz: a6a9d21974a588786f62d184b0d875fb2a9272af
5
5
  SHA512:
6
- metadata.gz: 2f5fbddee43572d0fe695b4571cc552a96f8d692eb275bcb16bd8214c6e1c2ee492966c37deaf9673a01679b37670f8c0517ef68212e1d64a4c1a6f9a6f9a67e
7
- data.tar.gz: fbd965a81b9a93dbf0bab9a015e257e0ad3efce01c9a5b55d20d0654e5dc96707cebd4a93303a2669ad4bc85aa1713fd06883c974df125b745364f4fb3c70b10
6
+ metadata.gz: 2660f67b2995bed4530dcef75840441560a7348571e62d41b95eeba193f8d9c00030c7ed3aa882ec70ab1aa9247b02e48381318b63e33ca6823fbf98feef6752
7
+ data.tar.gz: 510959b5f5b0df1cb945cb1935135ed576299321c3a7b0e1c34540c5a378cce94cdc047ba9d535a87e1fe0aca8afef090166c88a1ebb93f75f735b2994eb9499
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/domle.rb CHANGED
@@ -111,7 +111,8 @@ class Domle < Rexle
111
111
 
112
112
  def initialize(x=nil, callback: nil)
113
113
 
114
- super x
114
+ super x
115
+
115
116
  find_add_css()
116
117
  @callback = callback
117
118
  end
@@ -120,6 +121,42 @@ class Domle < Rexle
120
121
  @callback.refresh if @callback
121
122
  end
122
123
 
124
+ protected
125
+
126
+ def add_default_css()
127
+ end
128
+
129
+ def add_external_css()
130
+
131
+ # check for an external CSS file
132
+ if @instructions and @instructions.any? then
133
+
134
+ hrefs = @instructions.inject([]) do |r,x|
135
+
136
+ if x[0] =~ /xml-stylesheet/i and x[1] =~ /text\/css/i then
137
+
138
+ r << x[1][/href\s*=\s*["']([^'"]+)/,1]
139
+ else
140
+ r
141
+ end
142
+ end
143
+
144
+ add_css hrefs.map{|x| RXFHelper.read(x).first}.join
145
+
146
+ end
147
+
148
+ end
149
+
150
+ def add_inline_css()
151
+ @doc.root.xpath('//style').each {|e| add_css e.text }
152
+ end
153
+
154
+ def find_add_css()
155
+ add_default_css()
156
+ add_inline_css()
157
+ add_external_css()
158
+ end
159
+
123
160
  private
124
161
 
125
162
  def add_css(s, override: true)
@@ -160,11 +197,13 @@ class Domle < Rexle
160
197
 
161
198
  end
162
199
 
163
- def defined_elements()
164
-
165
- # override this method in your own class
166
-
167
- end
200
+ # override this method in your own class
201
+ #
202
+ def defined_elements()
203
+ {
204
+ doc: Rexle::Element
205
+ }
206
+ end
168
207
 
169
208
  def scan_element(name, attributes=nil, *children)
170
209
 
@@ -209,4 +248,4 @@ class Domle < Rexle
209
248
  end
210
249
 
211
250
 
212
- end
251
+ end
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.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  +DzRmU3W/HlxCxS+NNxtsXgbF7OVnKffoGck1XJLZRXir0GNIDPNB8lscxnltAgL
32
32
  VUONgYmKlCGQ2w==
33
33
  -----END CERTIFICATE-----
34
- date: 2017-01-26 00:00:00.000000000 Z
34
+ date: 2017-05-21 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rexle
metadata.gz.sig CHANGED
Binary file