css_parser 1.16.0 → 1.17.1

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: 6f2b7e6abc1f1bea049098d58fd072a7a17985203d25eb87fe9a62e3d3329bc3
4
+ data.tar.gz: ebb09d74054507e148544ad150cd8e3470a0601b736f9708bae567d26c08794c
5
5
  SHA512:
6
- metadata.gz: ba19471cdbeed2daf719a2e1b238bff145bd748abbc760b64cd5ba40ba3e0ed03de8f6550b44b114bcbdbd577cd415b8f5c609def6c53a25699d3ca71f6e06d7
7
- data.tar.gz: 72d71760da086f403c0d404c97d6bd6476e330376b56ce91b8ebfc51cdd27fc89932a066397b38799c15fb9f9a8a8b625d30728656dc0e8cfc24ec61a168e8e7
6
+ metadata.gz: 4ac7f707b7394d57bef2dea84887b07239cc446b15e5c4d49f3097b311950a95c7816e2b3acc81842570a827f3eb959d8d0081f974b92d9b97f4772cb9c312bd
7
+ data.tar.gz: a52877e078998a7d4b47938db8f41d67c2fc2a293a609e78efc54d9fbf403bae3cff8bb5145765b518d19d1a86177ae09eb44b6d8bdbafc07bcadd51672a94d1
@@ -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 = []
@@ -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 = IO.read(file_name)
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' => 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.1'.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.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: 2023-09-01 00:00:00.000000000 Z
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
- post_install_message:
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: []