From 9aaacdcce3f6db4cafdfe8bda7a227919e013d7d Mon Sep 17 00:00:00 2001 From: Tim Fischbach Date: Mon, 25 Sep 2023 16:43:48 +0200 Subject: [PATCH 1/3] Relax Ruby version requirement Allow upgrading to Ruby 3. Only define lower compatibility bound from now on to ease future updates REDMINE-19438 --- pageflow-text-page.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pageflow-text-page.gemspec b/pageflow-text-page.gemspec index c030ba9..1355cad 100644 --- a/pageflow-text-page.gemspec +++ b/pageflow-text-page.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ['lib'] - spec.required_ruby_version = '~> 2.1' + spec.required_ruby_version = '>= 2.1' spec.add_runtime_dependency 'pageflow', ['>= 15', '< 17'] spec.add_runtime_dependency 'pageflow-public-i18n', '~> 1.0' From 85f260fdc103778afee96641ea16151444fb214e Mon Sep 17 00:00:00 2001 From: Tim Fischbach Date: Fri, 29 Sep 2023 09:17:15 +0200 Subject: [PATCH 2/3] Fix Zeitwerk compatibility Add paths to both `autoload_paths` and `eager_load_paths`. `eager_load_paths` is required to have paths covered by `zeitwerk:check`. Ignore root file in lib which does not follow Zeitwerk conventions, but is required for Bundler to be able to require the gem. For Rails < 6, we cannot add `lib` to the `eager_load_paths` since Resque eager loads [1], which then evaluates the engine class a second time. This time `autoload_paths` is already frozen, resulting in an error. REDMINE-19438 [1] https://github.com/resque/resque/blob/v1.27.4/lib/resque/tasks.rb#L45 --- lib/pageflow-text-page.rb | 1 + lib/pageflow/text_page/engine.rb | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/pageflow-text-page.rb b/lib/pageflow-text-page.rb index 9c47594..73dd629 100644 --- a/lib/pageflow-text-page.rb +++ b/lib/pageflow-text-page.rb @@ -1,4 +1,5 @@ require 'pageflow/text_page/engine' +require 'pageflow/text_page/version' module Pageflow module TextPage diff --git a/lib/pageflow/text_page/engine.rb b/lib/pageflow/text_page/engine.rb index 1f78bd2..df797e0 100644 --- a/lib/pageflow/text_page/engine.rb +++ b/lib/pageflow/text_page/engine.rb @@ -5,7 +5,22 @@ module TextPage class Engine < Rails::Engine isolate_namespace Pageflow::TextPage - config.autoload_paths << File.join(config.root, 'lib') + if Rails.respond_to?(:autoloaders) + lib = root.join('lib') + + config.autoload_paths << lib + config.eager_load_paths << lib + + initializer 'pageflow_text_page.autoloading' do + Rails.autoloaders.main.ignore( + lib.join('pageflow-text-page.rb'), + lib.join('pageflow/text_page/version.rb') + ) + end + else + config.autoload_paths << File.join(config.root, 'lib') + end + config.i18n.load_path += Dir[config.root.join('config', 'locales', '**', '*.yml').to_s] end end From d115f5d59b6a36acc4fd275534c6b19cc16db887 Mon Sep 17 00:00:00 2001 From: Tim Fischbach Date: Mon, 2 Oct 2023 09:01:48 +0200 Subject: [PATCH 3/3] Allow running specs against Pageflow edge The reusable workflow now runs specs against experimental Rails versions which require Pageflow to be installed from a git source. REDMINE-19438 --- Gemfile | 11 +++++++++-- pageflow-text-page.gemspec | 7 ++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 4b6d606..516286b 100644 --- a/Gemfile +++ b/Gemfile @@ -3,5 +3,12 @@ source 'https://rubygems.org' # Specify your gem's dependencies in chart.gemspec gemspec -# Help bundler not exceed time limit -gem 'rails', '~> 5.2.0' +if ENV['PAGEFLOW_DEPENDENCIES'] == 'experimental' + git 'https://github.com/codevise/pageflow', branch: 'edge', glob: '**/*.gemspec' do + gem 'pageflow' + gem 'pageflow-support' + end +else + # Help bundler not exceed time limit + gem 'rails', '~> 5.2.0' +end diff --git a/pageflow-text-page.gemspec b/pageflow-text-page.gemspec index 1355cad..7aee98a 100644 --- a/pageflow-text-page.gemspec +++ b/pageflow-text-page.gemspec @@ -24,7 +24,12 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'bundler', ['>= 1.0', '< 3'] spec.add_development_dependency 'pageflow-support', ['>= 15', '< 17'] spec.add_development_dependency 'rake', '~> 12.0' - spec.add_development_dependency 'rspec-rails', '~> 3.0' + + if ENV['PAGEFLOW_DEPENDENCIES'] == 'experimental' + spec.add_development_dependency 'rspec-rails', '~> 6.0' + else + spec.add_development_dependency 'rspec-rails', '~> 3.0' + end # Semantic versioning rake tasks spec.add_development_dependency 'semmy', '~> 1.0'