Skip to content

Commit

Permalink
Preparing the release of v3 including breaking changes about view_paths.
Browse files Browse the repository at this point in the history
cookpad#78

- Adds support for Rails 7
- Drops support for eol versions of Ruby and  Rails.
  • Loading branch information
eudoxa committed Mar 8, 2024
1 parent a544457 commit a19036c
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 97 deletions.
30 changes: 4 additions & 26 deletions .github/workflows/master_and_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,17 @@ jobs:
strategy:
matrix:
rails_version:
- "5.0"
- "5.1"
- "5.2"
- "6.0"
- "6.1"
- "7.0"
- "7.1"
ruby_version:
- "2.7"
- "3.1"
- "3.3"
autoloader:
- "zeitwerk"
- "classic"
eager_load:
- "true"
- "false"
exclude:
- rails_version: "5.0"
ruby_version: "3.1"
- rails_version: "5.1"
ruby_version: "3.1"
- rails_version: "5.2"
ruby_version: "3.1"
- rails_version: "5.0"
autoloader: "zeitwerk"
- rails_version: "5.1"
autoloader: "zeitwerk"
- rails_version: "5.2"
autoloader: "zeitwerk"
- rails_version: "5.0"
autoloader: "classic"
- rails_version: "5.1"
autoloader: "classic"
- rails_version: "5.2"
autoloader: "classic"
name: Test on Rails ${{ matrix.rails_version }} & Ruby ${{ matrix.ruby_version }} & Autoloader ${{ matrix.autoloader }} & EagerLoad ${{ matrix.eager_load }}
env:
BUNDLE_GEMFILE: gemfiles/Gemfile_rails_${{ matrix.rails_version }}.rb
Expand All @@ -58,7 +36,7 @@ jobs:
- name: rspec
run: bundle exec rspec
- name: Coveralls
if: matrix.rails_version == '6.1' && matrix.ruby_version == '3.1'
if: matrix.rails_version == '7.1'
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0.6
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## Unreleased

## 3.0.0
* Support Rails 6,1. 7.0, 7.1.
* Drop support for Raiils below 6.0
* Drop support for Ruby 2
* The functionality to extend the view_paths has been discontinued.

## 2.3.0
* Support Rails 5.0, 5.1, 5,2, 6.0, 6,1.
* Drop support of Rails 4.x.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ it will be automatically hidden and fallback to its normal behavior.


## Requirements
* Ruby >= 2.6.0
* Rails >= 5.0.0
* Ruby >= 3.0.0
* Rails >= 6.1.0


## Usage
Expand Down
4 changes: 2 additions & 2 deletions chanko.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ Gem::Specification.new do |gem|
gem.files = `git ls-files`.split($/)
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ["lib"]
gem.required_ruby_version = '>= 2.6.0'
gem.required_ruby_version = '>= 3.0.0'

gem.add_dependency "rails", ">= 5.0.0"
gem.add_dependency "rails", ">= 6.1.0"
gem.add_development_dependency "byebug"
gem.add_development_dependency "coffee-rails", ">= 3.0.10"
gem.add_development_dependency "jquery-rails"
Expand Down
6 changes: 0 additions & 6 deletions gemfiles/Gemfile_rails_5.2.rb

This file was deleted.

8 changes: 0 additions & 8 deletions gemfiles/Gemfile_rails_6.0.rb

This file was deleted.

3 changes: 0 additions & 3 deletions gemfiles/Gemfile_rails_6.1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@
gemspec path: '..'

gem 'rails', '~> 6.1.0'
gem 'net-smtp'
gem 'net-pop'
gem 'net-imap'
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

gemspec path: '..'

gem 'rails', '~> 5.0.0'
gem 'sqlite3', '~> 1.3.6'
gem 'rails', '~> 7.0.0'
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

gemspec path: '..'

gem 'rails', '~> 5.1.0'
gem 'sqlite3', '~> 1.3.6'
gem 'rails', '~> 7.1.0'
6 changes: 2 additions & 4 deletions lib/chanko/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@ class Railtie < Rails::Railtie
end
end


initializer("chanko.zeitwerk.prepare_eager_load", before: :set_autoload_paths) do |app|
# zeitwerk freezes autoload_paths after :set_autoload_paths.
# So we need to prepare before set_autoload_paths
Chanko::Loader.prepare_eager_load(mode: :zeitwerk)
end

initializer("chanko.classic.prepare_eager_load", after: :load_environment_config) do |app|
# Rails5 doens't load environments/*.rb files before :set_autoload_paths.
# In other words, at this stage, config.eager_load cannot be determined to be true or false.
# At this stage, config.eager_load cannot be determined to be true or false.
# But classic loader does not freeze paths on :set_autoload_paths.
# After all, It's ok if it is executed after :set_autoload_paths on Rails5 and Rails6(classic).
# After all, It's ok if it is executed after :set_autoload_paths on Rails6(classic).
Chanko::Loader.prepare_eager_load(mode: :classic)
end

Expand Down
22 changes: 2 additions & 20 deletions spec/chanko/function_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,7 @@ module Chanko
Loader.load(:example_unit)
end

def rails5_action_view_instance
klass = Class.new(ActionView::Base) do
def current_unit
units.last
end

def units
@units ||= []
end
end
klass.new
end

def rails6_action_view_instance
def rails_action_view_instance
klass = Class.new(ActionView::Base.with_empty_template_cache) do
def current_unit
units.last
Expand All @@ -33,12 +20,7 @@ def units
end

let(:context) do
case Rails::VERSION::MAJOR
when 5
rails5_action_view_instance
when 6
rails6_action_view_instance
end
rails_action_view_instance
end

let(:options) do
Expand Down
13 changes: 2 additions & 11 deletions spec/chanko/test_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,13 @@

module Chanko
describe Test do
def rails5_action_view_instance
Class.new(ActionView::Base).new
end

def rails6_action_view_instance
def rails_action_view_instance
klass = Class.new(ActionView::Base.with_empty_template_cache)
klass.with_view_paths(nil, {}, nil)
end

let(:view) do
case Rails::VERSION::MAJOR
when 5
rails5_action_view_instance
when 6
rails6_action_view_instance
end
rails_action_view_instance
end

describe "#enable_unit" do
Expand Down
23 changes: 12 additions & 11 deletions spec/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,21 @@ class Application < Rails::Application
# config.active_record.schema_format = :sql

# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
config.assets.quiet = true if ::Rails::VERSION::MAJOR >= 5
if Rails::VERSION::MAJOR >= 6
if ENV['AUTOLOADER'] == 'zeitwerk'
Chanko::Test.logger.info("Autoloader: zeitwerk")
config.autoloader = :zeitwerk
else
Chanko::Test.logger.info("Autoloader: classic")
config.autoloader = :classic
end
if config.respond_to?("assets")
config.assets.version = '1.0'
config.assets.quiet = true
end

if ENV['AUTOLOADER'] == 'zeitwerk'
Chanko::Test.logger.info("Autoloader: zeitwerk")
config.autoloader = :zeitwerk
else
Chanko::Test.logger.info("Autoloader: classic")
config.autoloader = :classic
end
end
end

if Rails::VERSION::MAJOR >= 6 && Rails.autoloaders.zeitwerk_enabled?
if Rails.autoloaders.zeitwerk_enabled?
Rails.autoloaders.main.collapse(Rails.root.join('app', 'units', '*'))
end

0 comments on commit a19036c

Please sign in to comment.