css_parser 1.10.0 → 1.12.0
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 +3 -0
- data/lib/css_parser/rule_set.rb +9 -8
- data/lib/css_parser/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c20c504cf408fbaf9e5579e3011c485c9e1a7cb0eddc421b9bfc83bf91a9b2c
|
4
|
+
data.tar.gz: 416f126ad73ba30e3754db0e5af9519c416546fadb33c904a98c1bbf4a594f92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c963b193f920250c1f0ee217194720f5865a2a9d7724e7f34b7d8a054fbef78382732d69f22a3a16a320d3f162f14fa0b284fbe9fba9edcbf45d22547594cb07
|
7
|
+
data.tar.gz: afc7f111ffc2e4a42c9c6be5f7e3eb2b52239f7057d0e462ff731e45e5af2d9e6ea05aa7fcb62563538c048225cc8e8f9a8c674fa633fa234e432d8e741bd26a
|
data/lib/css_parser/parser.rb
CHANGED
@@ -39,6 +39,7 @@ module CssParser
|
|
39
39
|
@options = {absolute_paths: false,
|
40
40
|
import: true,
|
41
41
|
io_exceptions: true,
|
42
|
+
rule_set_exceptions: true,
|
42
43
|
capture_offsets: false}.merge(options)
|
43
44
|
|
44
45
|
# array of RuleSets
|
@@ -167,6 +168,8 @@ module CssParser
|
|
167
168
|
def add_rule!(selectors, declarations, media_types = :all)
|
168
169
|
rule_set = RuleSet.new(selectors, declarations)
|
169
170
|
add_rule_set!(rule_set, media_types)
|
171
|
+
rescue ArgumentError => e
|
172
|
+
raise e if @options[:rule_set_exceptions]
|
170
173
|
end
|
171
174
|
|
172
175
|
# Add a CSS rule by setting the +selectors+, +declarations+, +filename+, +offset+ and +media_types+.
|
data/lib/css_parser/rule_set.rb
CHANGED
@@ -93,6 +93,8 @@ module CssParser
|
|
93
93
|
else
|
94
94
|
declarations[property] = Value.new(value)
|
95
95
|
end
|
96
|
+
rescue ArgumentError => e
|
97
|
+
raise e.exception, "#{property} #{e.message}"
|
96
98
|
end
|
97
99
|
alias add_declaration! []=
|
98
100
|
|
@@ -511,23 +513,22 @@ module CssParser
|
|
511
513
|
#
|
512
514
|
# TODO: this is extremely similar to create_background_shorthand! and should be combined
|
513
515
|
def create_border_shorthand! # :nodoc:
|
514
|
-
values =
|
515
|
-
|
516
|
-
BORDER_STYLE_PROPERTIES.each do |property|
|
516
|
+
values = BORDER_STYLE_PROPERTIES.map do |property|
|
517
517
|
next unless (declaration = declarations[property])
|
518
518
|
next if declaration.important
|
519
|
-
|
520
519
|
# can't merge if any value contains a space (i.e. has multiple values)
|
521
520
|
# we temporarily remove any spaces after commas for the check (inside rgba, etc...)
|
522
|
-
|
521
|
+
next if declaration.value.gsub(/,\s/, ',').strip =~ /\s/
|
523
522
|
|
524
|
-
|
523
|
+
declaration.value
|
524
|
+
end.compact
|
525
|
+
|
526
|
+
return if values.size != BORDER_STYLE_PROPERTIES.size
|
525
527
|
|
528
|
+
BORDER_STYLE_PROPERTIES.each do |property|
|
526
529
|
declarations.delete(property)
|
527
530
|
end
|
528
531
|
|
529
|
-
return if values.empty?
|
530
|
-
|
531
532
|
declarations['border'] = values.join(' ')
|
532
533
|
end
|
533
534
|
|
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
|
+
version: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Dunae
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
170
|
- !ruby/object:Gem::Version
|
171
171
|
version: '0'
|
172
172
|
requirements: []
|
173
|
-
rubygems_version: 3.
|
173
|
+
rubygems_version: 3.1.6
|
174
174
|
signing_key:
|
175
175
|
specification_version: 4
|
176
176
|
summary: Ruby CSS parser.
|