Skip to content

Commit

Permalink
change support version
Browse files Browse the repository at this point in the history
  • Loading branch information
eudoxa committed Apr 26, 2024
1 parent a544457 commit 4c707fa
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 107 deletions.
34 changes: 5 additions & 29 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"
- "3.2"
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 }}
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
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'
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', '*'))

0 comments on commit 4c707fa

Please sign in to comment.