migration_assist 0.1.2
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/.document +5 -0
- data/.gitignore +21 -0
- data/.rspec +1 -0
- data/LICENSE +20 -0
- data/README.markdown +81 -0
- data/Rakefile +19 -0
- data/VERSION +1 -0
- data/lib/generators/migration/migration_generator.rb +18 -0
- data/lib/generators/migration/templates/create_users.erb +14 -0
- data/lib/migration_assist.rb +10 -0
- data/lib/migration_assist/class_methods.rb +38 -0
- data/lib/migration_assist/helper/file_name.rb +56 -0
- data/lib/migration_assist/implementation.rb +39 -0
- data/migration_assist.gemspec +77 -0
- data/spec/generators/migration_generator_spec.rb +45 -0
- data/spec/load_spec.rb +3 -0
- data/spec/migration_assist/class_methods_spec.rb +60 -0
- data/spec/migration_assist/fixtures/001_migration_a.rb +0 -0
- data/spec/migration_assist/fixtures/002_migration_b.rb +0 -0
- data/spec/migration_assist/fixtures/003_migration_a.rb +0 -0
- data/spec/migration_assist/fixtures/004_migration_c.rb +0 -0
- data/spec/migration_assist/implementation_spec.rb +43 -0
- data/spec/spec_helper.rb +10 -0
- metadata +126 -0
data/.document
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--format nested --color
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Kristian Mandrup
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# Migration Assistant
|
2
|
+
|
3
|
+
Assists in handling migrations, including generating migration files from a Thor Generator
|
4
|
+
The *Migration Assistant* includes specialized functionality for operating with *Active Record* migrations.
|
5
|
+
|
6
|
+
## Install
|
7
|
+
|
8
|
+
<code>gem install migration_assist</code>
|
9
|
+
|
10
|
+
## Usage
|
11
|
+
|
12
|
+
First you have to tell the gem where your Rails root directory is located so it can calculate the migrations dir from that for its operation.
|
13
|
+
|
14
|
+
Example:
|
15
|
+
<pre>
|
16
|
+
Rails::Migration::Assist.rails_root_dir = Rails.root
|
17
|
+
</pre>
|
18
|
+
|
19
|
+
A common use case for using this gem, is when you are creating code Generators that create Active Record migrations.
|
20
|
+
In this case you would add this Helper to your generator sth. like this
|
21
|
+
|
22
|
+
<pre>
|
23
|
+
require 'migration_assist'
|
24
|
+
require 'rails3_assist'
|
25
|
+
|
26
|
+
class MigrationGenerator < Rails::Generators::NamedBase
|
27
|
+
include Rails::Migration::Assist
|
28
|
+
include Rails::Assist::Migration # from rails3_assist
|
29
|
+
|
30
|
+
...
|
31
|
+
end
|
32
|
+
<pre>
|
33
|
+
|
34
|
+
In the above example we also included the migration helper from the *rails3_assist* gem, which adds some migration CRUD functionality to the mix.
|
35
|
+
|
36
|
+
### Class methods:
|
37
|
+
|
38
|
+
* migrations_list(dirname=nil)*
|
39
|
+
|
40
|
+
list of migrations
|
41
|
+
|
42
|
+
*first_migration_file: (name, dir=nil) - alias: *migration_exists?*
|
43
|
+
|
44
|
+
Get the first migration file matching a given name
|
45
|
+
|
46
|
+
*latest_migration_file: (dirname, file_name)*
|
47
|
+
|
48
|
+
Get the latest migration file matching a given name
|
49
|
+
|
50
|
+
*current_migration_number(dirname=nil)*
|
51
|
+
|
52
|
+
Return the highest migration number of the current migration files
|
53
|
+
|
54
|
+
*next_migration_number(dirname=nil)*
|
55
|
+
|
56
|
+
Often used to generate the number to prefix a new generated migration file
|
57
|
+
|
58
|
+
### Instance methods
|
59
|
+
|
60
|
+
*migration (name)*
|
61
|
+
|
62
|
+
Generate a new named migration using a template [name].erb to be found in a template source path (thor)
|
63
|
+
|
64
|
+
*reverse_migration! (migration_path=nil)*
|
65
|
+
|
66
|
+
Reverse a given migration, by switching the up and down methods and
|
67
|
+
changing the migration name, fx from Add to Remove or Create to Drop.
|
68
|
+
|
69
|
+
## Note on Patches/Pull Requests
|
70
|
+
|
71
|
+
* Fork the project.
|
72
|
+
* Make your feature addition or bug fix.
|
73
|
+
* Add tests for it. This is important so I don't break it in a
|
74
|
+
future version unintentionally.
|
75
|
+
* Commit, do not mess with rakefile, version, or history.
|
76
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
77
|
+
* Send me a pull request. Bonus points for topic branches.
|
78
|
+
|
79
|
+
## Copyright
|
80
|
+
|
81
|
+
Copyright (c) 2010 Kristian Mandrup. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |gem|
|
4
|
+
gem.name = "migration_assist"
|
5
|
+
gem.summary = %Q{Assists in handling migrations}
|
6
|
+
gem.description = %Q{Assists in handling migrations, including generating migration files from a Thor Generator}
|
7
|
+
gem.email = "kmandrup@gmail.com"
|
8
|
+
gem.homepage = "http://github.com/kristianmandrup/migration_assist"
|
9
|
+
gem.authors = ["Kristian Mandrup"]
|
10
|
+
gem.add_development_dependency "rspec", ">= 2.0.0.beta.19"
|
11
|
+
|
12
|
+
gem.add_dependency "require_all", ">= 1.1.0"
|
13
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
14
|
+
end
|
15
|
+
Jeweler::GemcutterTasks.new
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
18
|
+
end
|
19
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.2
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
require 'rails3_assist'
|
4
|
+
|
5
|
+
class MigrationGenerator < Rails::Generators::NamedBase
|
6
|
+
include Rails::Migration::Assist
|
7
|
+
|
8
|
+
desc "Creates a migration"
|
9
|
+
|
10
|
+
def self.source_root
|
11
|
+
@source_root ||= File.expand_path("../templates", __FILE__)
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_migration
|
15
|
+
# info "Create migration: #{name} from template: 'create_users'"
|
16
|
+
migration name, 'create_users'
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# NOTE:
|
2
|
+
# Alternative to use this helper is to inherit from ActiveRecord::Generators::Base
|
3
|
+
# which provides the #next_migration_number class method that lets #migration_template work as expected
|
4
|
+
#
|
5
|
+
module Rails::Migration::Assist
|
6
|
+
def self.included(base) #:nodoc:
|
7
|
+
base.extend ClassMethods
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
def migration_lookup_at(dirname) #:nodoc:
|
12
|
+
Dir.glob("#{dirname}/[0-9]*_*.rb")
|
13
|
+
end
|
14
|
+
|
15
|
+
def migration_exists?(dirname, file_name) #:nodoc:
|
16
|
+
migration_lookup_at(dirname).grep(/\d+_#{file_name}.rb$/).first
|
17
|
+
end
|
18
|
+
alias_method :first_migration_file, :migration_exists?
|
19
|
+
|
20
|
+
def latest_migration_file(dirname, file_name) #:nodoc:
|
21
|
+
migration_lookup_at(dirname).grep(/\d+_#{file_name}.rb$/).sort.last
|
22
|
+
end
|
23
|
+
|
24
|
+
def current_migration_number(dirname) #:nodoc:
|
25
|
+
migration_lookup_at(dirname).collect do |file|
|
26
|
+
File.basename(file).split("_").first.to_i
|
27
|
+
end.max.to_i
|
28
|
+
end
|
29
|
+
|
30
|
+
def next_migration_number(dirname) #:nodoc:
|
31
|
+
orm = Rails.configuration.generators.options[:rails][:orm]
|
32
|
+
require "rails/generators/#{orm}"
|
33
|
+
"#{orm.to_s.camelize}::Generators::Base".constantize.next_migration_number(dirname)
|
34
|
+
rescue
|
35
|
+
raise NotImplementedError
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Rails::Migration::Assist
|
2
|
+
class << self
|
3
|
+
attr_accessor :rails_root_dir
|
4
|
+
end
|
5
|
+
|
6
|
+
module FileNameHelper
|
7
|
+
def artifact_path name, type, dir=nil
|
8
|
+
dir ||= send :"#{type}_dir"
|
9
|
+
File.join(dir, "#{name}#{type_postfix type}.rb")
|
10
|
+
end
|
11
|
+
|
12
|
+
def type_postfix type
|
13
|
+
"_#{type}" if ![:model].include?(type)
|
14
|
+
end
|
15
|
+
|
16
|
+
def make_file_name name, type, options={}
|
17
|
+
send :"#{type}_file_name", name, options
|
18
|
+
end
|
19
|
+
|
20
|
+
def existing_file_name name, type
|
21
|
+
# first try finder method
|
22
|
+
finder_method = :"find_#{type}"
|
23
|
+
found = send finder_method, name if respond_to? finder_method
|
24
|
+
# default
|
25
|
+
make_file_name(name, type) if !found
|
26
|
+
end
|
27
|
+
|
28
|
+
def find_migration name, option=nil
|
29
|
+
migrations = Dir.glob("#{migration_dir}/[0-9]*_*.rb")
|
30
|
+
return nil if !migrations.empty?
|
31
|
+
matching_migrations = migrations.grep(/\d+_#{name}\.rb$/)
|
32
|
+
return nil if matching_migrations.empty?
|
33
|
+
migration_file = (option == :last) ? matching_migrations.last : matching_migrations.first
|
34
|
+
end
|
35
|
+
|
36
|
+
def migration_file_name name, options={}
|
37
|
+
number = options[:number]
|
38
|
+
number = next_migration_number(migration_dir) if !number
|
39
|
+
File.join(migration_dir, "#{number}_#{name}.rb")
|
40
|
+
end
|
41
|
+
|
42
|
+
def root_dir
|
43
|
+
dir = Migration::Assist.rails_root_dir
|
44
|
+
raise "You must set the Rails app root dir: Rails::Migration::Assist.rails_root_dir = '/my/root/dir'" if !dir
|
45
|
+
dir
|
46
|
+
end
|
47
|
+
|
48
|
+
def db_dir
|
49
|
+
File.join(root_dir, 'db')
|
50
|
+
end
|
51
|
+
|
52
|
+
def migration_dir
|
53
|
+
File.join(db_dir, 'migrations')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
require 'migration_assist/helper/file_name'
|
4
|
+
|
5
|
+
module Rails::Migration::Assist
|
6
|
+
include Rails::Generators::Migration
|
7
|
+
# include Rails::Assist::Migration
|
8
|
+
include FileNameHelper
|
9
|
+
|
10
|
+
def reverse_migration_name name
|
11
|
+
name.gsub(/^add_/, 'remove_').gsub(/^create_/, 'drop_')
|
12
|
+
end
|
13
|
+
|
14
|
+
def reverse_migration! migration_path
|
15
|
+
reverse_class_names! migration_path
|
16
|
+
reverse_up_down_methods! migration_path
|
17
|
+
end
|
18
|
+
|
19
|
+
def reverse_class_names! migration_path
|
20
|
+
# Change class name
|
21
|
+
gsub_file migration_path, /class Add/, 'class Remove'
|
22
|
+
gsub_file migration_path, /class Create/, 'class Drop'
|
23
|
+
end
|
24
|
+
|
25
|
+
def reverse_up_down_methods! migration_path
|
26
|
+
# swap up and down methods
|
27
|
+
gsub_file migration_path, /up/, 'dwn'
|
28
|
+
gsub_file migration_path, /down/, 'up'
|
29
|
+
gsub_file migration_path, /dwn/, 'down'
|
30
|
+
end
|
31
|
+
|
32
|
+
def latest_migration_file dir, name
|
33
|
+
self.class.latest_migration_file dir, name
|
34
|
+
end
|
35
|
+
|
36
|
+
def migration name, template_name=nil
|
37
|
+
migration_template "#{template_name || name}.erb", migration_file_name(name)
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{migration_assist}
|
8
|
+
s.version = "0.1.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Kristian Mandrup"]
|
12
|
+
s.date = %q{2010-08-19}
|
13
|
+
s.description = %q{Assists in handling migrations, including generating migration files from a Thor Generator}
|
14
|
+
s.email = %q{kmandrup@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.markdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
".rspec",
|
23
|
+
"LICENSE",
|
24
|
+
"README.markdown",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"lib/generators/migration/migration_generator.rb",
|
28
|
+
"lib/generators/migration/templates/create_users.erb",
|
29
|
+
"lib/migration_assist.rb",
|
30
|
+
"lib/migration_assist/class_methods.rb",
|
31
|
+
"lib/migration_assist/helper/file_name.rb",
|
32
|
+
"lib/migration_assist/implementation.rb",
|
33
|
+
"migration_assist.gemspec",
|
34
|
+
"spec/generators/migration_generator_spec.rb",
|
35
|
+
"spec/load_spec.rb",
|
36
|
+
"spec/migration_assist/class_methods_spec.rb",
|
37
|
+
"spec/migration_assist/fixtures/001_migration_a.rb",
|
38
|
+
"spec/migration_assist/fixtures/002_migration_b.rb",
|
39
|
+
"spec/migration_assist/fixtures/003_migration_a.rb",
|
40
|
+
"spec/migration_assist/fixtures/004_migration_c.rb",
|
41
|
+
"spec/migration_assist/implementation_spec.rb",
|
42
|
+
"spec/spec_helper.rb"
|
43
|
+
]
|
44
|
+
s.homepage = %q{http://github.com/kristianmandrup/migration_assist}
|
45
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
46
|
+
s.require_paths = ["lib"]
|
47
|
+
s.rubygems_version = %q{1.3.7}
|
48
|
+
s.summary = %q{Assists in handling migrations}
|
49
|
+
s.test_files = [
|
50
|
+
"spec/generators/migration_generator_spec.rb",
|
51
|
+
"spec/load_spec.rb",
|
52
|
+
"spec/migration_assist/class_methods_spec.rb",
|
53
|
+
"spec/migration_assist/fixtures/001_migration_a.rb",
|
54
|
+
"spec/migration_assist/fixtures/002_migration_b.rb",
|
55
|
+
"spec/migration_assist/fixtures/003_migration_a.rb",
|
56
|
+
"spec/migration_assist/fixtures/004_migration_c.rb",
|
57
|
+
"spec/migration_assist/implementation_spec.rb",
|
58
|
+
"spec/spec_helper.rb"
|
59
|
+
]
|
60
|
+
|
61
|
+
if s.respond_to? :specification_version then
|
62
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
63
|
+
s.specification_version = 3
|
64
|
+
|
65
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
66
|
+
s.add_development_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
|
67
|
+
s.add_runtime_dependency(%q<require_all>, [">= 1.1.0"])
|
68
|
+
else
|
69
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
|
70
|
+
s.add_dependency(%q<require_all>, [">= 1.1.0"])
|
71
|
+
end
|
72
|
+
else
|
73
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
|
74
|
+
s.add_dependency(%q<require_all>, [">= 1.1.0"])
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
# require 'migration-spec'
|
3
|
+
# require 'rails3_assist'
|
4
|
+
|
5
|
+
# RSpec::Generator.debug = true
|
6
|
+
#
|
7
|
+
# require_generator :migration
|
8
|
+
#
|
9
|
+
# describe 'migration_generator' do
|
10
|
+
# use_orm :active_record
|
11
|
+
# use_helpers :migration, :helper
|
12
|
+
#
|
13
|
+
# before :each do
|
14
|
+
# setup_generator 'migration_generator' do
|
15
|
+
# tests MigrationGenerator
|
16
|
+
# end
|
17
|
+
# remove_migration :create_users
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# after :each do
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# it "should generate create_user migration" do
|
24
|
+
# with_generator do |g|
|
25
|
+
# g.run_generator :create_users.args
|
26
|
+
# g.should generate_migration :create_users do |content|
|
27
|
+
# content.should have_migration :create_users do |klass|
|
28
|
+
# klass.should have_up do |up|
|
29
|
+
# up.should have_create_table :users do |user_tbl|
|
30
|
+
# user_tbl.should have_columns :name => :string, :age => :integer, :admin => :boolean
|
31
|
+
# user_tbl.should_not have_timestamps
|
32
|
+
# end
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# klass.should have_down do |up|
|
36
|
+
# up.should have_drop_table :users
|
37
|
+
# end
|
38
|
+
# end
|
39
|
+
# end
|
40
|
+
# end
|
41
|
+
# end
|
42
|
+
# end
|
43
|
+
#
|
44
|
+
#
|
45
|
+
#
|
data/spec/load_spec.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rails'
|
3
|
+
|
4
|
+
class TestGenerator
|
5
|
+
include Rails::Migration::Assist
|
6
|
+
end
|
7
|
+
|
8
|
+
describe 'Migration Assist' do
|
9
|
+
let(:dir) { fixtures_dir }
|
10
|
+
let(:generator) { TestGenerator.new }
|
11
|
+
|
12
|
+
before :each do
|
13
|
+
end
|
14
|
+
|
15
|
+
after :each do
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#migration_lookup_at' do
|
19
|
+
it "should return 4 migrations" do
|
20
|
+
generator.class.migration_lookup_at(dir).should have(4).items
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#migration_exists?' do
|
25
|
+
it "should verify migration 'a' exists" do
|
26
|
+
generator.class.migration_exists?(dir, 'migration_a').should include('001_migration_a.rb')
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should verify migration 'c' exists" do
|
30
|
+
generator.class.migration_exists?(dir, 'migration_c').should include('004_migration_c.rb')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#first_migration_file' do
|
35
|
+
it "should find first migration 'a'" do
|
36
|
+
generator.class.first_migration_file(dir, 'migration_a').should include('001_migration_a.rb')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#latest_migration_file' do
|
41
|
+
it "should lookup latest migration 'a' " do
|
42
|
+
generator.class.latest_migration_file(dir, 'migration_a').should include('003_migration_a.rb')
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should lookup latest migration 'b' " do
|
46
|
+
generator.class.latest_migration_file(dir, 'migration_b').should include('002_migration_b.rb')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#current_migration_number' do
|
51
|
+
it "should find current migration number 4" do
|
52
|
+
generator.class.current_migration_number(dir).should be 4
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#next_migration_number' do
|
57
|
+
it "should find next migration number 5" do
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# RSpec::Generator.debug = true
|
4
|
+
#
|
5
|
+
# require_generator :migration
|
6
|
+
#
|
7
|
+
# describe 'migration_generator' do
|
8
|
+
# use_orm :active_record
|
9
|
+
# use_helpers :migration, :helper
|
10
|
+
#
|
11
|
+
# before :each do
|
12
|
+
# setup_generator 'migration_generator' do
|
13
|
+
# tests MigrationGenerator
|
14
|
+
# end
|
15
|
+
# remove_migration :create_users
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# after :each do
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# it "should generate create_user migration" do
|
22
|
+
# with_generator do |g|
|
23
|
+
# g.run_generator :create_users.args
|
24
|
+
# g.should generate_migration :create_users do |content|
|
25
|
+
# content.should have_migration :create_users do |klass|
|
26
|
+
# klass.should have_up do |up|
|
27
|
+
# up.should have_create_table :users do |user_tbl|
|
28
|
+
# user_tbl.should have_columns :name => :string, :age => :integer, :admin => :boolean
|
29
|
+
# user_tbl.should_not have_timestamps
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# klass.should have_down do |up|
|
34
|
+
# up.should have_drop_table :users
|
35
|
+
# end
|
36
|
+
# end
|
37
|
+
# end
|
38
|
+
# end
|
39
|
+
# end
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
#
|
43
|
+
#
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: migration_assist
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Kristian Mandrup
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-08-19 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 2
|
30
|
+
- 0
|
31
|
+
- 0
|
32
|
+
- beta
|
33
|
+
- 19
|
34
|
+
version: 2.0.0.beta.19
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: require_all
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
segments:
|
46
|
+
- 1
|
47
|
+
- 1
|
48
|
+
- 0
|
49
|
+
version: 1.1.0
|
50
|
+
type: :runtime
|
51
|
+
version_requirements: *id002
|
52
|
+
description: Assists in handling migrations, including generating migration files from a Thor Generator
|
53
|
+
email: kmandrup@gmail.com
|
54
|
+
executables: []
|
55
|
+
|
56
|
+
extensions: []
|
57
|
+
|
58
|
+
extra_rdoc_files:
|
59
|
+
- LICENSE
|
60
|
+
- README.markdown
|
61
|
+
files:
|
62
|
+
- .document
|
63
|
+
- .gitignore
|
64
|
+
- .rspec
|
65
|
+
- LICENSE
|
66
|
+
- README.markdown
|
67
|
+
- Rakefile
|
68
|
+
- VERSION
|
69
|
+
- lib/generators/migration/migration_generator.rb
|
70
|
+
- lib/generators/migration/templates/create_users.erb
|
71
|
+
- lib/migration_assist.rb
|
72
|
+
- lib/migration_assist/class_methods.rb
|
73
|
+
- lib/migration_assist/helper/file_name.rb
|
74
|
+
- lib/migration_assist/implementation.rb
|
75
|
+
- migration_assist.gemspec
|
76
|
+
- spec/generators/migration_generator_spec.rb
|
77
|
+
- spec/load_spec.rb
|
78
|
+
- spec/migration_assist/class_methods_spec.rb
|
79
|
+
- spec/migration_assist/fixtures/001_migration_a.rb
|
80
|
+
- spec/migration_assist/fixtures/002_migration_b.rb
|
81
|
+
- spec/migration_assist/fixtures/003_migration_a.rb
|
82
|
+
- spec/migration_assist/fixtures/004_migration_c.rb
|
83
|
+
- spec/migration_assist/implementation_spec.rb
|
84
|
+
- spec/spec_helper.rb
|
85
|
+
has_rdoc: true
|
86
|
+
homepage: http://github.com/kristianmandrup/migration_assist
|
87
|
+
licenses: []
|
88
|
+
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options:
|
91
|
+
- --charset=UTF-8
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
version: "0"
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
version: "0"
|
110
|
+
requirements: []
|
111
|
+
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 1.3.7
|
114
|
+
signing_key:
|
115
|
+
specification_version: 3
|
116
|
+
summary: Assists in handling migrations
|
117
|
+
test_files:
|
118
|
+
- spec/generators/migration_generator_spec.rb
|
119
|
+
- spec/load_spec.rb
|
120
|
+
- spec/migration_assist/class_methods_spec.rb
|
121
|
+
- spec/migration_assist/fixtures/001_migration_a.rb
|
122
|
+
- spec/migration_assist/fixtures/002_migration_b.rb
|
123
|
+
- spec/migration_assist/fixtures/003_migration_a.rb
|
124
|
+
- spec/migration_assist/fixtures/004_migration_c.rb
|
125
|
+
- spec/migration_assist/implementation_spec.rb
|
126
|
+
- spec/spec_helper.rb
|