Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes support version and Drops support for classic loader #81

Merged
merged 4 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 6 additions & 30 deletions .github/workflows/master_and_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,21 @@ 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"
autoloader:
- "zeitwerk"
- "classic"
- "3.2"
- "3.3"
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 }}
name: Test on Rails ${{ matrix.rails_version }} & Ruby ${{ matrix.ruby_version }} & EagerLoad ${{ matrix.eager_load }}
env:
BUNDLE_GEMFILE: gemfiles/Gemfile_rails_${{ matrix.rails_version }}.rb
CI: true
EAGER_LOAD: ${{ matrix.eager_load }}
AUTOLOADER : ${{ matrix.autoloader }}
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
Expand All @@ -58,7 +34,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' && matrix.ruby_version == '3.3'
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
## Unreleased
* Support Rails 6,1. 7.0, 7.1.
* Drop support for Raiils below 6.0
* Drop support for Ruby 2
* Drop support for classic loader
* 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.
Expand Down
6 changes: 3 additions & 3 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 All @@ -27,7 +27,7 @@ Gem::Specification.new do |gem|
gem.add_development_dependency "simplecov"
gem.add_development_dependency 'simplecov-lcov'
gem.add_development_dependency "slim"
gem.add_development_dependency "sqlite3"
gem.add_development_dependency "sqlite3", ">= 1.4"
gem.add_development_dependency "thin"
gem.add_development_dependency "uglifier"
end
6 changes: 0 additions & 6 deletions gemfiles/Gemfile_rails_5.0.rb

This file was deleted.

6 changes: 0 additions & 6 deletions gemfiles/Gemfile_rails_5.1.rb

This file was deleted.

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.

6 changes: 2 additions & 4 deletions gemfiles/Gemfile_rails_6.1.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
source "https://rubygems.org"
source 'https://rubygems.org'

gemspec path: '..'

gem 'rails', '~> 6.1.0'
gem 'net-smtp'
gem 'net-pop'
gem 'net-imap'
gem 'sqlite3', '~> 1.4'
6 changes: 6 additions & 0 deletions gemfiles/Gemfile_rails_7.0.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source 'https://rubygems.org'

gemspec path: '..'

gem 'rails', '~> 7.0.0'
gem 'sqlite3', '~> 1.4'
6 changes: 6 additions & 0 deletions gemfiles/Gemfile_rails_7.1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source 'https://rubygems.org'

gemspec path: '..'

gem 'rails', '~> 7.1.0'
gem 'sqlite3', '~> 1.4'
8 changes: 0 additions & 8 deletions lib/chanko/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ class Railtie < Rails::Railtie
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.
# 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).
Chanko::Loader.prepare_eager_load(mode: :classic)
end

initializer("chanko.eager_load_units", before: :eager_load!) do |app|
# This is why we need handmade eager-loading
# https://github.com/cookpad/chanko/pull/38
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 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
action_view_instance
end

let(:options) do
Expand Down
15 changes: 1 addition & 14 deletions spec/chanko/test_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,11 @@

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

def rails6_action_view_instance
let(:view) do
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
end

describe "#enable_unit" do
it "forces to enable specified unit" do
enable_unit(:inactive_unit)
Expand Down
21 changes: 8 additions & 13 deletions spec/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,15 @@ 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

# for Rails 6.1
if config.respond_to?("assets")
config.assets.version = '1.0'
config.assets.quiet = true
end

config.autoloader = :zeitwerk
end
end

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