From ef9ac53207fe812a9182d799eb8e6430f2e6cd82 Mon Sep 17 00:00:00 2001 From: Piero Dotti Date: Tue, 16 Dec 2025 20:32:56 +0100 Subject: [PATCH 1/5] feat(ci): remove ruby 2.4, add ruby 3.3 and 3.4 to the ci matrix --- .github/workflows/ci.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 76a2259..65f3b6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: [2.4, 2.7, '3.0', 3.1, 3.2, truffleruby-head] + ruby: [2.7, '3.0', 3.1, 3.2, 3.3, 3.4, truffleruby-head] steps: - uses: actions/checkout@v3 @@ -22,13 +22,7 @@ jobs: run: | sudo apt-get install libsqlite3-dev - - name: Install legacy bundler for Ruby 2.4 - if: ${{ matrix.ruby == 2.4 }} - run: | - gem install -q bundler -v 2.3.26 - - - name: Install bundler 2.4+ for modern Rubies - if: ${{ matrix.ruby != 2.4 }} + - name: Install bundler run: | gem install -q bundler From c1a6ade2abc29c692d64428741e9ee7dcec2bc6c Mon Sep 17 00:00:00 2001 From: Piero Dotti Date: Tue, 16 Dec 2025 20:39:55 +0100 Subject: [PATCH 2/5] fix: modernize rubocop configuration, apply automatic fixes --- .rubocop.yml | 9 ++++++--- jsonapi-serializer.gemspec | 2 +- lib/fast_jsonapi/object_serializer.rb | 4 ++-- spec/fixtures/actor.rb | 2 +- spec/spec_helper.rb | 3 ++- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 43747b4..2edc619 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,4 @@ -require: +plugins: - rubocop-performance - rubocop-rspec @@ -23,7 +23,10 @@ Lint/DuplicateMethods: Exclude: - 'spec/fixtures/*.rb' -RSpec/FilePath: +RSpec/SpecFilePathFormat: + Enabled: false + +RSpec/SpecFilePathSuffix: Enabled: false RSpec/DescribedClass: @@ -76,7 +79,7 @@ Layout/LineLength: Exclude: - 'lib/**/**.rb' -Naming/PredicateName: +Naming/PredicatePrefix: Exclude: - 'lib/**/**.rb' diff --git a/jsonapi-serializer.gemspec b/jsonapi-serializer.gemspec index d8ccb4a..22eb5ce 100644 --- a/jsonapi-serializer.gemspec +++ b/jsonapi-serializer.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |gem| gem.require_paths = ['lib'] gem.extra_rdoc_files = ['LICENSE.txt', 'README.md'] - gem.add_runtime_dependency('activesupport', '>= 4.2') + gem.add_dependency('activesupport', '>= 4.2') gem.add_development_dependency('activerecord') gem.add_development_dependency('bundler') diff --git a/lib/fast_jsonapi/object_serializer.rb b/lib/fast_jsonapi/object_serializer.rb index 04bd98d..417e3b8 100644 --- a/lib/fast_jsonapi/object_serializer.rb +++ b/lib/fast_jsonapi/object_serializer.rb @@ -117,7 +117,7 @@ def is_collection?(resource, force_is_collection = nil) end def inherited(subclass) - super(subclass) + super subclass.attributes_to_serialize = attributes_to_serialize.dup if attributes_to_serialize.present? subclass.relationships_to_serialize = relationships_to_serialize.dup if relationships_to_serialize.present? subclass.cachable_relationships_to_serialize = cachable_relationships_to_serialize.dup if cachable_relationships_to_serialize.present? @@ -271,7 +271,7 @@ def create_relationship(base_key, relationship_type, options, block) name: name, id_method_name: compute_id_method_name( options[:id_method_name], - "#{base_serialization_key}#{id_postfix}".to_sym, + :"#{base_serialization_key}#{id_postfix}", polymorphic, options[:serializer], block diff --git a/spec/fixtures/actor.rb b/spec/fixtures/actor.rb index f212de1..0ffd494 100644 --- a/spec/fixtures/actor.rb +++ b/spec/fixtures/actor.rb @@ -6,7 +6,7 @@ class Actor < User attr_accessor :movies, :movie_ids def self.fake(id = nil) - faked = super(id) + faked = super faked.movies = [] faked.movie_ids = [] faked diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4da35af..c7f597e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,6 +8,7 @@ end require 'active_support' +require 'active_support/core_ext/object' require 'active_support/core_ext/object/json' require 'jsonapi/serializer' require 'ffaker' @@ -16,7 +17,7 @@ require 'byebug' require 'securerandom' -Dir[File.expand_path('spec/fixtures/*.rb')].sort.each { |f| require f } +Dir[File.expand_path('spec/fixtures/*.rb')].each { |f| require f } RSpec.configure do |config| config.include JSONAPI::RSpec From 085c2c0766a7337519009a21e2773788bb4e2ba8 Mon Sep 17 00:00:00 2001 From: Piero Dotti Date: Tue, 16 Dec 2025 20:40:28 +0100 Subject: [PATCH 3/5] fix: ci for ruby 2.7 --- .github/workflows/ci.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 65f3b6f..68331d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,13 @@ jobs: run: | sudo apt-get install libsqlite3-dev - - name: Install bundler + - name: Install legacy bundler for Ruby 2.7 + if: ${{ matrix.ruby == 2.7 }} + run: | + gem install -q bundler -v 2.4.22 + + - name: Install bundler 2.7+ for modern Rubies + if: ${{ matrix.ruby != 2.7 }} run: | gem install -q bundler From a64c4d95b4a9ac4bd3f3ad755ba9b7f3a3540a1f Mon Sep 17 00:00:00 2001 From: Piero Dotti Date: Tue, 16 Dec 2025 20:46:37 +0100 Subject: [PATCH 4/5] fix: rubocop --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c7f597e..4e2ac77 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -17,7 +17,7 @@ require 'byebug' require 'securerandom' -Dir[File.expand_path('spec/fixtures/*.rb')].each { |f| require f } +Dir[File.expand_path('spec/fixtures/*.rb')].sort.each { |f| require f } RSpec.configure do |config| config.include JSONAPI::RSpec From 9068354b5a3faaa58b1dd8310286efe2a5823e69 Mon Sep 17 00:00:00 2001 From: Piero Dotti Date: Tue, 16 Dec 2025 21:03:14 +0100 Subject: [PATCH 5/5] fix(ci): test among ruby HEAD --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 68331d0..f293108 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: [2.7, '3.0', 3.1, 3.2, 3.3, 3.4, truffleruby-head] + ruby: [2.7, '3.0', 3.1, 3.2, 3.3, 3.4, head, truffleruby-head] steps: - uses: actions/checkout@v3