From a5b41b0b74856720ad703ec731831f1fab6cda5b 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-vr.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pageflow-vr.gemspec b/pageflow-vr.gemspec index 44abbc4..84116de 100644 --- a/pageflow-vr.gemspec +++ b/pageflow-vr.gemspec @@ -15,7 +15,7 @@ Gem::Specification.new do |spec| spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } spec.require_paths = ['lib'] - spec.required_ruby_version = '~> 2.1' + spec.required_ruby_version = '>= 2.1' spec.add_dependency 'pageflow', ['>= 12.0', '< 17'] spec.add_dependency 'pageflow-public-i18n', '~> 1.10' From 644f9900028db99876596d3dc9ce172f6f8842b7 Mon Sep 17 00:00:00 2001 From: Tim Fischbach Date: Fri, 29 Sep 2023 09:38:40 +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`. Rename root file in lib which does not follow Zeitwerk conventions. Bundler will replace `-` with `/` in the gem name when requiring 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-vr.rb => pageflow/vr.rb} | 1 + lib/pageflow/vr/engine.rb | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) rename lib/{pageflow-vr.rb => pageflow/vr.rb} (95%) diff --git a/lib/pageflow-vr.rb b/lib/pageflow/vr.rb similarity index 95% rename from lib/pageflow-vr.rb rename to lib/pageflow/vr.rb index 80989fd..68c07cd 100644 --- a/lib/pageflow-vr.rb +++ b/lib/pageflow/vr.rb @@ -1,4 +1,5 @@ require 'pageflow/vr/engine' +require 'pageflow/vr/version' module Pageflow module Vr diff --git a/lib/pageflow/vr/engine.rb b/lib/pageflow/vr/engine.rb index c3b7473..c722325 100644 --- a/lib/pageflow/vr/engine.rb +++ b/lib/pageflow/vr/engine.rb @@ -3,7 +3,22 @@ module Vr class Engine < Rails::Engine isolate_namespace Pageflow::Vr - 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_vr.autoloading' do + Rails.autoloaders.main.ignore( + lib.join('pageflow/vr/version.rb'), + lib.join('generators') + ) + end + else + config.autoload_paths << File.join(config.root, 'lib') + end + config.i18n.load_path += Dir[config.root.join('config', 'locales', '**', '*.yml').to_s] initializer "pageflow-vr.add_watchable_files", group: :all do |app| From 88ac3fcb998619f88fa89bcbed0b137c8c40695f 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 | 13 ++++++++++--- pageflow-vr.gemspec | 8 +++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index cb6a04e..8d1d891 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,14 @@ source 'https://rubygems.org' # Specify your gem's dependencies in pageflow-vr.gemspec gemspec -group :development, :test do - # Help Bundler resolve dependencies - 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 + group :development, :test do + # Help Bundler resolve dependencies + gem 'rails', '~> 5.2.0' + end end diff --git a/pageflow-vr.gemspec b/pageflow-vr.gemspec index 84116de..14b4858 100644 --- a/pageflow-vr.gemspec +++ b/pageflow-vr.gemspec @@ -23,6 +23,12 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'bundler', ['>= 1.12', '< 3'] spec.add_development_dependency 'pageflow-support', ['>= 14', '< 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 + spec.add_development_dependency 'semmy', '~> 1.0' end