Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
* master:
  Add Rails 8 compatibility
  Do not test Rails edge against Ruby < 3.2
  Prefer `require_relative` for internal requires
  Do not test Rails 7.0 against Ruby 3.4 dev
  Update coveralls action
  Fix Gemspec/AddRuntimeDependency offenses
  Test against Rails 7.2 beta
  Update version and changelog
  Allow Rails 8.0
  Fix "Test is missing assertions" warnings
  Test Rails Edge against Ruby 3.3
  Fix typos
  Update RuboCop config
  Require Ruby 3.1 for Rails edge
  Test against Ruby 3.3
  • Loading branch information
tagliala committed Nov 8, 2024
2 parents 1f45440 + f7342eb commit c541359
Show file tree
Hide file tree
Showing 16 changed files with 101 additions and 42 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
ruby-version: ['3.2']
ruby-version: ['3.3']

steps:
- uses: actions/checkout@v4
Expand All @@ -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
33 changes: 21 additions & 12 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,45 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.7', '3.0', '3.1', '3.2']
gemfile: [rails_6.1, rails_7.0, rails_7.1]
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, rails_8.0]
channel: ['stable']

include:
- ruby-version: '2.7'
- ruby-version: '3.2'
gemfile: rails_edge
channel: 'experimental'
- ruby-version: '3.0'
- ruby-version: '3.3'
gemfile: rails_edge
channel: 'experimental'
- ruby-version: '3.1'
gemfile: rails_edge
channel: 'experimental'
- ruby-version: '3.2'
gemfile: rails_edge
- ruby-version: 'head'
gemfile: rails_7.1
channel: 'experimental'
- ruby-version: 'head'
gemfile: rails_7.0
gemfile: rails_7.2
channel: 'experimental'
- ruby-version: 'head'
gemfile: rails_7.1
gemfile: rails_8.0
channel: 'experimental'
- ruby-version: 'head'
gemfile: rails_edge
channel: 'experimental'

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'
gemfile: rails_6.1

env:
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
Expand Down Expand Up @@ -73,7 +82,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ Rails/I18nLocaleAssignment:
Exclude:
- 'test/support/i18n_helper.rb'

Style/ArgumentsForwarding:
Enabled: false

Style/Documentation:
Enabled: false

Expand Down
8 changes: 8 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ appraise 'rails-7.1' do
gem 'rails', '~> 7.1.0'
end

appraise 'rails-7.2' do
gem 'rails', '~> 7.2.0'
end

appraise 'rails-8.0' do
gem 'rails', '~> 8.0.0'
end

appraise 'rails-edge' do
gem 'rails', git: 'https://github.com/rails/rails.git', branch: 'main'
end
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 14.2.0 / 2024-11-08

* [FEATURE] Rails 8.0 compatibility

## 14.1.2 / 2024-05-27

* [ENHANCEMENT] Test against Ruby 3.3
* [ENHANCEMENT] Allow Rails 8.0 (pre)

## 14.1.1 / 2023-12-19

* [BUGFIX] Fix memory leak in development mode ([#301](https://github.com/enriclluelles/route_translator/pull/301))
Expand Down Expand Up @@ -315,6 +324,6 @@

## 4.2.0 / 2015-12-15

* [ENHANCEMENT] Style update to match RuboCop recommandations
* [ENHANCEMENT] Style update to match RuboCop recommendations
* [BUGFIX] Permit named_params with suffix (#116)
* [BUGFIX] Fix optional parameters with prefix (#118)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -157,7 +157,7 @@ link_to url_for(locale: 'es'), hreflang: 'es', rel: 'alternate'

Although locales are stored by Rails as a symbol (`:es`), when linking to a page in a different locale you need to use a string (`'es'`). Otherwise, instead of a namespaced route (`/es/my-route`) you will get a parameterized route (`/my-route?locale=es`).

If the page contains a localized slug, the above snippet does not work and a custom implementation is neede.
If the page contains a localized slug, the above snippet does not work and a custom implementation is needed.

More information at [Generating translated URLs](https://github.com/enriclluelles/route_translator/wiki/Generating-translated-URLs)

Expand Down
19 changes: 19 additions & 0 deletions gemfiles/rails_7.2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "appraisal"
gem "byebug"
gem "minitest"
gem "rails", "~> 7.2.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: "../"
19 changes: 19 additions & 0 deletions gemfiles/rails_8.0.gemfile
Original file line number Diff line number Diff line change
@@ -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: "../"
8 changes: 4 additions & 4 deletions lib/route_translator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

require 'active_support'

require 'route_translator/extensions'
require 'route_translator/translator'
require 'route_translator/host'
require 'route_translator/version'
require_relative 'route_translator/extensions'
require_relative 'route_translator/translator'
require_relative 'route_translator/host'
require_relative 'route_translator/version'

module RouteTranslator
extend RouteTranslator::Host
Expand Down
6 changes: 3 additions & 3 deletions lib/route_translator/extensions.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

require 'route_translator/extensions/mapper'
require 'route_translator/extensions/route_set'
require 'route_translator/extensions/action_controller'
require_relative 'extensions/mapper'
require_relative 'extensions/route_set'
require_relative 'extensions/action_controller'
6 changes: 3 additions & 3 deletions lib/route_translator/translator.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

require 'route_translator/translator/route_helpers'
require 'route_translator/translator/path'
require 'route_translator/route'
require_relative 'translator/route_helpers'
require_relative 'translator/path'
require_relative 'route'

module RouteTranslator
module Translator
Expand Down
2 changes: 1 addition & 1 deletion lib/route_translator/translator/path.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require 'route_translator/translator/path/segment'
require_relative 'path/segment'

module RouteTranslator
module Translator
Expand Down
4 changes: 2 additions & 2 deletions lib/route_translator/translator/path/segment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/route_translator/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module RouteTranslator
VERSION = '14.1.1'
VERSION = '14.2.0'
end
4 changes: 2 additions & 2 deletions route_translator.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ Gem::Specification.new do |spec|

spec.required_ruby_version = '>= 2.7'

spec.add_runtime_dependency 'actionpack', '>= 6.1', '< 7.2'
spec.add_runtime_dependency 'activesupport', '>= 6.1', '< 7.2'
spec.add_dependency 'actionpack', '>= 6.1'
spec.add_dependency 'activesupport', '>= 6.1'
end
10 changes: 1 addition & 9 deletions test/routing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -620,15 +620,7 @@ def test_host_locales
end

def test_action_controller_gets_locale_setter
ActionController::Base.instance_methods.include?('set_locale_from_url')
end

def test_action_controller_gets_locale_suffix_helper
ActionController::Base.instance_methods.include?('locale_suffix')
end

def test_action_view_gets_locale_suffix_helper
ActionView::Base.instance_methods.include?('locale_suffix')
assert_includes ActionController::Base.private_instance_methods, :set_locale_from_url
end

# See https://github.com/enriclluelles/route_translator/issues/69
Expand Down

0 comments on commit c541359

Please sign in to comment.