From 91c0e80ba008ce02414fdee1a2dedcef03ca8b27 Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Fri, 8 Nov 2024 09:36:32 +0100 Subject: [PATCH] Add Rails 8 compatibility Remove upper constraint as per https://github.com/svenfuchs/rails-i18n/pull/1130#discussion_r1808623501 --- .github/workflows/rubocop.yml | 2 +- .github/workflows/ruby.yml | 11 ++++++++++- Appraisals | 6 +++++- CHANGELOG.md | 4 ++++ README.md | 2 +- gemfiles/rails_7.2.gemfile | 2 +- gemfiles/rails_8.0.gemfile | 19 +++++++++++++++++++ .../translator/path/segment.rb | 4 ++-- lib/route_translator/version.rb | 2 +- route_translator.gemspec | 4 ++-- 10 files changed, 46 insertions(+), 10 deletions(-) create mode 100644 gemfiles/rails_8.0.gemfile diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index db8b1712..0c9cdfd2 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -29,4 +29,4 @@ jobs: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true - name: Ruby linter - run: bundle exec rubocop + run: bundle exec rubocop --format github diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index b263485d..b1316ed9 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3'] - gemfile: [rails_6.1, rails_7.0, rails_7.1, rails_7.2] + gemfile: [rails_6.1, rails_7.0, rails_7.1, rails_7.2, rails_8.0] channel: ['stable'] include: @@ -32,6 +32,9 @@ jobs: - ruby-version: 'head' gemfile: rails_7.2 channel: 'experimental' + - ruby-version: 'head' + gemfile: rails_8.0 + channel: 'experimental' - ruby-version: 'head' gemfile: rails_edge channel: 'experimental' @@ -39,8 +42,14 @@ jobs: exclude: - ruby-version: '2.7' gemfile: rails_7.2 + - ruby-version: '2.7' + gemfile: rails_8.0 - ruby-version: '3.0' gemfile: rails_7.2 + - ruby-version: '3.0' + gemfile: rails_8.0 + - ruby-version: '3.1' + gemfile: rails_8.0 - ruby-version: '3.2' gemfile: rails_6.1 - ruby-version: '3.3' diff --git a/Appraisals b/Appraisals index 066c0eec..8c6cfeac 100644 --- a/Appraisals +++ b/Appraisals @@ -13,7 +13,11 @@ appraise 'rails-7.1' do end appraise 'rails-7.2' do - gem 'rails', '~> 7.2.0.beta2' + gem 'rails', '~> 7.2.0' +end + +appraise 'rails-8.0' do + gem 'rails', '~> 8.0.0' end appraise 'rails-edge' do diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fcc7db0..dafd5204 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 14.2.0 / 2024-11-08 + +* [FEATURE] Rails 8.0 compatibility + ## 14.1.2 / 2024-05-27 * [ENHANCEMENT] Test against Ruby 3.3 diff --git a/README.md b/README.md index b85aee00..d1e3f6ec 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ RouteTranslator is a gem to allow you to manage the translations of your app rou It started as a fork of the awesome [translate_routes](https://github.com/raul/translate_routes) plugin by [Raúl Murciano](https://github.com/raul). -Right now it works with Rails 6.1 and 7.x +Right now it works with Rails 6.1, 7.x, and 8.0 ## Quick Start diff --git a/gemfiles/rails_7.2.gemfile b/gemfiles/rails_7.2.gemfile index 2eef2cf2..725bb81c 100644 --- a/gemfiles/rails_7.2.gemfile +++ b/gemfiles/rails_7.2.gemfile @@ -5,7 +5,7 @@ source "https://rubygems.org" gem "appraisal" gem "byebug" gem "minitest" -gem "rails", "~> 7.2.0.beta2" +gem "rails", "~> 7.2.0" gem "rake" gem "rubocop" gem "rubocop-minitest" diff --git a/gemfiles/rails_8.0.gemfile b/gemfiles/rails_8.0.gemfile new file mode 100644 index 00000000..28155c6c --- /dev/null +++ b/gemfiles/rails_8.0.gemfile @@ -0,0 +1,19 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "appraisal" +gem "byebug" +gem "minitest" +gem "rails", "~> 8.0.0" +gem "rake" +gem "rubocop" +gem "rubocop-minitest" +gem "rubocop-packaging" +gem "rubocop-performance" +gem "rubocop-rails" +gem "rubocop-rake" +gem "simplecov" +gem "simplecov-lcov" + +gemspec path: "../" diff --git a/lib/route_translator/translator/path/segment.rb b/lib/route_translator/translator/path/segment.rb index adcba297..2902cfc1 100644 --- a/lib/route_translator/translator/path/segment.rb +++ b/lib/route_translator/translator/path/segment.rb @@ -24,8 +24,8 @@ def translate_resource(str, locale, scope) handler = proc { |exception| exception } opts = { locale: locale, scope: scope } - if I18n.t(str, **opts.merge(exception_handler: handler)).is_a?(I18n::MissingTranslation) - I18n.t! str, **opts.merge(fallback_options(str, locale)) + if I18n.t(str, **opts, exception_handler: handler).is_a?(I18n::MissingTranslation) + I18n.t! str, **opts, **fallback_options(str, locale) else I18n.t str, **opts end diff --git a/lib/route_translator/version.rb b/lib/route_translator/version.rb index 88b55589..5f31f391 100644 --- a/lib/route_translator/version.rb +++ b/lib/route_translator/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module RouteTranslator - VERSION = '14.1.2' + VERSION = '14.2.0' end diff --git a/route_translator.gemspec b/route_translator.gemspec index 73beacad..ad9a0494 100644 --- a/route_translator.gemspec +++ b/route_translator.gemspec @@ -26,6 +26,6 @@ Gem::Specification.new do |spec| spec.required_ruby_version = '>= 2.7' - spec.add_dependency 'actionpack', '>= 6.1', '< 8.0' - spec.add_dependency 'activesupport', '>= 6.1', '< 8.0' + spec.add_dependency 'actionpack', '>= 6.1' + spec.add_dependency 'activesupport', '>= 6.1' end