Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #150

Merged
merged 6 commits into from Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .rubocop.yml
@@ -1,3 +1,6 @@
require:
- rubocop-rake

AllCops:
TargetRubyVersion: 2.7 # lowest supported version
NewCops: enable
Expand Down Expand Up @@ -53,6 +56,10 @@ Style/Not:
Style/NumericPredicate:
Enabled: false

Style/OpenStructUse:
Exclude:
- 'test/**/*'

Style/RedundantFreeze:
Enabled: false

Expand Down
9 changes: 9 additions & 0 deletions Gemfile
Expand Up @@ -5,3 +5,12 @@
source 'https://rubygems.org'

gemspec

gem 'benchmark-ips'
gem 'bump'
gem 'maxitest'
gem 'memory_profiler'
gem 'rake'
gem 'rubocop'
gem 'rubocop-rake'
gem 'webrick'
60 changes: 34 additions & 26 deletions Gemfile.lock
Expand Up @@ -9,37 +9,45 @@ GEM
specs:
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.1)
benchmark-ips (2.8.4)
ast (2.4.2)
benchmark-ips (2.13.0)
bump (0.10.0)
maxitest (3.6.0)
minitest (>= 5.0.0, < 5.14.0)
memory_profiler (1.0.0)
minitest (5.12.0)
parallel (1.20.1)
parser (3.0.0.0)
json (2.7.2)
json (2.7.2-java)
language_server-protocol (3.17.0.3)
maxitest (4.5.0)
minitest (>= 5.0.0, < 5.19.0)
memory_profiler (1.0.1)
minitest (5.18.1)
parallel (1.24.0)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
public_suffix (5.0.5)
rainbow (3.0.0)
rake (13.0.3)
regexp_parser (2.0.3)
rexml (3.2.4)
rubocop (1.8.0)
racc (1.7.3)
racc (1.7.3-java)
rainbow (3.1.1)
rake (13.2.1)
regexp_parser (2.9.0)
rexml (3.2.6)
rubocop (1.62.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.2.0, < 2.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.4.0)
parser (>= 2.7.1.5)
rubocop-rake (0.5.1)
rubocop
ruby-progressbar (1.11.0)
unicode-display_width (2.0.0)
webrick (1.7.0)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.2)
parser (>= 3.3.0.4)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
ruby-progressbar (1.13.0)
unicode-display_width (2.5.0)
webrick (1.8.1)

PLATFORMS
java
Expand All @@ -52,9 +60,9 @@ DEPENDENCIES
maxitest
memory_profiler
rake
rubocop (~> 1.8)
rubocop
rubocop-rake
webrick

BUNDLED WITH
2.1.4
2.4.12
9 changes: 0 additions & 9 deletions css_parser.gemspec
Expand Up @@ -19,13 +19,4 @@ Gem::Specification.new name, CssParser::VERSION do |s|
s.metadata['rubygems_mfa_required'] = 'true'

s.add_runtime_dependency 'addressable'

s.add_development_dependency 'benchmark-ips'
s.add_development_dependency 'bump'
s.add_development_dependency 'maxitest'
s.add_development_dependency 'memory_profiler'
s.add_development_dependency 'rake'
s.add_development_dependency 'rubocop', '~> 1.8'
s.add_development_dependency 'rubocop-rake'
s.add_development_dependency 'webrick'
end
2 changes: 1 addition & 1 deletion lib/css_parser.rb
Expand Up @@ -111,7 +111,7 @@ def self.merge(*rule_sets)
#++
def self.calculate_specificity(selector)
a = 0
b = selector.scan(/\#/).length
b = selector.scan('#').length
c = selector.scan(NON_ID_ATTRIBUTES_AND_PSEUDO_CLASSES_RX_NC).length
d = selector.scan(ELEMENTS_AND_PSEUDO_ELEMENTS_RX_NC).length

Expand Down
2 changes: 1 addition & 1 deletion lib/css_parser/parser.rb
Expand Up @@ -133,7 +133,7 @@ def add_block!(block, options = {})
block.scan(RE_AT_IMPORT_RULE).each do |import_rule|
media_types = []
if (media_string = import_rule[-1])
media_string.split(/,/).each do |t|
media_string.split(',').each do |t|
media_types << CssParser.sanitize_media_query(t) unless t.empty?
end
else
Expand Down
2 changes: 1 addition & 1 deletion lib/css_parser/regexps.rb
Expand Up @@ -11,7 +11,7 @@ def self.regex_possible_values(*values)
RE_NON_ASCII = Regexp.new('([\x00-\xFF])', Regexp::IGNORECASE | Regexp::NOENCODING) # [^\0-\177]
RE_UNICODE = Regexp.new('(\\\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])*)', Regexp::IGNORECASE | Regexp::EXTENDED | Regexp::MULTILINE | Regexp::NOENCODING)
RE_ESCAPE = Regexp.union(RE_UNICODE, '|(\\\\[^\n\r\f0-9a-f])')
RE_IDENT = Regexp.new("[\-]?([_a-z]|#{RE_NON_ASCII}|#{RE_ESCAPE})([_a-z0-9\-]|#{RE_NON_ASCII}|#{RE_ESCAPE})*", Regexp::IGNORECASE | Regexp::NOENCODING)
RE_IDENT = Regexp.new("[-]?([_a-z]|#{RE_NON_ASCII}|#{RE_ESCAPE})([_a-z0-9-]|#{RE_NON_ASCII}|#{RE_ESCAPE})*", Regexp::IGNORECASE | Regexp::NOENCODING)

# General strings
RE_STRING1 = /("(.[^\n\r\f"]*|\\#{RE_NL}|#{RE_ESCAPE})*")/.freeze
Expand Down
8 changes: 4 additions & 4 deletions lib/css_parser/rule_set.rb
Expand Up @@ -58,7 +58,7 @@ def ==(other)

extend Forwardable

def_delegators :declarations, :each
def_delegators :declarations, :each, :each_value

def initialize(declarations = {})
self.declarations = {}
Expand Down Expand Up @@ -142,7 +142,7 @@ def replace_declaration!(property, replacements, preserve_importance: false)

if preserve_importance
importance = get_value(property).important
replacement_declarations.each { |_key, value| value.important = importance }
replacement_declarations.each_value { |value| value.important = importance }
tagliala marked this conversation as resolved.
Show resolved Hide resolved
end

replacement_keys = declarations.keys
Expand Down Expand Up @@ -308,7 +308,7 @@ def expand_background_shorthand! # :nodoc:

replacement =
if value.match(CssParser::RE_INHERIT)
BACKGROUND_PROPERTIES.map { |key| [key, 'inherit'] }.to_h
BACKGROUND_PROPERTIES.to_h { |key| [key, 'inherit'] }
else
{
'background-image' => value.slice!(CssParser::RE_IMAGE),
Expand Down Expand Up @@ -448,7 +448,7 @@ def expand_list_style_shorthand! # :nodoc:

replacement =
if value =~ CssParser::RE_INHERIT
LIST_STYLE_PROPERTIES.map { |key| [key, 'inherit'] }.to_h
LIST_STYLE_PROPERTIES.to_h { |key| [key, 'inherit'] }
else
{
'list-style-type' => value.slice!(CssParser::RE_LIST_STYLE_TYPE),
Expand Down
2 changes: 1 addition & 1 deletion test/rule_set/test_declarations.rb
Expand Up @@ -167,7 +167,7 @@ class RuleSetDeclarationsTest < Minitest::Test
declarations = CssParser::RuleSet::Declarations.new({foo: 'foo value'})
assert_equal 1, declarations.size

declarations.remove_declaration!('fOo'.to_sym)
declarations.remove_declaration!(:fOo)

assert_equal 0, declarations.size
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_css_parser_media_types.rb
Expand Up @@ -43,7 +43,7 @@ def test_finding_by_media_type

assert_equal 'font-size: 10pt; line-height: 1.2;', @cp.find_by_selector('body', :print).join(' ')
assert_equal 'font-size: 13px; line-height: 1.2; color: blue;', @cp.find_by_selector('body', :screen).join(' ')
assert_equal 'color: blue;', @cp.find_by_selector('body', 'print and resolution > 90dpi'.to_sym).join(' ')
assert_equal 'color: blue;', @cp.find_by_selector('body', :'print and resolution > 90dpi').join(' ')
end

def test_with_parenthesized_media_features
Expand Down
5 changes: 2 additions & 3 deletions test/test_css_parser_misc.rb
Expand Up @@ -79,7 +79,7 @@ def test_parsing_blocks
\
foo(int x) {\
this.x = 'test';\
this.x = \"test\";\
this.x = "test";\
}\
\
}"] { color: red }
Expand Down Expand Up @@ -127,8 +127,7 @@ def test_multiline_declarations
@cp.each_selector do |selector, declarations, _spec|
assert_equal '@font-face', selector
assert_equal "font-family: 'some_font'; " \
"src: url(https://example.com/font.woff2) format('woff2')," \
"url(https://example.com/font.woff) format('woff'); " \
"src: url(https://example.com/font.woff2) format('woff2'),url(https://example.com/font.woff) format('woff'); " \
"font-style: normal;", declarations
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_rule_set.rb
Expand Up @@ -73,7 +73,7 @@ def test_each_declaration_respects_order

def test_each_declaration_containing_semicolons
rs = RuleSet.new(nil, "background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAiCAMAAAB7);" \
"background-repeat: no-repeat")
"background-repeat: no-repeat")
assert_equal('url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAiCAMAAAB7);', rs['background-image'])
assert_equal('no-repeat;', rs['background-repeat'])
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_rule_set_creating_shorthand.rb
Expand Up @@ -219,7 +219,7 @@ def test_a_single_property_is_not_shorted
protected

def assert_properties_are_deleted(ruleset, properties)
properties.each do |property, _value|
properties.each_key do |property|
assert_equal '', ruleset[property]
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_rule_set_expanding_shorthand.rb
Expand Up @@ -247,7 +247,7 @@ def test_getting_list_style_properties_from_shorthand
'list-style-position' => 'inside'
}

shorthand = "list-style: katakana inside url(\'chess.png\');"
shorthand = "list-style: katakana inside url('chess.png');"
declarations = expand_declarations(shorthand)
assert_equal expected, declarations
end
Expand Down