From f60752a22aff4d524364988c73ada41719839bf7 Mon Sep 17 00:00:00 2001 From: Michael Grosser Date: Mon, 23 Feb 2026 11:56:23 -0800 Subject: [PATCH] remove eol rubies --- .github/workflows/ci.yml | 4 +- .rubocop.yml | 11 +++- Gemfile | 4 +- Gemfile.lock | 83 +++++++++++++++++------------- css_parser.gemspec | 4 +- lib/css_parser/parser.rb | 5 +- test/rule_set/test_declarations.rb | 11 ++-- test/test_css_parser_misc.rb | 5 +- test/test_helper.rb | 2 + test/test_rule_set.rb | 3 +- 10 files changed, 78 insertions(+), 54 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b97fcea..b1d09e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: ['3.0', '3.1', '3.2', '3.3', '3.4', 'jruby'] + ruby-version: ['3.3', '3.4', 'jruby'] steps: - uses: actions/checkout@v4 @@ -35,7 +35,7 @@ jobs: - uses: ruby/setup-ruby@v1 with: - ruby-version: '3.0' # lowest supported Ruby version + ruby-version: '3.3' # lowest supported Ruby version bundler-cache: true - run: bundle exec rake rubocop diff --git a/.rubocop.yml b/.rubocop.yml index 11c6145..7d06dab 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,7 +3,7 @@ require: - rubocop-rake AllCops: - TargetRubyVersion: 3.0 # lowest supported version + TargetRubyVersion: 3.3 # lowest supported version NewCops: enable Layout/ArgumentAlignment: @@ -79,3 +79,12 @@ Style/WordArray: Style/SymbolArray: EnforcedStyle: brackets + +Style/HashSyntax: + EnforcedShorthandSyntax: never + +Naming/BlockForwarding: + EnforcedStyle: explicit + +Style/CollectionQuerying: + Enabled: false diff --git a/Gemfile b/Gemfile index 4f83719..5e02aa8 100644 --- a/Gemfile +++ b/Gemfile @@ -10,8 +10,10 @@ gem 'benchmark-ips' gem 'bump' gem 'maxitest' gem 'memory_profiler' +gem 'mocha' +gem 'ostruct' gem 'rake' -gem 'rubocop' +gem 'rubocop', '~> 1.84.2' # locked down so we don't get accidental new cops gem 'rubocop-performance' gem 'rubocop-rake' gem 'webrick' diff --git a/Gemfile.lock b/Gemfile.lock index 5913805..5998768 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,50 +7,61 @@ PATH GEM remote: https://rubygems.org/ specs: - addressable (2.8.6) - public_suffix (>= 2.0.2, < 6.0) - ast (2.4.2) - benchmark-ips (2.13.0) + addressable (2.8.8) + public_suffix (>= 2.0.2, < 8.0) + ast (2.4.3) + benchmark-ips (2.14.0) bump (0.10.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) + json (2.18.1) + json (2.18.1-java) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) + maxitest (7.1.1) + minitest (>= 6.0.0, < 6.1.0) + memory_profiler (1.1.0) + minitest (6.0.1) + prism (~> 1.5) + mocha (3.0.2) + ruby2_keywords (>= 0.0.5) + ostruct (0.6.3) + parallel (1.27.0) + parser (3.3.10.2) ast (~> 2.4.1) racc - public_suffix (5.0.5) - racc (1.7.3) - racc (1.7.3-java) + prism (1.9.0) + public_suffix (7.0.2) + racc (1.8.1) + racc (1.8.1-java) rainbow (3.1.1) - rake (13.2.1) - regexp_parser (2.9.0) - rexml (3.2.6) - rubocop (1.62.1) + rake (13.3.1) + regexp_parser (2.11.3) + rubocop (1.84.2) json (~> 2.3) - language_server-protocol (>= 3.17.0) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.31.1, < 2.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.49.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.31.2) - parser (>= 3.3.0.4) - rubocop-performance (1.23.0) - rubocop (>= 1.48.1, < 2.0) - rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rake (0.6.0) - rubocop (~> 1.0) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.49.0) + parser (>= 3.3.7.2) + prism (~> 1.7) + rubocop-performance (1.26.1) + lint_roller (~> 1.1) + rubocop (>= 1.75.0, < 2.0) + rubocop-ast (>= 1.47.1, < 2.0) + rubocop-rake (0.7.1) + lint_roller (~> 1.1) + rubocop (>= 1.72.1) ruby-progressbar (1.13.0) - unicode-display_width (2.5.0) - webrick (1.8.1) + ruby2_keywords (0.0.5) + unicode-display_width (3.2.0) + unicode-emoji (~> 4.1) + unicode-emoji (4.2.0) + webrick (1.9.2) PLATFORMS java @@ -62,8 +73,10 @@ DEPENDENCIES css_parser! maxitest memory_profiler + mocha + ostruct rake - rubocop + rubocop (~> 1.84.2) rubocop-performance rubocop-rake webrick diff --git a/css_parser.gemspec b/css_parser.gemspec index d8cf155..df3cc36 100644 --- a/css_parser.gemspec +++ b/css_parser.gemspec @@ -11,12 +11,12 @@ Gem::Specification.new name, CssParser::VERSION do |s| s.author = 'Alex Dunae' s.files = Dir.glob('lib/**/*') + ['MIT-LICENSE'] s.license = 'MIT' - s.required_ruby_version = '>= 3.0' + s.required_ruby_version = '>= 3.3' s.metadata['changelog_uri'] = 'https://github.com/premailer/css_parser/blob/master/CHANGELOG.md' s.metadata['source_code_uri'] = 'https://github.com/premailer/css_parser' s.metadata['bug_tracker_uri'] = 'https://github.com/premailer/css_parser/issues' s.metadata['rubygems_mfa_required'] = 'true' - s.add_runtime_dependency 'addressable' + s.add_dependency 'addressable' end diff --git a/lib/css_parser/parser.rb b/lib/css_parser/parser.rb index 57d3a5e..a8d714a 100644 --- a/lib/css_parser/parser.rb +++ b/lib/css_parser/parser.rb @@ -143,7 +143,7 @@ def add_block!(block, options = {}) media_types = [:all] end - next unless options[:only_media_types].include?(:all) or media_types.empty? or !(media_types & options[:only_media_types]).empty? + next unless options[:only_media_types].include?(:all) or media_types.empty? or media_types.intersect?(options[:only_media_types]) import_path = import_rule[0].to_s.gsub(/['"]*/, '').strip @@ -568,7 +568,8 @@ def load_string!(src, options = {}, deprecated = nil) # # Raises a CircularReferenceError exception if io_exceptions are on, # otherwise returns true/false. - def circular_reference_check(path) + # TODO: fix rubocop + def circular_reference_check(path) # rubocop:disable Naming/PredicateMethod path = path.to_s if @loaded_uris.include?(path) raise CircularReferenceError, "can't load #{path} more than once" if @options[:io_exceptions] diff --git a/test/rule_set/test_declarations.rb b/test/rule_set/test_declarations.rb index 8158787..ace714b 100644 --- a/test/rule_set/test_declarations.rb +++ b/test/rule_set/test_declarations.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require_relative '../test_helper' -require 'minitest/spec' class RuleSetDeclarationsTest < Minitest::Test describe '.new' do @@ -382,14 +381,12 @@ class RuleSetDeclarationsTest < Minitest::Test declarations = CssParser::RuleSet::Declarations.new({foo: foo_value, bar: bar_value, baz: baz_value}) - mock = Minitest::Mock.new - mock.expect :call, true, ['foo', foo_value] - mock.expect :call, true, ['bar', bar_value] - mock.expect :call, true, ['baz', baz_value] + mock = stub("Fake") + mock.expects(:call).with('foo', foo_value).returns(true) + mock.expects(:call).with('bar', bar_value).returns(true) + mock.expects(:call).with('baz', baz_value).returns(true) declarations.each { |name, value| mock.call(name, value) } - - assert_mock mock end end end diff --git a/test/test_css_parser_misc.rb b/test/test_css_parser_misc.rb index 817c436..029e0c2 100644 --- a/test/test_css_parser_misc.rb +++ b/test/test_css_parser_misc.rb @@ -227,9 +227,10 @@ def test_enumerator_nonempty end end - def with_value_exception(&block) + def with_value_exception # Raise synthetic exception to test error handling because there is no known way to cause it naturally - CssParser::RuleSet::Declarations::Value.stub :new, -> { raise ArgumentError.new, 'stub' }, &block + CssParser::RuleSet::Declarations::Value.stubs(:new).raises(ArgumentError.new('stub')) + yield # TODO: do not pass a block instead end def test_catching_argument_exceptions_for_add_rule diff --git a/test/test_helper.rb b/test/test_helper.rb index 7dd2989..6411176 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -2,6 +2,8 @@ require 'bundler/setup' require 'maxitest/autorun' +require 'mocha/minitest' +require 'ostruct' require 'net/http' require 'webrick' require 'css_parser' diff --git a/test/test_rule_set.rb b/test/test_rule_set.rb index 1a40c1f..0b0c367 100644 --- a/test/test_rule_set.rb +++ b/test/test_rule_set.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require_relative 'test_helper' -require "set" # Test cases for parsing CSS blocks class RuleSetTests < Minitest::Test @@ -81,7 +80,7 @@ def test_each_declaration_containing_semicolons def test_each_declaration_with_newlines expected = Set[ {property: 'background-image', value: 'url(foo;bar)', is_important: false}, - {property: 'font-weight', value: 'bold', is_important: true}, + {property: 'font-weight', value: 'bold', is_important: true} ] rs = RuleSet.new(block: "background-image\n:\nurl(foo;bar);\n\n\n\n\n;;font-weight\n\n\n:bold\n\n\n!important") actual = Set.new