From 6218341252b280841f55b7861fbcb00393ceca95 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Mon, 24 Nov 2025 13:42:01 -0800 Subject: [PATCH] Support Rails 7 + 8 --- .github/workflows/ruby.yml | 11 +++++++---- Gemfile | 15 +++------------ annotot.gemspec | 5 ++--- app/models/annotot/annotation.rb | 2 +- lib/annotot/engine.rb | 12 ++++++++++++ 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 890c7d6..e912a4c 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -11,14 +11,17 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: [2.7, '3.0'] + ruby: [3.4] + rails: ['~> 7', '~> 8'] + env: + RAILS_VERSION: ${{ matrix.rails }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} - - uses: actions/cache@v2 + - uses: actions/cache@v4 with: path: vendor/bundle key: ${{ runner.os }}-gems-202103-${{ hashFiles('**/Gemfile.lock') }} @@ -27,6 +30,6 @@ jobs: - name: Bundle install run: bundle config path vendor/bundle - name: Install dependencies - run: bin/setup + run: bundle install - name: Run tests run: bundle exec rake diff --git a/Gemfile b/Gemfile index caba24a..1c4e6c3 100644 --- a/Gemfile +++ b/Gemfile @@ -16,7 +16,9 @@ gemspec # engine_cart: 1.2.0 # engine_cart stanza: 0.10.0 # the below comes from engine_cart, a gem used to test this Rails engine gem in the context of a Rails app. -file = File.expand_path('Gemfile', ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || File.expand_path('.internal_test_app', File.dirname(__FILE__))) +file = File.expand_path('Gemfile', + ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || File.expand_path('.internal_test_app', + File.dirname(__FILE__))) if File.exist?(file) begin eval_gemfile file @@ -35,16 +37,5 @@ else gem 'rails', ENV['RAILS_VERSION'] end end - - case ENV['RAILS_VERSION'] - when /^5.[12]/ - gem 'sass-rails', '~> 5.1' - when /^4.2/ - gem 'responders', '~> 2.0' - gem 'sass-rails', '>= 5.0' - gem 'coffee-rails', '~> 4.1.0' - when /^4.[01]/ - gem 'sass-rails', '< 5.0' - end end # END ENGINE_CART BLOCK diff --git a/annotot.gemspec b/annotot.gemspec index 0958a4d..6a4018d 100644 --- a/annotot.gemspec +++ b/annotot.gemspec @@ -1,4 +1,4 @@ -$:.push File.expand_path('../lib', __FILE__) +$:.push File.expand_path('lib', __dir__) # Maintain your gem's version: require 'annotot/version' @@ -16,11 +16,10 @@ Gem::Specification.new do |s| s.files = Dir['{app,config,db,lib}/**/*', 'LICENSE', 'Rakefile', 'README.md'] - s.add_dependency 'rails', '>= 5.1', '< 8' + s.add_dependency 'rails', '>= 7.0', '< 9' s.add_development_dependency 'engine_cart' s.add_development_dependency 'factory_bot_rails' s.add_development_dependency 'rails-controller-testing' s.add_development_dependency 'rspec-rails' - s.add_development_dependency 'sqlite3' end diff --git a/app/models/annotot/annotation.rb b/app/models/annotot/annotation.rb index 9d56e3b..55955dc 100644 --- a/app/models/annotot/annotation.rb +++ b/app/models/annotot/annotation.rb @@ -3,7 +3,7 @@ class Annotation < ApplicationRecord validates :uuid, presence: true, uniqueness: true validates :canvas, presence: true - serialize :data, JSON + serialize :data, coder: JSON ## # Used to differentiate between a numeric id and a uuid. Rails will trim a diff --git a/lib/annotot/engine.rb b/lib/annotot/engine.rb index 497a641..27c0db1 100644 --- a/lib/annotot/engine.rb +++ b/lib/annotot/engine.rb @@ -1,5 +1,17 @@ module Annotot class Engine < ::Rails::Engine isolate_namespace Annotot + + config.before_configuration do + # see https://github.com/fxn/zeitwerk#for_gem + # Blacklight puts a generator into LOCAL APP lib/generators, so tell + # zeitwerk to ignore the whole directory? If we're using a recent + # enough version of Rails to have zeitwerk config + # + # See: https://github.com/cbeer/engine_cart/issues/117 + if Rails.try(:autoloaders).try(:main).respond_to?(:ignore) + Rails.autoloaders.main.ignore(Rails.root.join('lib/generators')) + end + end end end