dm-migrations 0.9.7 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1 +1,3 @@
1
+ === 0.9.8 / 2008-12-07
1
2
 
3
+ * No changes this version
data/Manifest.txt CHANGED
@@ -36,3 +36,6 @@ spec/unit/sql/table_creator_spec.rb
36
36
  spec/unit/sql/table_modifier_spec.rb
37
37
  spec/unit/sql/table_spec.rb
38
38
  spec/unit/sql_spec.rb
39
+ tasks/db.rb
40
+ tasks/install.rb
41
+ tasks/spec.rb
data/Rakefile CHANGED
@@ -1,81 +1,25 @@
1
- require 'rubygems'
2
- require 'spec'
3
- require 'spec/rake/spectask'
4
1
  require 'pathname'
2
+ require 'rubygems'
3
+
4
+ ROOT = Pathname(__FILE__).dirname.expand_path
5
+ JRUBY = RUBY_PLATFORM =~ /java/
6
+ WINDOWS = Gem.win_platform?
7
+ SUDO = (WINDOWS || JRUBY) ? '' : ('sudo' unless ENV['SUDOLESS'])
5
8
 
6
- ROOT = Pathname(__FILE__).dirname.expand_path
7
9
  require ROOT + 'lib/dm-migrations/version'
8
10
 
9
- AUTHOR = "Paul Sadauskas"
10
- EMAIL = "psadauskas@gmail.com"
11
- GEM_NAME = "dm-migrations"
11
+ AUTHOR = 'Paul Sadauskas'
12
+ EMAIL = 'psadauskas [a] gmail [d] com'
13
+ GEM_NAME = 'dm-migrations'
12
14
  GEM_VERSION = DataMapper::Migration::VERSION
13
- GEM_DEPENDENCIES = [["dm-core", '~>0.9.7']]
14
- GEM_CLEAN = ["log", "pkg"]
15
- GEM_EXTRAS = { :has_rdoc => true, :extra_rdoc_files => %w[ README.txt LICENSE TODO ] }
16
-
17
- PROJECT_NAME = "datamapper"
18
- PROJECT_URL = "http://github.com/sam/dm-more/tree/master/dm-migrations"
19
- PROJECT_DESCRIPTION = PROJECT_SUMMARY = "DataMapper plugin for writing and speccing migrations"
20
-
21
- require ROOT.parent + 'tasks/hoe'
22
-
23
- task :default => [ :spec ]
24
-
25
- WIN32 = (RUBY_PLATFORM =~ /win32|mingw|cygwin/) rescue nil
26
- SUDO = WIN32 ? '' : ('sudo' unless ENV['SUDOLESS'])
27
-
28
- desc "Install #{GEM_NAME} #{GEM_VERSION} (default ruby)"
29
- task :install => [ :package ] do
30
- sh "#{SUDO} gem install --local pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources", :verbose => false
31
- end
32
-
33
- desc "Uninstall #{GEM_NAME} #{GEM_VERSION} (default ruby)"
34
- task :uninstall => [ :clobber ] do
35
- sh "#{SUDO} gem uninstall #{GEM_NAME} -v#{GEM_VERSION} -I -x", :verbose => false
36
- end
37
-
38
- namespace :jruby do
39
- desc "Install #{GEM_NAME} #{GEM_VERSION} with JRuby"
40
- task :install => [ :package ] do
41
- sh %{#{SUDO} jruby -S gem install --local pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources}, :verbose => false
42
- end
43
- end
44
-
45
- desc 'Run specifications'
46
- Spec::Rake::SpecTask.new(:spec) do |t|
47
- t.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
48
- t.spec_files = Pathname.glob((ROOT + 'spec/**/*_spec.rb').to_s)
49
-
50
- begin
51
- t.rcov = ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true
52
- t.rcov_opts << '--exclude' << 'spec'
53
- t.rcov_opts << '--text-summary'
54
- t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
55
- rescue Exception
56
- # rcov not installed
57
- end
58
- end
59
-
60
- namespace :db do
61
-
62
- # pass the relative path to the migrations directory by MIGRATION_DIR
63
- task :setup_migration_dir do
64
- unless defined?(MIGRATION_DIR)
65
- migration_dir = ENV["MIGRATION_DIR"] || File.join("db", "migrations")
66
- MIGRATION_DIR = File.expand_path(File.join(File.dirname(__FILE__), migration_dir))
67
- end
68
- FileUtils.mkdir_p MIGRATION_DIR
69
- end
70
-
71
- # set DIRECTION to migrate down
72
- desc "Run your system's migrations"
73
- task :migrate => [:setup_migration_dir] do
74
- require File.expand_path(File.join(File.dirname(__FILE__), "lib", "migration_runner.rb"))
75
- require File.expand_path(File.join(MIGRATION_DIR, "config.rb"))
15
+ GEM_DEPENDENCIES = [['dm-core', "~>#{GEM_VERSION}"]]
16
+ GEM_CLEAN = %w[ log pkg coverage ]
17
+ GEM_EXTRAS = { :has_rdoc => true, :extra_rdoc_files => %w[ README.txt LICENSE TODO History.txt ] }
76
18
 
77
- Dir[File.join(MIGRATION_DIR, "*.rb")].each { |file| require file }
19
+ PROJECT_NAME = 'datamapper'
20
+ PROJECT_URL = "http://github.com/sam/dm-more/tree/master/#{GEM_NAME}"
21
+ PROJECT_DESCRIPTION = PROJECT_SUMMARY = 'DataMapper plugin for writing and speccing migrations'
78
22
 
79
- ENV["DIRECTION"] != "down" ? migrate_up! : migrate_down!
80
- end
23
+ [ ROOT, ROOT.parent ].each do |dir|
24
+ Pathname.glob(dir.join('tasks/**/*.rb').to_s).each { |f| require f }
81
25
  end
data/TODO CHANGED
@@ -1,8 +0,0 @@
1
- TODO
2
- ====
3
-
4
-
5
-
6
- ---
7
- TODO tickets may also be found in the DataMapper Issue Tracker:
8
- http://wm.lighthouseapp.com/projects/4819-datamapper/overview
@@ -1,5 +1,5 @@
1
1
  module DataMapper
2
2
  class Migration
3
- VERSION = "0.9.7"
3
+ VERSION = '0.9.8'
4
4
  end
5
5
  end
data/lib/migration.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'rubygems'
2
- gem 'dm-core', '~>0.9.7'
2
+ gem 'dm-core', '~>0.9.8'
3
3
  require 'dm-core'
4
4
  require 'benchmark'
5
5
  require File.dirname(__FILE__) + '/sql'
@@ -196,19 +196,21 @@ module DataMapper
196
196
 
197
197
  # Quoted table name, for the adapter
198
198
  def migration_info_table
199
- @migration_info_table ||= @adapter.send(:quote_table_name, 'migration_info')
199
+ @migration_info_table ||= quote_table_name('migration_info')
200
200
  end
201
201
 
202
202
  # Quoted `migration_name` column, for the adapter
203
203
  def migration_name_column
204
- @migration_name_column ||= @adapter.send(:quote_column_name, 'migration_name')
204
+ @migration_name_column ||= quote_column_name('migration_name')
205
205
  end
206
206
 
207
207
  def quote_table_name(table_name)
208
+ # TODO: Fix this for 1.9 - can't use this hack to access a private method
208
209
  @adapter.send(:quote_table_name, table_name.to_s)
209
210
  end
210
211
 
211
212
  def quote_column_name(column_name)
213
+ # TODO: Fix this for 1.9 - can't use this hack to access a private method
212
214
  @adapter.send(:quote_column_name, column_name.to_s)
213
215
  end
214
216
  end
@@ -1,8 +1,7 @@
1
1
  require 'pathname'
2
2
  require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
3
3
 
4
- [:sqlite3, :mysql, :postgres].each do |adapter|
5
- next unless eval("HAS_#{adapter.to_s.upcase}")
4
+ ADAPTERS.each do |adapter|
6
5
  describe "Using Adapter #{adapter}, " do
7
6
  describe 'empty migration runner' do
8
7
  it "should return an empty array if no migrations have been defined" do
@@ -1,8 +1,7 @@
1
1
  require 'pathname'
2
2
  require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
3
3
 
4
- [:sqlite3, :mysql, :postgres].each do |adapter|
5
- next unless eval("HAS_#{adapter.to_s.upcase}")
4
+ ADAPTERS.each do |adapter|
6
5
  describe "Using Adapter #{adapter}, " do
7
6
  describe DataMapper::Migration, 'interface' do
8
7
  before do
@@ -51,25 +50,15 @@ require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
51
50
  [m1, m2, m3, m4].sort.should == [m1, m3, m2, m4]
52
51
  end
53
52
 
54
- if HAS_SQLITE3
55
- it "should extend with SQL::Sqlite3 when adapter is Sqlite3Adapter" do
56
- migration = DataMapper::Migration.new(1, :sqlite3_adapter_test, :database => :sqlite3) { }
57
- (class << migration.adapter; self; end).included_modules.should include(SQL::Sqlite3)
58
- end
59
- end
60
-
61
- if HAS_MYSQL
62
- it "should extend with SQL::Mysql when adapter is MysqlAdapter" do
63
- migration = DataMapper::Migration.new(1, :mysql_adapter_test, :database => :mysql) { }
64
- (class << migration.adapter; self; end).included_modules.should include(SQL::Mysql)
65
- end
66
- end
53
+ expected_module = {
54
+ :sqlite3 => lambda { SQL::Sqlite3 },
55
+ :mysql => lambda { SQL::Mysql },
56
+ :postgres => lambda { SQL::Postgresql }
57
+ }[adapter][]
67
58
 
68
- if HAS_POSTGRES
69
- it "should extend with SQL::Postgres when adapter is PostgresAdapter" do
70
- migration = DataMapper::Migration.new(1, :postgres_adapter_test, :database => :postgres) { }
71
- (class << migration.adapter; self; end).included_modules.should include(SQL::Postgresql)
72
- end
59
+ it "should extend with #{expected_module} when adapter is #{adapter}" do
60
+ migration = DataMapper::Migration.new(1, :"#{adapter}_adapter_test", :database => adapter) { }
61
+ (class << migration.adapter; self; end).included_modules.should include(expected_module)
73
62
  end
74
63
  end
75
64
 
@@ -1,8 +1,7 @@
1
1
  require 'pathname'
2
2
  require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
3
3
 
4
- [:sqlite3, :mysql, :postgres].each do |adapter|
5
- next unless eval("HAS_#{adapter.to_s.upcase}")
4
+ ADAPTERS.each do |adapter|
6
5
  describe "Using Adapter #{adapter}," do
7
6
  describe DataMapper::Migration, "#create_table helper" do
8
7
  before do
@@ -111,12 +110,12 @@ require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
111
110
  @migration.send(:needs_down?).should be_true
112
111
  end
113
112
 
114
- it "should properly quote the migration_info table for use in queries" do
115
- @migration.send(:migration_info_table).should == '"migration_info"'
113
+ it "should properly quote the migration_info table via the adapter for use in queries" do
114
+ @migration.send(:migration_info_table).should == @migration.quote_table_name("migration_info")
116
115
  end
117
116
 
118
- it "should properly quote the migration_info.migration_name column for use in queries" do
119
- @migration.send(:migration_name_column).should == '"migration_name"'
117
+ it "should properly quote the migration_info.migration_name column via the adapter for use in queries" do
118
+ @migration.send(:migration_name_column).should == @migration.quote_column_name("migration_name")
120
119
  end
121
120
 
122
121
  it "should properly quote the migration's name for use in queries"
data/spec/spec.opts CHANGED
@@ -1,2 +1 @@
1
1
  --colour
2
- --format progress
data/spec/spec_helper.rb CHANGED
@@ -1,30 +1,27 @@
1
+ require 'pathname'
1
2
  require 'rubygems'
2
- gem 'rspec', '>=1.1.3'
3
+
4
+ gem 'rspec', '~>1.1.11'
3
5
  require 'spec'
4
- require 'pathname'
6
+
5
7
  require Pathname(__FILE__).dirname.parent.expand_path + 'lib/dm-migrations'
6
8
  require Pathname(__FILE__).dirname.parent.expand_path + 'lib/migration_runner'
7
9
 
10
+ ADAPTERS = []
8
11
  def load_driver(name, default_uri)
9
- #return false if ENV['ADAPTER'] != name.to_s
10
-
11
- lib = "do_#{name}"
12
-
13
12
  begin
14
- gem lib, '~>0.9.7'
15
- require lib
16
13
  DataMapper.setup(name, default_uri)
17
14
  DataMapper::Repository.adapters[:default] = DataMapper::Repository.adapters[name]
18
- puts "Loaded #{name}"
15
+ ADAPTERS << name
19
16
  true
20
- rescue Gem::LoadError => e
21
- warn "Could not load #{lib}: #{e}"
17
+ rescue LoadError => e
18
+ warn "Could not load do_#{name}: #{e}"
22
19
  false
23
20
  end
24
21
  end
25
22
 
26
- ENV['ADAPTER'] ||= 'sqlite3'
23
+ #ENV['ADAPTER'] ||= 'sqlite3'
27
24
 
28
- HAS_SQLITE3 = load_driver(:sqlite3, 'sqlite3::memory:')
29
- HAS_MYSQL = load_driver(:mysql, 'mysql://localhost/dm_core_test')
30
- HAS_POSTGRES = load_driver(:postgres, 'postgres://postgres@localhost/dm_core_test')
25
+ load_driver(:sqlite3, 'sqlite3::memory:')
26
+ load_driver(:mysql, 'mysql://localhost/dm_core_test')
27
+ load_driver(:postgres, 'postgres://postgres@localhost/dm_core_test')
data/tasks/db.rb ADDED
@@ -0,0 +1,22 @@
1
+ namespace :db do
2
+
3
+ # pass the relative path to the migrations directory by MIGRATION_DIR
4
+ task :setup_migration_dir do
5
+ unless defined?(MIGRATION_DIR)
6
+ migration_dir = ENV["MIGRATION_DIR"] || File.join("db", "migrations")
7
+ MIGRATION_DIR = File.expand_path(File.join(File.dirname(__FILE__), migration_dir))
8
+ end
9
+ FileUtils.mkdir_p MIGRATION_DIR
10
+ end
11
+
12
+ # set DIRECTION to migrate down
13
+ desc "Run your system's migrations"
14
+ task :migrate => [:setup_migration_dir] do
15
+ require File.expand_path(File.join(File.dirname(__FILE__), "lib", "migration_runner.rb"))
16
+ require File.expand_path(File.join(MIGRATION_DIR, "config.rb"))
17
+
18
+ Dir[File.join(MIGRATION_DIR, "*.rb")].each { |file| require file }
19
+
20
+ ENV["DIRECTION"] != "down" ? migrate_up! : migrate_down!
21
+ end
22
+ end
data/tasks/install.rb ADDED
@@ -0,0 +1,13 @@
1
+ def sudo_gem(cmd)
2
+ sh "#{SUDO} #{RUBY} -S gem #{cmd}", :verbose => false
3
+ end
4
+
5
+ desc "Install #{GEM_NAME} #{GEM_VERSION}"
6
+ task :install => [ :package ] do
7
+ sudo_gem "install --local pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources"
8
+ end
9
+
10
+ desc "Uninstall #{GEM_NAME} #{GEM_VERSION}"
11
+ task :uninstall => [ :clobber ] do
12
+ sudo_gem "uninstall #{GEM_NAME} -v#{GEM_VERSION} -Ix"
13
+ end
data/tasks/spec.rb ADDED
@@ -0,0 +1,25 @@
1
+ begin
2
+ gem 'rspec', '~>1.1.11'
3
+ require 'spec'
4
+ require 'spec/rake/spectask'
5
+
6
+ task :default => [ :spec ]
7
+
8
+ desc 'Run specifications'
9
+ Spec::Rake::SpecTask.new(:spec) do |t|
10
+ t.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
11
+ t.spec_files = Pathname.glob((ROOT + 'spec/**/*_spec.rb').to_s)
12
+
13
+ begin
14
+ gem 'rcov', '~>0.8'
15
+ t.rcov = JRUBY ? false : (ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true)
16
+ t.rcov_opts << '--exclude' << 'spec'
17
+ t.rcov_opts << '--text-summary'
18
+ t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
19
+ rescue LoadError
20
+ # rcov not installed
21
+ end
22
+ end
23
+ rescue LoadError
24
+ # rspec not installed
25
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Sadauskas
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-18 00:00:00 -08:00
12
+ date: 2008-12-07 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,21 +20,11 @@ dependencies:
20
20
  requirements:
21
21
  - - ~>
22
22
  - !ruby/object:Gem::Version
23
- version: 0.9.7
24
- version:
25
- - !ruby/object:Gem::Dependency
26
- name: hoe
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 1.8.2
23
+ version: 0.9.8
34
24
  version:
35
25
  description: DataMapper plugin for writing and speccing migrations
36
26
  email:
37
- - psadauskas@gmail.com
27
+ - psadauskas [a] gmail [d] com
38
28
  executables: []
39
29
 
40
30
  extensions: []
@@ -43,6 +33,7 @@ extra_rdoc_files:
43
33
  - README.txt
44
34
  - LICENSE
45
35
  - TODO
36
+ - History.txt
46
37
  files:
47
38
  - History.txt
48
39
  - LICENSE
@@ -82,6 +73,9 @@ files:
82
73
  - spec/unit/sql/table_modifier_spec.rb
83
74
  - spec/unit/sql/table_spec.rb
84
75
  - spec/unit/sql_spec.rb
76
+ - tasks/db.rb
77
+ - tasks/install.rb
78
+ - tasks/spec.rb
85
79
  has_rdoc: true
86
80
  homepage: http://github.com/sam/dm-more/tree/master/dm-migrations
87
81
  post_install_message: