Skip to content

Commit

Permalink
Merge pull request #83 from ojab/rails-6
Browse files Browse the repository at this point in the history
rails-6 support
jenseng authored Sep 4, 2019
2 parents 567ace9 + 24d5bc6 commit 3e4ec04
Showing 8 changed files with 53 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/Gemfile.lock
/gemfiles/*.lock
/gemfiles/.bundle
/*.gem
/pkg
/tmp
12 changes: 11 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
sudo: false
language: ruby
services:
- mysql
- postgresql
env: DB_CONFIG=travis
rvm:
- 2.3.8
@@ -9,11 +12,18 @@ gemfile:
- gemfiles/activerecord_5.0.gemfile
- gemfiles/activerecord_5.1.gemfile
- gemfiles/activerecord_5.2.gemfile
- gemfiles/activerecord_6.0.gemfile
- gemfiles/activerecord_edge.gemfile
matrix:
exclude:
- gemfile: gemfiles/activerecord_6.0.gemfile
rvm: 2.3.8
- gemfile: gemfiles/activerecord_6.0.gemfile
rvm: 2.4.5
- gemfile: gemfiles/activerecord_edge.gemfile
rvm: 2.3.7
rvm: 2.3.8
- gemfile: gemfiles/activerecord_edge.gemfile
rvm: 2.4.5
allow_failures:
- gemfile: gemfiles/activerecord_edge.gemfile
bundler_args: --without development
9 changes: 8 additions & 1 deletion Appraisals
Original file line number Diff line number Diff line change
@@ -19,10 +19,17 @@ appraise "activerecord-5.2" do
gem "sqlite3", "~> 1.3.6"
end

appraise "activerecord-6.0" do
gem "activerecord", "~> 6.0.0"
gem "mysql2", "~> 0.4.10"
gem "pg", ">= 0.18", "< 2.0"
gem "sqlite3", "~> 1.4.0"
end

appraise "activerecord-edge" do
gem "arel", github: "rails/arel"
gem "activerecord", github: "rails/rails"
gem "mysql2", "~> 0.4.10"
gem "pg", ">= 0.18", "< 2.0"
gem "sqlite3", "~> 1.3.6"
gem "sqlite3", "~> 1.4.0"
end
20 changes: 20 additions & 0 deletions gemfiles/activerecord_6.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "activerecord", "~> 6.0.0"
gem "mysql2", "~> 0.4.10"
gem "pg", ">= 0.18", "< 2.0"
gem "sqlite3", "~> 1.4.0"

group :development do
gem "appraisal"
gem "byebug"
end

group :test do
gem "rake", "~> 10.0"
gem "rspec", "~> 2.14.0"
end

gemspec path: "../"
2 changes: 1 addition & 1 deletion gemfiles/activerecord_edge.gemfile
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ gem "arel", :github => "rails/arel"
gem "activerecord", :github => "rails/rails"
gem "mysql2", "~> 0.4.10"
gem "pg", ">= 0.18", "< 2.0"
gem "sqlite3", "~> 1.3.6"
gem "sqlite3", "~> 1.4.0"

group :development do
gem "appraisal"
2 changes: 1 addition & 1 deletion hairtrigger.gemspec
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|

s.files = %w(LICENSE.txt Rakefile README.md) + Dir['lib/**/*.rb'] + Dir['lib/**/*.rake']

s.add_dependency 'activerecord', '>= 5.0', '< 6.0'
s.add_dependency 'activerecord', '>= 5.0', '< 7'
s.add_dependency 'ruby_parser', '~> 3.10'
s.add_dependency 'ruby2ruby', '~> 2.4'
end
10 changes: 8 additions & 2 deletions lib/hair_trigger.rb
Original file line number Diff line number Diff line change
@@ -40,13 +40,19 @@ def models

def migrator
version = ActiveRecord::VERSION::STRING
if version >= "5.2."
if version >= "6.0."
migrations = ActiveRecord::MigrationContext.new(migration_path, ActiveRecord::SchemaMigration).migrations
elsif version >= "5.2."
migrations = ActiveRecord::MigrationContext.new(migration_path).migrations
else # version >= "4.0."
migrations = ActiveRecord::Migrator.migrations(migration_path)
end

ActiveRecord::Migrator.new(:up, migrations)
if version >= "6.0."
ActiveRecord::Migrator.new(:up, migrations, ActiveRecord::SchemaMigration)
else
ActiveRecord::Migrator.new(:up, migrations)
end
end

def current_migrations(options = {})
4 changes: 3 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -75,7 +75,9 @@ def initialize_db

def migrate_db
ActiveRecord::Migration.verbose = false
if ActiveRecord::VERSION::STRING >= "5.2"
if ActiveRecord::VERSION::STRING >= "6.0"
ActiveRecord::MigrationContext.new(HairTrigger.migration_path, ActiveRecord::SchemaMigration).migrate
elsif ActiveRecord::VERSION::STRING >= "5.2"
ActiveRecord::MigrationContext.new(HairTrigger.migration_path).migrate
else
ActiveRecord::Migrator.migrate(HairTrigger.migration_path)

0 comments on commit 3e4ec04

Please sign in to comment.