css_parser 1.4.8 → 1.4.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/css_parser/parser.rb +7 -7
- data/lib/css_parser/regexps.rb +2 -2
- data/lib/css_parser/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e52722a5c36a9f9c005952eec5a578dea6b0bcab
|
4
|
+
data.tar.gz: 7402ed19b5d47e7eaee3de93fd40b5f0919d040c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bb6fe5419e7eed4020270f70450fad376f21d950974b0bdc24625f0073221a304fa01ca73f628504d7cfa4fbbbf6eb683fe9855e46c362e337ed2db701fb265
|
7
|
+
data.tar.gz: 659b96cce569d009fe41c00073f05c214afb278c8e4fc2834c8b05cd5af8f1fd1477f52e065b8de96e8148931f8fd4b5f44f5c53dc376bf27db5608cb690bd25
|
data/lib/css_parser/parser.rb
CHANGED
@@ -20,7 +20,7 @@ module CssParser
|
|
20
20
|
STRIP_HTML_COMMENTS_RX = /\<\!\-\-|\-\-\>/m
|
21
21
|
|
22
22
|
# Initial parsing
|
23
|
-
RE_AT_IMPORT_RULE = /\@import\s*(?:url\s*)?(?:\()?(?:\s*)["']?([^'"\s\)]*)["']?\)?([\w\s\,^\]\(\)
|
23
|
+
RE_AT_IMPORT_RULE = /\@import\s*(?:url\s*)?(?:\()?(?:\s*)["']?([^'"\s\)]*)["']?\)?([\w\s\,^\]\(\)]*)\)?[;\n]?/
|
24
24
|
|
25
25
|
MAX_REDIRECTS = 3
|
26
26
|
|
@@ -188,10 +188,10 @@ module CssParser
|
|
188
188
|
end
|
189
189
|
|
190
190
|
# Output all CSS rules as a Hash
|
191
|
-
def to_h(
|
191
|
+
def to_h(which_media = :all)
|
192
192
|
out = {}
|
193
193
|
styles_by_media_types = {}
|
194
|
-
each_selector(
|
194
|
+
each_selector(which_media) do |selectors, declarations, specificity, media_types|
|
195
195
|
media_types.each do |media_type|
|
196
196
|
styles_by_media_types[media_type] ||= []
|
197
197
|
styles_by_media_types[media_type] << [selectors, declarations]
|
@@ -221,10 +221,10 @@ module CssParser
|
|
221
221
|
end
|
222
222
|
|
223
223
|
# Output all CSS rules as a single stylesheet.
|
224
|
-
def to_s(
|
224
|
+
def to_s(which_media = :all)
|
225
225
|
out = ''
|
226
226
|
styles_by_media_types = {}
|
227
|
-
each_selector(
|
227
|
+
each_selector(which_media) do |selectors, declarations, specificity, media_types|
|
228
228
|
media_types.each do |media_type|
|
229
229
|
styles_by_media_types[media_type] ||= []
|
230
230
|
styles_by_media_types[media_type] << [selectors, declarations]
|
@@ -511,8 +511,8 @@ module CssParser
|
|
511
511
|
raise RemoteFileError if @options[:io_exceptions]
|
512
512
|
return '', nil
|
513
513
|
elsif res.code.to_i >= 300 and res.code.to_i < 400
|
514
|
-
if res
|
515
|
-
return read_remote_file Addressable::URI.parse(URI.escape(res
|
514
|
+
if res['Location'] != nil
|
515
|
+
return read_remote_file Addressable::URI.parse(Addressable::URI.escape(res['Location']))
|
516
516
|
end
|
517
517
|
end
|
518
518
|
|
data/lib/css_parser/regexps.rb
CHANGED
@@ -23,7 +23,7 @@ module CssParser
|
|
23
23
|
RE_GRADIENT = /[-a-z]*gradient\([-a-z0-9 .,#%()]*\)/im
|
24
24
|
|
25
25
|
# Initial parsing
|
26
|
-
RE_AT_IMPORT_RULE = /\@import
|
26
|
+
RE_AT_IMPORT_RULE = /\@import\s+(url\()?["']?(.[^'"\s]*)["']?\)?([\w\s\,^\])]*)\)?;?/
|
27
27
|
|
28
28
|
#--
|
29
29
|
#RE_AT_MEDIA_RULE = Regexp.new('(\"(.[^\n\r\f\\"]*|\\\\' + RE_NL.to_s + '|' + RE_ESCAPE.to_s + ')*\")')
|
@@ -44,7 +44,7 @@ module CssParser
|
|
44
44
|
STRIP_HTML_COMMENTS_RX = /\<\!\-\-|\-\-\>/m
|
45
45
|
|
46
46
|
# Special units
|
47
|
-
BOX_MODEL_UNITS_RX = /(auto|inherit|0|([\-]*([0-9]+|[0-9]*\.[0-9]+)(e[mx]+|px|[cm]+m|p[tc+]|in|\%)))([\s;]|\Z)/imx
|
47
|
+
BOX_MODEL_UNITS_RX = /(auto|inherit|0|([\-]*([0-9]+|[0-9]*\.[0-9]+)(rem|vw|vh|vm|vmin|vmax|e[mx]+|px|[cm]+m|p[tc+]|in|\%)))([\s;]|\Z)/imx
|
48
48
|
RE_LENGTH_OR_PERCENTAGE = Regexp.new('([\-]*(([0-9]*\.[0-9]+)|[0-9]+)(e[mx]+|px|[cm]+m|p[tc+]|in|\%))', Regexp::IGNORECASE)
|
49
49
|
RE_BACKGROUND_POSITION = Regexp.new("((((#{RE_LENGTH_OR_PERCENTAGE})|left|center|right|top|bottom)[\s]*){1,2})", Regexp::IGNORECASE | Regexp::EXTENDED)
|
50
50
|
RE_BACKGROUND_SIZE = Regexp.new("\\s*/\\s*((((#{RE_LENGTH_OR_PERCENTAGE})|auto|cover|contain|initial|inherit)[\\s]*){1,2})", Regexp::IGNORECASE | Regexp::EXTENDED)
|
data/lib/css_parser/version.rb
CHANGED
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.4.
|
4
|
+
version: 1.4.9
|
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-02-
|
11
|
+
date: 2017-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|