css_parser 1.16.0 → 1.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/css_parser/parser.rb +10 -8
- data/lib/css_parser/version.rb +1 -1
- data/lib/css_parser.rb +3 -3
- metadata +6 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6f2b7e6abc1f1bea049098d58fd072a7a17985203d25eb87fe9a62e3d3329bc3
|
|
4
|
+
data.tar.gz: ebb09d74054507e148544ad150cd8e3470a0601b736f9708bae567d26c08794c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4ac7f707b7394d57bef2dea84887b07239cc446b15e5c4d49f3097b311950a95c7816e2b3acc81842570a827f3eb959d8d0081f974b92d9b97f4772cb9c312bd
|
|
7
|
+
data.tar.gz: a52877e078998a7d4b47938db8f41d67c2fc2a293a609e78efc54d9fbf403bae3cff8bb5145765b518d19d1a86177ae09eb44b6d8bdbafc07bcadd51672a94d1
|
data/lib/css_parser/parser.rb
CHANGED
|
@@ -17,7 +17,6 @@ module CssParser
|
|
|
17
17
|
# [<tt>io_exceptions</tt>] Throw an exception if a link can not be found. Boolean, default is <tt>true</tt>.
|
|
18
18
|
class Parser
|
|
19
19
|
USER_AGENT = "Ruby CSS Parser/#{CssParser::VERSION} (https://github.com/premailer/css_parser)"
|
|
20
|
-
|
|
21
20
|
STRIP_CSS_COMMENTS_RX = %r{/\*.*?\*/}m.freeze
|
|
22
21
|
STRIP_HTML_COMMENTS_RX = /<!--|-->/m.freeze
|
|
23
22
|
|
|
@@ -36,11 +35,14 @@ module CssParser
|
|
|
36
35
|
class << self; attr_reader :folded_declaration_cache; end
|
|
37
36
|
|
|
38
37
|
def initialize(options = {})
|
|
39
|
-
@options = {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
@options = {
|
|
39
|
+
absolute_paths: false,
|
|
40
|
+
import: true,
|
|
41
|
+
io_exceptions: true,
|
|
42
|
+
rule_set_exceptions: true,
|
|
43
|
+
capture_offsets: false,
|
|
44
|
+
user_agent: USER_AGENT
|
|
45
|
+
}.merge(options)
|
|
44
46
|
|
|
45
47
|
# array of RuleSets
|
|
46
48
|
@rules = []
|
|
@@ -484,7 +486,7 @@ module CssParser
|
|
|
484
486
|
return unless File.readable?(file_name)
|
|
485
487
|
return unless circular_reference_check(file_name)
|
|
486
488
|
|
|
487
|
-
src =
|
|
489
|
+
src = File.read(file_name)
|
|
488
490
|
|
|
489
491
|
opts[:filename] = file_name if opts[:capture_offsets]
|
|
490
492
|
opts[:base_dir] = File.dirname(file_name)
|
|
@@ -597,7 +599,7 @@ module CssParser
|
|
|
597
599
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
598
600
|
end
|
|
599
601
|
|
|
600
|
-
res = http.get(uri.request_uri, {'User-Agent' =>
|
|
602
|
+
res = http.get(uri.request_uri, {'User-Agent' => @options[:user_agent], 'Accept-Encoding' => 'gzip'})
|
|
601
603
|
src = res.body
|
|
602
604
|
charset = res.respond_to?(:charset) ? res.encoding : 'utf-8'
|
|
603
605
|
|
data/lib/css_parser/version.rb
CHANGED
data/lib/css_parser.rb
CHANGED
|
@@ -75,13 +75,13 @@ module CssParser
|
|
|
75
75
|
|
|
76
76
|
rule_set.each_declaration do |property, value, is_important|
|
|
77
77
|
# Add the property to the list to be folded per http://www.w3.org/TR/CSS21/cascade.html#cascading-order
|
|
78
|
-
if
|
|
78
|
+
if !properties.key?(property)
|
|
79
79
|
properties[property] = {value: value, specificity: specificity, is_important: is_important}
|
|
80
80
|
elsif is_important
|
|
81
|
-
if
|
|
81
|
+
if !properties[property][:is_important] || properties[property][:specificity] <= specificity
|
|
82
82
|
properties[property] = {value: value, specificity: specificity, is_important: is_important}
|
|
83
83
|
end
|
|
84
|
-
elsif properties[property][:specificity] < specificity
|
|
84
|
+
elsif properties[property][:specificity] < specificity || properties[property][:specificity] == specificity
|
|
85
85
|
unless properties[property][:is_important]
|
|
86
86
|
properties[property] = {value: value, specificity: specificity, is_important: is_important}
|
|
87
87
|
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.
|
|
4
|
+
version: 1.17.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alex Dunae
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2024-04-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: addressable
|
|
@@ -155,7 +155,8 @@ metadata:
|
|
|
155
155
|
changelog_uri: https://github.com/premailer/css_parser/blob/master/CHANGELOG.md
|
|
156
156
|
source_code_uri: https://github.com/premailer/css_parser
|
|
157
157
|
bug_tracker_uri: https://github.com/premailer/css_parser/issues
|
|
158
|
-
|
|
158
|
+
rubygems_mfa_required: 'true'
|
|
159
|
+
post_install_message:
|
|
159
160
|
rdoc_options: []
|
|
160
161
|
require_paths:
|
|
161
162
|
- lib
|
|
@@ -171,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
171
172
|
version: '0'
|
|
172
173
|
requirements: []
|
|
173
174
|
rubygems_version: 3.1.6
|
|
174
|
-
signing_key:
|
|
175
|
+
signing_key:
|
|
175
176
|
specification_version: 4
|
|
176
177
|
summary: Ruby CSS parser.
|
|
177
178
|
test_files: []
|