csslite 0.1.3 → 0.1.4

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 +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/csslite.rb +27 -20
  5. metadata +27 -24
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7fb82c1cfd6d8794f652310cfb81ab840e513644
4
- data.tar.gz: 15ff90c9f4011b68b2b4051e5b12f05023d3aaa1
2
+ SHA256:
3
+ metadata.gz: 23ee4f1fbc6c7aed763a4bc53742b7aa32d1a40bb2986bd00e600ecccb07da77
4
+ data.tar.gz: 5179cff8f4018365562a21860e7bbff942fd99bf0176409706ce1c6c4f3dc5a5
5
5
  SHA512:
6
- metadata.gz: 3621c4f457fb16582d4b9556eea03d1a0009b86f6f407c4efe8769959093510d9b277890f91867d86b9b151679ee500fb66758f765ea9ef127019c3a43e2426b
7
- data.tar.gz: e836886bb33ebd1ce7c2b12c42cce3e1e8801c92101d895e46faa297ef8f044b27517016fd0262c6d4a43814ebc38905e0d81ec9fd2c470678040f01d169e629
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
- @elements = {}
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
- style.each do |k,v|
41
-
42
- root_element.css(selector).each do |element|
43
-
44
- apply_style element, k, v
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, k, v)
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
- id = e.object_id
62
- @elements[id] = e.style.to_h unless @elements.has_key? id
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.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,28 +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 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: 2017-09-10 00:00:00.000000000 Z
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
- rubyforge_project:
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