css_parser 1.16.0 → 1.17.0

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
  SHA256:
3
- metadata.gz: 36f35091b57e726d3e9b528b6f3357232343c075af962f61a402f2bb111aadd1
4
- data.tar.gz: ee8dbf61a3a6f396e8d383f0334cfee91ad483b192bfbffb4e5c5d9294f89859
3
+ metadata.gz: 47d696725a77d514c0a1ca529dc18e39d41bdd4106a786f21219f14c2ccf43f5
4
+ data.tar.gz: eb6a39b541cfa6bd8c4d66fc4e0adb06310922794b47e582989aba6dd8f5729b
5
5
  SHA512:
6
- metadata.gz: ba19471cdbeed2daf719a2e1b238bff145bd748abbc760b64cd5ba40ba3e0ed03de8f6550b44b114bcbdbd577cd415b8f5c609def6c53a25699d3ca71f6e06d7
7
- data.tar.gz: 72d71760da086f403c0d404c97d6bd6476e330376b56ce91b8ebfc51cdd27fc89932a066397b38799c15fb9f9a8a8b625d30728656dc0e8cfc24ec61a168e8e7
6
+ metadata.gz: db5d0a6cf245796841621194c360c31f5f349596fa00a755152bd109a50707ff5dc301a47601fb09400fa00479e2319a9321f3657c9eb0d5a11b4db7c5d8b048
7
+ data.tar.gz: 7dd50eff88bc656f81928098d736fb7c657ebe6ced0328523cee6e3e778f5b2e7d285311436be6ffd210f8b122467f99dfad739828d43530db41e60a74694b25
@@ -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 = {absolute_paths: false,
40
- import: true,
41
- io_exceptions: true,
42
- rule_set_exceptions: true,
43
- capture_offsets: false}.merge(options)
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 = []
@@ -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' => USER_AGENT, 'Accept-Encoding' => 'gzip'})
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CssParser
4
- VERSION = '1.16.0'.freeze
4
+ VERSION = '1.17.0'.freeze
5
5
  end
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 not properties.key?(property)
78
+ if !properties.key?(property)
79
79
  properties[property] = {value: value, specificity: specificity, is_important: is_important}
80
80
  elsif is_important
81
- if not properties[property][:is_important] or properties[property][:specificity] <= specificity
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 or 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.16.0
4
+ version: 1.17.0
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: 2023-09-01 00:00:00.000000000 Z
11
+ date: 2024-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -155,7 +155,7 @@ 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
- post_install_message:
158
+ post_install_message:
159
159
  rdoc_options: []
160
160
  require_paths:
161
161
  - lib
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  version: '0'
172
172
  requirements: []
173
173
  rubygems_version: 3.1.6
174
- signing_key:
174
+ signing_key:
175
175
  specification_version: 4
176
176
  summary: Ruby CSS parser.
177
177
  test_files: []