Skip to content

Commit

Permalink
Merge pull request #2006 from tf/rails-version-helper
Browse files Browse the repository at this point in the history
Move RailsVersion helper from support to core gem
  • Loading branch information
tf authored Sep 21, 2023
2 parents 92ca368 + 1cef387 commit c9376d2
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 16 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/.rails_version
/.ruby-version
/coverage
/Gemfile.lock
Expand All @@ -13,4 +12,4 @@ spec/dummy/*
.localeapp

/node_modules
/packages/*/node_modules
/packages/*/node_modules
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion bin/rspec
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/spring.rb
Original file line number Diff line number Diff line change
@@ -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}")
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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
2 changes: 1 addition & 1 deletion pageflow.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion spec/support/pageflow-support.gemspec
Original file line number Diff line number Diff line change
@@ -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'
Expand Down

0 comments on commit c9376d2

Please sign in to comment.