css_parser 1.5.0.pre → 1.5.0.pre2

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: 842917dce4f3455e696297fb182f1b1783ac3a5a
4
- data.tar.gz: ef48928b85b441a68fe9b10e3947643f90a147ec
3
+ metadata.gz: bcad7a186fec9e364d7b615e821fad091db568cc
4
+ data.tar.gz: 4b0c9be7d82bf15144bda6bf09e1a0b328d7a5d0
5
5
  SHA512:
6
- metadata.gz: 01d11dfbc01781b5ca23598800f53062211f0d7b06074683720ca11354d85d7ea2e9cb2624bfc97265e6ee89ee3c28edb95d02361512a1407c77bd9c8b54d381
7
- data.tar.gz: 194c4de30884cc386108ffee89cd1c0426ce4ae2bcfb467515c3fc1ff19dd387680a19306c7ace0f24854adef85846f0eeeca8a01651602c3e744a38cf72ca61
6
+ metadata.gz: d5a2a1d8f77eb1dc9ed16d03bf6141385238d3c3fb774b9352df83d49a6c64881ba26226d8d5ff88af68130c503fef4164a44f0a0a0aa0662911659b1f1ae877
7
+ data.tar.gz: 451dd77df3050fe539cc7098da6ba7f07b25fe977eae29d579f3ce55f85c7e72cfe9b45f25bf93d588f97e291ad2c0b6c553782980a9032ad22566f712a7bc9c
@@ -189,6 +189,19 @@ module CssParser
189
189
  @rules << {:media_types => media_types, :rules => ruleset}
190
190
  end
191
191
 
192
+ # Remove a CssParser RuleSet object.
193
+ #
194
+ # +media_types+ can be a symbol or an array of symbols.
195
+ def remove_rule_set!(ruleset, media_types = :all)
196
+ raise ArgumentError unless ruleset.kind_of?(CssParser::RuleSet)
197
+
198
+ media_types = [media_types].flatten.collect { |mt| CssParser.sanitize_media_query(mt)}
199
+
200
+ @rules.reject! do |rule|
201
+ rule[:media_types] == media_types && rule[:rules].to_s == ruleset.to_s
202
+ end
203
+ end
204
+
192
205
  # Iterate through RuleSet objects.
193
206
  #
194
207
  # +media_types+ can be a symbol or an array of symbols.
@@ -83,10 +83,163 @@ module CssParser
83
83
  )/ix
84
84
 
85
85
  # Colours
86
- RE_COLOUR_NUMERIC = Regexp.new('((hsl|rgb)[\s]*\([\s-]*[\d]+(\.[\d]+)?[%\s]*,[\s-]*[\d]+(\.[\d]+)?[%\s]*,[\s-]*[\d]+(\.[\d]+)?[%\s]*\))', Regexp::IGNORECASE)
87
- RE_COLOUR_NUMERIC_ALPHA = Regexp.new('((hsla|rgba)[\s]*\([\s-]*[\d]+(\.[\d]+)?[%\s]*,[\s-]*[\d]+(\.[\d]+)?[%\s]*,[\s-]*[\d]+(\.[\d]+)?[%\s]*,[\s-]*[\d]+(\.[\d]+)?[%\s]*\))', Regexp::IGNORECASE)
88
- RE_COLOUR_HEX = /(#([0-9a-f]{6}|[0-9a-f]{3})([\s;]|$))/i
89
- RE_COLOUR_NAMED = /([\s]*^)?(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|transparent)([\s]*$)?/i
86
+ NAMED_COLOURS = %w[
87
+ aliceblue
88
+ antiquewhite
89
+ aqua
90
+ aquamarine
91
+ azure
92
+ beige
93
+ bisque
94
+ black
95
+ blanchedalmond
96
+ blue
97
+ blueviolet
98
+ brown
99
+ burlywood
100
+ cadetblue
101
+ chartreuse
102
+ chocolate
103
+ coral
104
+ cornflowerblue
105
+ cornsilk
106
+ crimson
107
+ cyan
108
+ darkblue
109
+ darkcyan
110
+ darkgoldenrod
111
+ darkgray
112
+ darkgreen
113
+ darkgrey
114
+ darkkhaki
115
+ darkmagenta
116
+ darkolivegreen
117
+ darkorange
118
+ darkorchid
119
+ darkred
120
+ darksalmon
121
+ darkseagreen
122
+ darkslateblue
123
+ darkslategray
124
+ darkslategrey
125
+ darkturquoise
126
+ darkviolet
127
+ deeppink
128
+ deepskyblue
129
+ dimgray
130
+ dimgrey
131
+ dodgerblue
132
+ firebrick
133
+ floralwhite
134
+ forestgreen
135
+ fuchsia
136
+ gainsboro
137
+ ghostwhite
138
+ gold
139
+ goldenrod
140
+ gray
141
+ green
142
+ greenyellow
143
+ grey
144
+ honeydew
145
+ hotpink
146
+ indianred
147
+ indigo
148
+ ivory
149
+ khaki
150
+ lavender
151
+ lavenderblush
152
+ lawngreen
153
+ lemonchiffon
154
+ lightblue
155
+ lightcoral
156
+ lightcyan
157
+ lightgoldenrodyellow
158
+ lightgray
159
+ lightgreen
160
+ lightgrey
161
+ lightpink
162
+ lightsalmon
163
+ lightseagreen
164
+ lightskyblue
165
+ lightslategray
166
+ lightslategrey
167
+ lightsteelblue
168
+ lightyellow
169
+ lime
170
+ limegreen
171
+ linen
172
+ magenta
173
+ maroon
174
+ mediumaquamarine
175
+ mediumblue
176
+ mediumorchid
177
+ mediumpurple
178
+ mediumseagreen
179
+ mediumslateblue
180
+ mediumspringgreen
181
+ mediumturquoise
182
+ mediumvioletred
183
+ midnightblue
184
+ mintcream
185
+ mistyrose
186
+ moccasin
187
+ navajowhite
188
+ navy
189
+ oldlace
190
+ olive
191
+ olivedrab
192
+ orange
193
+ orangered
194
+ orchid
195
+ palegoldenrod
196
+ palegreen
197
+ paleturquoise
198
+ palevioletred
199
+ papayawhip
200
+ peachpuff
201
+ peru
202
+ pink
203
+ plum
204
+ powderblue
205
+ purple
206
+ red
207
+ rosybrown
208
+ royalblue
209
+ saddlebrown
210
+ salmon
211
+ sandybrown
212
+ seagreen
213
+ seashell
214
+ sienna
215
+ silver
216
+ skyblue
217
+ slateblue
218
+ slategray
219
+ slategrey
220
+ snow
221
+ springgreen
222
+ steelblue
223
+ tan
224
+ teal
225
+ thistle
226
+ tomato
227
+ turquoise
228
+ violet
229
+ wheat
230
+ white
231
+ whitesmoke
232
+ yellow
233
+ yellowgreen
234
+
235
+ transparent
236
+ inherit
237
+ currentColor
238
+ ]
239
+ RE_COLOUR_NUMERIC = /\b(hsl|rgb)\s*\(-?\s*-?\d+(\.\d+)?%?\s*%?,-?\s*-?\d+(\.\d+)?%?\s*%?,-?\s*-?\d+(\.\d+)?%?\s*%?\)/i
240
+ RE_COLOUR_NUMERIC_ALPHA = /\b(hsla|rgba)\s*\(-?\s*-?\d+(\.\d+)?%?\s*%?,-?\s*-?\d+(\.\d+)?%?\s*%?,-?\s*-?\d+(\.\d+)?%?\s*%?,-?\s*-?\d+(\.\d+)?%?\s*%?\)/i
241
+ RE_COLOUR_HEX = /\s*#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})\b/
242
+ RE_COLOUR_NAMED = /\s*\b(#{NAMED_COLOURS.join('|')})\b/i
90
243
  RE_COLOUR = Regexp.union(RE_COLOUR_NUMERIC, RE_COLOUR_NUMERIC_ALPHA, RE_COLOUR_HEX, RE_COLOUR_NAMED)
91
244
  # :startdoc:
92
245
  end
@@ -195,9 +195,9 @@ module CssParser
195
195
  # can split easily on spaces.
196
196
  #
197
197
  # TODO: rgba, hsl, hsla
198
- value.gsub!(RE_COLOUR) { |c| c.gsub(/(\s?\,\s?)/, ',') }
198
+ value.gsub!(RE_COLOUR) { |c| c.gsub(/(\s*\,\s*)/, ',') }
199
199
 
200
- matches = value.strip.split(/[\s]+/)
200
+ matches = value.strip.split(/\s+/)
201
201
 
202
202
  t, r, b, l = nil
203
203
 
@@ -1,3 +1,3 @@
1
1
  module CssParser
2
- VERSION = "1.5.0.pre".freeze
2
+ VERSION = "1.5.0.pre2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: css_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0.pre
4
+ version: 1.5.0.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Dunae
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-13 00:00:00.000000000 Z
11
+ date: 2017-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable