diff --git a/Gemfile b/Gemfile index 1454eeb..1fa9ed2 100644 --- a/Gemfile +++ b/Gemfile @@ -1,8 +1,8 @@ source :rubygems gem 'rake' -gem 'activerecord', ENV['AR'] || '~>3.2.11' -gem 'railties', ENV['AR'] || '~>3.2.11' +gem 'activerecord', ENV['AR'] || '~> 4.0.0.beta1' +gem 'railties', ENV['AR'] || '~> 4.0.0.beta1' group :dev do gem 'sqlite3' diff --git a/Gemfile.lock b/Gemfile.lock index 38d2c1b..6b78866 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,83 +1,75 @@ GEM remote: http://rubygems.org/ specs: - actionpack (3.2.11) - activemodel (= 3.2.11) - activesupport (= 3.2.11) - builder (~> 3.0.0) + actionpack (4.0.0.beta1) + activesupport (= 4.0.0.beta1) + builder (~> 3.1.0) erubis (~> 2.7.0) - journey (~> 1.0.4) - rack (~> 1.4.0) - rack-cache (~> 1.2) - rack-test (~> 0.6.1) - sprockets (~> 2.2.1) - activemodel (3.2.11) - activesupport (= 3.2.11) - builder (~> 3.0.0) - activerecord (3.2.11) - activemodel (= 3.2.11) - activesupport (= 3.2.11) - arel (~> 3.0.2) - tzinfo (~> 0.3.29) - activesupport (3.2.11) - i18n (~> 0.6) - multi_json (~> 1.0) - arel (3.0.2) - builder (3.0.4) - diff-lcs (1.1.3) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + activemodel (4.0.0.beta1) + activesupport (= 4.0.0.beta1) + builder (~> 3.1.0) + activerecord (4.0.0.beta1) + activemodel (= 4.0.0.beta1) + activerecord-deprecated_finders (~> 0.0.3) + activesupport (= 4.0.0.beta1) + arel (~> 4.0.0.beta1) + activerecord-deprecated_finders (0.0.3) + activesupport (4.0.0.beta1) + i18n (~> 0.6.2) + minitest (~> 4.2) + multi_json (~> 1.3) + thread_safe (~> 0.1) + tzinfo (~> 0.3.33) + arel (4.0.0.beta1) + atomic (1.0.1) + builder (3.1.4) + diff-lcs (1.2.1) erubis (2.7.0) git (1.2.5) - hike (1.2.1) - i18n (0.6.1) - jeweler (1.6.4) + i18n (0.6.2) + jeweler (1.8.4) bundler (~> 1.0) git (>= 1.2.5) rake - journey (1.0.4) - json (1.7.6) - multi_json (1.5.0) - rack (1.4.4) - rack-cache (1.2) - rack (>= 0.4) - rack-ssl (1.3.3) - rack + rdoc + json (1.7.7) + minitest (4.6.1) + multi_json (1.6.1) + rack (1.5.2) rack-test (0.6.2) rack (>= 1.0) - railties (3.2.11) - actionpack (= 3.2.11) - activesupport (= 3.2.11) - rack-ssl (~> 1.3.2) + railties (4.0.0.beta1) + actionpack (= 4.0.0.beta1) + activesupport (= 4.0.0.beta1) rake (>= 0.8.7) rdoc (~> 3.4) - thor (>= 0.14.6, < 2.0) - rake (0.9.2.2) - rdoc (3.12) + thor (>= 0.17.0, < 2.0) + rake (10.0.3) + rdoc (3.12.2) json (~> 1.4) - rspec (2.7.0) - rspec-core (~> 2.7.0) - rspec-expectations (~> 2.7.0) - rspec-mocks (~> 2.7.0) - rspec-core (2.7.1) - rspec-expectations (2.7.0) - diff-lcs (~> 1.1.2) - rspec-mocks (2.7.0) - sprockets (2.2.2) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.6) + rspec (2.13.0) + rspec-core (~> 2.13.0) + rspec-expectations (~> 2.13.0) + rspec-mocks (~> 2.13.0) + rspec-core (2.13.0) + rspec-expectations (2.13.0) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.13.0) + sqlite3 (1.3.7) thor (0.17.0) - tilt (1.3.3) + thread_safe (0.1.0) + atomic tzinfo (0.3.35) PLATFORMS ruby DEPENDENCIES - activerecord (~> 3.2.11) + activerecord (~> 4.0.0.beta1) jeweler - railties (~> 3.2.11) + railties (~> 4.0.0.beta1) rake rspec (~> 2) sqlite3 diff --git a/lib/standalone_migrations.rb b/lib/standalone_migrations.rb index 79fdecc..18aea1c 100644 --- a/lib/standalone_migrations.rb +++ b/lib/standalone_migrations.rb @@ -1,6 +1,10 @@ lib_path = File.expand_path("../", __FILE__) $:.unshift lib_path unless $:.include?(lib_path) +if !ENV["RAILS_ENV"] + ENV["RAILS_ENV"] = ENV["DB"] || ENV["RACK_ENV"] || "development" +end + require "rubygems" require "rails" require "active_record" @@ -13,7 +17,3 @@ require "standalone_migrations/minimal_railtie_config" require "standalone_migrations/tasks" - -if !ENV["RAILS_ENV"] - ENV["RAILS_ENV"] = ENV["DB"] || ENV["RACK_ENV"] || Rails.env || "development" -end diff --git a/spec/standalone_migrations_spec.rb b/spec/standalone_migrations_spec.rb index 0dbf1a8..a6e4474 100644 --- a/spec/standalone_migrations_spec.rb +++ b/spec/standalone_migrations_spec.rb @@ -31,8 +31,7 @@ def make_migration(name, options={}) task_name = options[:task_name] || 'db:new_migration' migration = run("rake #{task_name} name=#{name}").match(%r{db/migrate/\d+.*.rb})[0] content = read(migration) - content.sub!(/def down.*?\send/m, "def down;puts 'DOWN-#{name}';end") - content.sub!(/def up.*?\send/m, "def up;puts 'UP-#{name}';end") + content.sub!(/def change.*?\send/m, "def change; reversible {|dir| dir.up{ puts 'UP-#{name}' }; dir.down{ puts 'DOWN-#{name}'}}; end") write(migration, content) migration.match(/\d{14}/)[0] end @@ -53,23 +52,29 @@ def write_multiple_migrations write_rakefile %{t.migrations = "db/migrations", "db/migrations2"} write "db/migrate/20100509095815_create_tests.rb", <<-TXT class CreateTests < ActiveRecord::Migration - def up - puts "UP-CreateTests" - end - - def down - puts "DOWN-CreateTests" + def change + reversible { |dir| + dir.up { + puts "UP-CreateTests" + } + dir.down{ + puts "DOWN-CreateTests" + } + } end end TXT write "db/migrate/20100509095816_create_tests2.rb", <<-TXT class CreateTests2 < ActiveRecord::Migration - def up - puts "UP-CreateTests2" - end - - def down - puts "DOWN-CreateTests2" + def change + reversible { |dir| + dir.up { + puts "UP-CreateTests2" + } + dir.down{ + puts "DOWN-CreateTests2" + } + } end end TXT diff --git a/standalone_migrations.gemspec b/standalone_migrations.gemspec index 227fad5..0303654 100644 --- a/standalone_migrations.gemspec +++ b/standalone_migrations.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Todd Huss", "Michael Grosser"] - s.date = "2013-02-25" + s.date = "2013-02-27" s.email = "thuss@gabrito.com" s.extra_rdoc_files = [ "README.markdown" @@ -46,7 +46,7 @@ Gem::Specification.new do |s| ] s.homepage = "http://github.com/thuss/standalone-migrations" s.require_paths = ["lib"] - s.rubygems_version = "1.8.24" + s.rubygems_version = "1.8.23" s.summary = "A thin wrapper to use Rails Migrations in non Rails projects" if s.respond_to? :specification_version then @@ -54,17 +54,17 @@ Gem::Specification.new do |s| if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then s.add_runtime_dependency(%q, [">= 0"]) - s.add_runtime_dependency(%q, ["~> 3.2.11"]) - s.add_runtime_dependency(%q, ["~> 3.2.11"]) + s.add_runtime_dependency(%q, ["~> 4.0.0.beta1"]) + s.add_runtime_dependency(%q, ["~> 4.0.0.beta1"]) else s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, ["~> 3.2.11"]) - s.add_dependency(%q, ["~> 3.2.11"]) + s.add_dependency(%q, ["~> 4.0.0.beta1"]) + s.add_dependency(%q, ["~> 4.0.0.beta1"]) end else s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, ["~> 3.2.11"]) - s.add_dependency(%q, ["~> 3.2.11"]) + s.add_dependency(%q, ["~> 4.0.0.beta1"]) + s.add_dependency(%q, ["~> 4.0.0.beta1"]) end end