Skip to content

Commit e3f182d

Browse files
committed
change version comparison from string to
Gem::Version
1 parent 3ed594f commit e3f182d

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

lib/ransack/constants.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module Constants
4848
RAILS_5_1 = '5.1'.freeze
4949
RAILS_5_2 = '5.2'.freeze
5050
RAILS_5_2_0 = '5.2.0'.freeze
51-
RAILS_6_0 = '6.0.0.rc1'.freeze
51+
RAILS_6_0 = '6.0.0'.freeze
5252

5353
RANSACK_SLASH_SEARCHES = 'ransack/searches'.freeze
5454
RANSACK_SLASH_SEARCHES_SLASH_SEARCH = 'ransack/searches/search'.freeze

polyamorous/lib/polyamorous.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ module Polyamorous
1212
require 'polyamorous/swapping_reflection_class'
1313

1414
ar_version = ::ActiveRecord::VERSION::STRING[0,3]
15-
ar_version = ::ActiveRecord::VERSION::STRING[0,5] if ar_version >= "5.2" && ::ActiveRecord::VERSION::STRING < "6.0"
16-
ar_version = "5.2.1" if ::ActiveRecord::VERSION::STRING >= "5.2.1" && ::ActiveRecord::VERSION::STRING < "6.0"
17-
15+
ar_version = ::ActiveRecord::VERSION::STRING[0,5] if ar_version >= "5.2" && ::ActiveRecord.version < ::Gem::Version.new("6.0")
16+
ar_version = "5.2.1" if ::ActiveRecord::VERSION::STRING >= "5.2.1" && ::ActiveRecord.version < ::Gem::Version.new("6.0")
1817
%w(join_association join_dependency).each do |file|
1918
require "polyamorous/activerecord_#{ar_version}_ruby_2/#{file}"
2019
end

ransack.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
2222
s.add_development_dependency 'rspec', '~> 3'
2323
s.add_development_dependency 'machinist', '~> 1.0.6'
2424
s.add_development_dependency 'faker', '~> 0.9.5'
25-
s.add_development_dependency 'sqlite3', ENV['RAILS'] == '6-0-stable' ? '~> 1.4.1' : '~> 1.3.3'
25+
s.add_development_dependency 'sqlite3', ::Gem::Version.new(ENV['RAILS'].gsub(/^v/, '')) >= ::Gem::Version.new('6-0-stable') ? '~> 1.4.1' : '~> 1.3.3'
2626
s.add_development_dependency 'pg', '~> 0.21'
2727
s.add_development_dependency 'mysql2', '0.3.20'
2828
s.add_development_dependency 'pry', '0.10'

spec/helpers/polyamorous_helper.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ def new_join_association(reflection, children, klass)
33
Polyamorous::JoinAssociation.new reflection, children, klass
44
end
55

6-
if ActiveRecord::VERSION::STRING >= "6.0.0.rc1"
6+
if ActiveRecord.version >= ::Gem::Version.new("6.0.0.rc1")
77
def new_join_dependency(klass, associations = {})
88
Polyamorous::JoinDependency.new klass, klass.arel_table, associations, Polyamorous::InnerJoin
99
end
10-
elsif ActiveRecord::VERSION::STRING > "5.2.0"
10+
elsif ActiveRecord.version > ::Gem::Version.new("5.2.0")
1111
def new_join_dependency(klass, associations = {})
1212
Polyamorous::JoinDependency.new klass, klass.arel_table, associations
1313
end
14-
elsif ActiveRecord::VERSION::STRING == "5.2.0"
14+
elsif ActiveRecord.version == ::Gem::Version.new("5.2.0")
1515
def new_join_dependency(klass, associations = {})
1616
alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(klass.connection, klass.table_name, [])
1717
Polyamorous::JoinDependency.new klass, klass.arel_table, associations, alias_tracker

0 commit comments

Comments
 (0)