csslite 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/csslite.rb +27 -20
- metadata +27 -24
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 23ee4f1fbc6c7aed763a4bc53742b7aa32d1a40bb2986bd00e600ecccb07da77
|
4
|
+
data.tar.gz: 5179cff8f4018365562a21860e7bbff942fd99bf0176409706ce1c6c4f3dc5a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 572d484cb1170d6a9f22268f4288bec3f9566db02fcff79b2a58e93e5d84cf2818d132b50f339be65132b189c6cb84b62b7255a4a5e8319dc77cd728163c5dd1
|
7
|
+
data.tar.gz: d5456ebc4697652d3af9ca69f9662afa13382ce6bed9483ddbf2b495f8f5ce09a98c0d11c26b3f93f3808b7c1fadcd97adcce57f4e993a7e7691ede6c88afbec
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/csslite.rb
CHANGED
@@ -2,11 +2,15 @@
|
|
2
2
|
|
3
3
|
# file: csslite.rb
|
4
4
|
|
5
|
+
require 'c32'
|
5
6
|
|
6
|
-
class CSSLite
|
7
7
|
|
8
|
+
class CSSLite
|
9
|
+
using ColouredText
|
8
10
|
|
9
|
-
def initialize(s)
|
11
|
+
def initialize(s, debug: false, override: false)
|
12
|
+
|
13
|
+
@debug, @override = debug, override
|
10
14
|
|
11
15
|
# parse the CSS
|
12
16
|
|
@@ -22,12 +26,14 @@ class CSSLite
|
|
22
26
|
[raw_selector.split(/,\s*/).map(&:strip), h]
|
23
27
|
end
|
24
28
|
|
25
|
-
@
|
29
|
+
puts '@a: ' + @a.inspect if @debug
|
26
30
|
|
27
31
|
end
|
28
32
|
|
29
33
|
def propagate(root_element)
|
30
|
-
|
34
|
+
|
35
|
+
puts 'inside csslist#propagate'.info if @debug
|
36
|
+
|
31
37
|
# add each CSS style attribute to the element
|
32
38
|
# e.g. @a = [[['line'],{stroke: 'green'}]]
|
33
39
|
|
@@ -37,15 +43,12 @@ class CSSLite
|
|
37
43
|
|
38
44
|
selectors.each do |selector|
|
39
45
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
# apply the CSS to all its children
|
47
|
-
element.each_recursive {|x| apply_style x, k,v}
|
48
|
-
end
|
46
|
+
root_element.css(selector).each do |element|
|
47
|
+
puts 'element: ' + element.inspect if @debug
|
48
|
+
apply_style element, style
|
49
|
+
|
50
|
+
# apply the CSS to all its children
|
51
|
+
element.each_recursive {|x| apply_style x, style}
|
49
52
|
end
|
50
53
|
|
51
54
|
end
|
@@ -53,15 +56,19 @@ class CSSLite
|
|
53
56
|
|
54
57
|
end
|
55
58
|
|
56
|
-
private
|
57
|
-
|
59
|
+
private
|
58
60
|
|
59
|
-
def apply_style(e,
|
61
|
+
def apply_style(e, new_h)
|
62
|
+
|
63
|
+
h = e.style.to_h
|
64
|
+
puts 'h: ' + h.inspect if @debug
|
65
|
+
|
66
|
+
puts 'new_h: ' + new_h.inspect if @debug
|
67
|
+
@override ? h.merge!(new_h) : h = new_h.merge(h)
|
60
68
|
|
61
|
-
|
62
|
-
|
63
|
-
e.style[k] = v unless @elements[id].has_key? k
|
69
|
+
puts 'after h: ' + h.inspect if @debug
|
70
|
+
e.attributes[:style] = h.map{|x| x.join(':') }.join(';')
|
64
71
|
|
65
72
|
end
|
66
73
|
|
67
|
-
end
|
74
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csslite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,28 +10,32 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
13
|
+
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjAwNTExMTk0ODI0WhcN
|
15
|
+
MjEwNTExMTk0ODI0WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDFKxHs
|
17
|
+
eTyRdKNJyaJnaufcwasm9wkYzzcxdk9wYWkQiC10SvWInPPpHVBOkIzqb0QI417k
|
18
|
+
NR5tNPgn8AehCVCpiBGpRhigwK9IdsVSvLVHJGMWQIANlmnaUv989BbSyV3fiHB9
|
19
|
+
TwtADE3h/bxOP7JKBrbz7g56LzJT5ow3b5bcUCFXEAsjssGEaja+Hwv0q+2bbCEK
|
20
|
+
3LuoIxn0ml/dxEw7sHdi4A/uCS/ps3kFzZ6aGRhT/z/dOkiBiRQKR6mUEcZBBFeK
|
21
|
+
he7eCOTJBq4yh8ayD2gvMdc+iOEWGMvbV2AsOSd4gGZ/zQpqe4/slsjj5F6LPZXd
|
22
|
+
FI3FztVR1QeLBGNkZRaXwdeK7mNG3XHayXywFSowyHnZAVfqvXtOcpk3ibqTiR/x
|
23
|
+
vgoCbO1fZVQv3JMXjYK8d9RpOPUHV5/s0ejZysz2BYacxnqsssjYMbf2yY+FVDQV
|
24
|
+
Nq1DqspMniHtFcGigeYY/iTZsOu7R5YUk/mDHrUjFZWJ7zJVLU4nQLIcrHECAwEA
|
25
|
+
AaOBijCBhzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUtG5uG4wj
|
26
|
+
gKFqPnAYfcWzgzmxI9MwJgYDVR0RBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
|
27
|
+
c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
|
28
|
+
BgkqhkiG9w0BAQsFAAOCAYEAVS28hJd9kdfN2PItppseANDv+36ZyzHj0ivYxb41
|
29
|
+
NHcpDeuT4TnjZemU9D1n8/cKfU0D5doQGC1tVtBPAULR5uHsw3kuYaf45edJy6jb
|
30
|
+
H82sQCyT2yMHCHIY6F/tAax2mk4CbDiWk0ycjCwnSc4zJ+Pk4r6Vnuq31udo34NA
|
31
|
+
A4OX8bWhB18kD5ntjw8xHoGWjJhJB8iXd1xgl+AseanborvB5q5Yo6kPneA7bpTX
|
32
|
+
BBegCtLupn+c+UNAE8YjokR7teUr+ARReHWu2eC5WPQPSpT60lyIBHQy2VozhIXo
|
33
|
+
u/RHxOlr//ZBtZ9gXo4ERx0RezNeP/ex31yCy9eFvF6jZ8wAE2rklsQCG5GyPd7x
|
34
|
+
A70HZWApuAAJ4E8rOXr5bbYAyMiLehwJbByu7UNjWm20Boi205jWFc43k5claMPN
|
35
|
+
T2RwjhAnWqdUfU1ddLSGXfvZc5losV0GOxqUDXg1chnBLh6mm5IkSTp+PZaT3H7d
|
36
|
+
KosATF+mCCLwHG4CZS33JUkx
|
33
37
|
-----END CERTIFICATE-----
|
34
|
-
date:
|
38
|
+
date: 2020-05-11 00:00:00.000000000 Z
|
35
39
|
dependencies: []
|
36
40
|
description:
|
37
41
|
email: james@jamesrobertson.eu
|
@@ -59,8 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
63
|
- !ruby/object:Gem::Version
|
60
64
|
version: '0'
|
61
65
|
requirements: []
|
62
|
-
|
63
|
-
rubygems_version: 2.6.8
|
66
|
+
rubygems_version: 3.0.3
|
64
67
|
signing_key:
|
65
68
|
specification_version: 4
|
66
69
|
summary: An experimental gem to parse CSS and propagate the style attributes for the
|
metadata.gz.sig
CHANGED
Binary file
|