From 1cef3876a2afcb09683cde07d9701c44a0b3aa6d Mon Sep 17 00:00:00 2001 From: Tim Fischbach Date: Thu, 21 Sep 2023 11:05:06 +0200 Subject: [PATCH] Move RailsVersion helper from support to core gem Now also used by production code. REDMINE-19438 --- .gitignore | 3 +-- Gemfile | 2 +- bin/rspec | 2 +- config/spring.rb | 2 +- {spec/support => lib}/pageflow/rails_version.rb | 10 +--------- pageflow.gemspec | 2 +- spec/support/pageflow-support.gemspec | 2 +- 7 files changed, 7 insertions(+), 16 deletions(-) rename {spec/support => lib}/pageflow/rails_version.rb (50%) diff --git a/.gitignore b/.gitignore index 9583d02998..c7808883ed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -/.rails_version /.ruby-version /coverage /Gemfile.lock @@ -13,4 +12,4 @@ spec/dummy/* .localeapp /node_modules -/packages/*/node_modules \ No newline at end of file +/packages/*/node_modules diff --git a/Gemfile b/Gemfile index f58fa80db5..c8e160760c 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source "https://rubygems.org" gemspec -require File.expand_path('spec/support/pageflow/rails_version', File.dirname(__FILE__)) +require File.expand_path('lib/pageflow/rails_version', File.dirname(__FILE__)) gem 'rails', Pageflow::RailsVersion.detect gem 'pageflow-support', path: 'spec/support' diff --git a/bin/rspec b/bin/rspec index 8305140549..c5ee52f93e 100755 --- a/bin/rspec +++ b/bin/rspec @@ -1,7 +1,7 @@ #!/usr/bin/env ruby ENV['RAILS_ENV'] ||= 'test' -require File.expand_path('../spec/support/pageflow/rails_version', File.dirname(__FILE__)) +require File.expand_path('../lib/pageflow/rails_version', File.dirname(__FILE__)) dummy_root = File.expand_path("../spec/dummy/rails-#{Pageflow::RailsVersion.detect}", File.dirname(__FILE__)) begin diff --git a/config/spring.rb b/config/spring.rb index 690ab1c4e1..40d8b9a020 100644 --- a/config/spring.rb +++ b/config/spring.rb @@ -1,2 +1,2 @@ -require File.expand_path('../spec/support/pageflow/rails_version', File.dirname(__FILE__)) +require File.expand_path('../lib/pageflow/rails_version', File.dirname(__FILE__)) Spring.application_root = File.join(__FILE__, "../../spec/dummy/rails-#{Pageflow::RailsVersion.detect}") diff --git a/spec/support/pageflow/rails_version.rb b/lib/pageflow/rails_version.rb similarity index 50% rename from spec/support/pageflow/rails_version.rb rename to lib/pageflow/rails_version.rb index 3b9610aaad..739d571735 100644 --- a/spec/support/pageflow/rails_version.rb +++ b/lib/pageflow/rails_version.rb @@ -2,10 +2,8 @@ module Pageflow module RailsVersion extend self - RAILS_VERSION_FILE = File.expand_path('../../../../.rails_version') - def detect - from_env || from_file || '5.2.0' + from_env || '5.2.0' end def experimental? @@ -17,11 +15,5 @@ def experimental? def from_env ENV['PAGEFLOW_RAILS_VERSION'] if ENV['PAGEFLOW_RAILS_VERSION'] != '' end - - def from_file - if File.exist?(RAILS_VERSION_FILE) - File.read(RAILS_VERSION_FILE).chomp.strip.presence - end - end end end diff --git a/pageflow.gemspec b/pageflow.gemspec index a34d479a1f..a00d6e7d08 100644 --- a/pageflow.gemspec +++ b/pageflow.gemspec @@ -2,7 +2,7 @@ lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'pageflow/version' -require File.expand_path('spec/support/pageflow/rails_version', File.dirname(__FILE__)) +require File.expand_path('lib/pageflow/rails_version', File.dirname(__FILE__)) Gem::Specification.new do |s| s.name = 'pageflow' diff --git a/spec/support/pageflow-support.gemspec b/spec/support/pageflow-support.gemspec index 5d61b26cc8..527d940acc 100644 --- a/spec/support/pageflow-support.gemspec +++ b/spec/support/pageflow-support.gemspec @@ -1,7 +1,7 @@ $:.push File.expand_path('../../../lib', __FILE__) require 'pageflow/version' -require File.expand_path('pageflow/rails_version', File.dirname(__FILE__)) +require 'pageflow/rails_version' Gem::Specification.new do |s| s.name = 'pageflow-support'