migration_assist 0.1.9 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -13,7 +13,7 @@ First you have to tell the gem where your Rails root directory is located so it
13
13
 
14
14
  Example:
15
15
  <pre>
16
- Rails3::Migration::Assist.rails_root_dir = Rails.root
16
+ RailsAssist::Migration.rails_root_dir = Rails.root
17
17
  </pre>
18
18
 
19
19
  A common use case for using this gem, is when you are creating code Generators that create Active Record migrations.
@@ -21,12 +21,10 @@ In this case you would add this Helper to your generator sth. like this
21
21
 
22
22
  <pre>
23
23
  require 'migration_assist'
24
- require 'rails3_assist'
24
+ require 'rails_assist'
25
25
 
26
26
  class MigrationGenerator < Rails::Generators::NamedBase
27
- include Rails3::Migration::Assist
28
- include Rails3::Assist::Migration # from rails3_assist
29
-
27
+ include RailsAssist::Migration
30
28
  ...
31
29
  end
32
30
  </pre>
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ require 'psych'
2
+
1
3
  begin
2
4
  require 'jeweler'
3
5
  Jeweler::Tasks.new do |gem|
@@ -7,9 +9,9 @@ begin
7
9
  gem.email = "kmandrup@gmail.com"
8
10
  gem.homepage = "http://github.com/kristianmandrup/migration_assist"
9
11
  gem.authors = ["Kristian Mandrup"]
10
- gem.add_development_dependency "rspec", ">= 2.0.1"
11
- gem.add_development_dependency "mocha", ">= 0.9.8"
12
- gem.add_development_dependency "generator-spec", ">= 0.7.1"
12
+ gem.add_development_dependency "rspec", ">= 2.4.1"
13
+ gem.add_development_dependency "mocha", ">= 0.9.8"
14
+ gem.add_development_dependency "generator-spec", ">= 0.7.3"
13
15
 
14
16
  gem.add_dependency "require_all", "~> 1.2.0"
15
17
  gem.add_dependency "rails", ">= 3.0.1"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.9
1
+ 0.2.0
@@ -2,7 +2,7 @@
2
2
  # Alternative to use this helper is to inherit from ActiveRecord::Generators::Base
3
3
  # which provides the #next_migration_number class method that lets #migration_template work as expected
4
4
  #
5
- module Rails3::Migration::Assist
5
+ module RailsAssist::Migration
6
6
  class << self
7
7
  attr_accessor :rails_root_dir
8
8
  attr_accessor :orm
@@ -13,7 +13,7 @@ module Rails3::Migration::Assist
13
13
  end
14
14
 
15
15
  def next_migration_number(dirname) #:nodoc:
16
- orm = Rails3::Migration::Assist.orm || Rails.configuration.generators.options[:rails][:orm]
16
+ orm = RailsAssist::Migration.orm || Rails.configuration.generators.options[:rails][:orm]
17
17
  require "rails/generators/#{orm}"
18
18
  "#{orm.to_s.camelize}::Generators::Base".constantize.next_migration_number(dirname)
19
19
  rescue
@@ -42,7 +42,7 @@ module Rails3::Migration::Assist
42
42
  end
43
43
 
44
44
  def next_migration_number(dirname) #:nodoc:
45
- orm = Rails3::Migration::Assist.orm || Rails.configuration.generators.options[:rails][:orm]
45
+ orm = RailsAssist::Migration.orm || Rails.configuration.generators.options[:rails][:orm]
46
46
  require "rails/generators/#{orm}"
47
47
  "#{orm.to_s.camelize}::Generators::Base".constantize.next_migration_number(dirname)
48
48
  rescue
@@ -1,4 +1,4 @@
1
- module Rails3::Migration::Assist
1
+ module RailsAssist::Migration
2
2
  module FileNameHelper
3
3
  def artifact_path name, type, dir=nil
4
4
  dir ||= send :"#{type}_dir"
@@ -36,7 +36,7 @@ module Rails3::Migration::Assist
36
36
  end
37
37
 
38
38
  def root_dir
39
- dir = Rails3::Migration::Assist.rails_root_dir || Rails.root
39
+ dir = RailsAssist::Migration.rails_root_dir || Rails.root
40
40
  raise "You must set the Rails app root dir: Rails3::Migration::Assist.rails_root_dir = '/my/root/dir'" if !dir
41
41
  dir
42
42
  end
@@ -2,7 +2,7 @@ require 'rails/generators'
2
2
  require 'rails/generators/migration'
3
3
  require 'migration_assist/helper/file_name'
4
4
 
5
- module Rails3::Migration::Assist
5
+ module RailsAssist::Migration
6
6
  include Rails::Generators::Migration
7
7
  include FileNameHelper
8
8
 
@@ -1,6 +1,4 @@
1
- module Rails3
1
+ module RailsAssist
2
2
  module Migration
3
- module Assist
4
- end
5
3
  end
6
4
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{migration_assist}
8
- s.version = "0.1.9"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
12
- s.date = %q{2010-12-20}
12
+ s.date = %q{2011-03-04}
13
13
  s.description = %q{Assists in handling migrations, including generating migration files from a Thor Generator}
14
14
  s.email = %q{kmandrup@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -29,6 +29,9 @@ Gem::Specification.new do |s|
29
29
  "lib/migration_assist/implementation.rb",
30
30
  "lib/migration_assist/namespaces.rb",
31
31
  "migration_assist.gemspec",
32
+ "spec/TODO.textile",
33
+ "spec/generators/migration/migration_generator.rb",
34
+ "spec/generators/migration/templates/create_users.erb",
32
35
  "spec/load_spec.rb",
33
36
  "spec/migration_assist/class_methods_spec.rb",
34
37
  "spec/migration_assist/fixtures/001_migration_a.rb",
@@ -40,9 +43,10 @@ Gem::Specification.new do |s|
40
43
  ]
41
44
  s.homepage = %q{http://github.com/kristianmandrup/migration_assist}
42
45
  s.require_paths = ["lib"]
43
- s.rubygems_version = %q{1.3.7}
46
+ s.rubygems_version = %q{1.6.1}
44
47
  s.summary = %q{Assists in handling migrations}
45
48
  s.test_files = [
49
+ "spec/generators/migration/migration_generator.rb",
46
50
  "spec/load_spec.rb",
47
51
  "spec/migration_assist/class_methods_spec.rb",
48
52
  "spec/migration_assist/fixtures/001_migration_a.rb",
@@ -54,26 +58,25 @@ Gem::Specification.new do |s|
54
58
  ]
55
59
 
56
60
  if s.respond_to? :specification_version then
57
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
58
61
  s.specification_version = 3
59
62
 
60
63
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
61
- s.add_development_dependency(%q<rspec>, [">= 2.0.1"])
64
+ s.add_development_dependency(%q<rspec>, [">= 2.4.1"])
62
65
  s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
63
- s.add_development_dependency(%q<generator-spec>, [">= 0.7.1"])
66
+ s.add_development_dependency(%q<generator-spec>, [">= 0.7.3"])
64
67
  s.add_runtime_dependency(%q<require_all>, ["~> 1.2.0"])
65
68
  s.add_runtime_dependency(%q<rails>, [">= 3.0.1"])
66
69
  else
67
- s.add_dependency(%q<rspec>, [">= 2.0.1"])
70
+ s.add_dependency(%q<rspec>, [">= 2.4.1"])
68
71
  s.add_dependency(%q<mocha>, [">= 0.9.8"])
69
- s.add_dependency(%q<generator-spec>, [">= 0.7.1"])
72
+ s.add_dependency(%q<generator-spec>, [">= 0.7.3"])
70
73
  s.add_dependency(%q<require_all>, ["~> 1.2.0"])
71
74
  s.add_dependency(%q<rails>, [">= 3.0.1"])
72
75
  end
73
76
  else
74
- s.add_dependency(%q<rspec>, [">= 2.0.1"])
77
+ s.add_dependency(%q<rspec>, [">= 2.4.1"])
75
78
  s.add_dependency(%q<mocha>, [">= 0.9.8"])
76
- s.add_dependency(%q<generator-spec>, [">= 0.7.1"])
79
+ s.add_dependency(%q<generator-spec>, [">= 0.7.3"])
77
80
  s.add_dependency(%q<require_all>, ["~> 1.2.0"])
78
81
  s.add_dependency(%q<rails>, [">= 3.0.1"])
79
82
  end
data/spec/TODO.textile ADDED
@@ -0,0 +1,3 @@
1
+ h1. TODO
2
+
3
+ Use generator-spec to spec sample generator for migration_assist
@@ -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 Rails3::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,14 @@
1
+ class <%= name.camelize %> < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :users do |t|
4
+ t.string :name
5
+ t.integer :age
6
+ t.boolean :admin
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ drop_table :users
12
+ end
13
+
14
+ end
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  class TestGenerator
4
- include Rails3::Migration::Assist
4
+ include RailsAssist::Migration
5
5
  end
6
6
 
7
- Rails3::Migration::Assist.orm = :active_record
7
+ RailsAssist::Migration.orm = :active_record
8
8
 
9
- describe 'Migration Assist' do
9
+ describe RailsAssist::Migration do
10
10
  let(:dir) { fixtures_dir }
11
11
  let(:generator) { TestGenerator.new }
12
12
 
@@ -10,7 +10,7 @@ RSpec::Generator.configure do |config|
10
10
  end
11
11
 
12
12
 
13
- Rails3::Migration::Assist.orm = :active_record
13
+ RailsAssist::Migration.orm = :active_record
14
14
 
15
15
  require_generator :migration
16
16
 
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'rspec/core'
1
+ require 'rspec'
2
2
  require 'migration_assist'
3
3
 
4
4
  RSpec.configure do |config|
metadata CHANGED
@@ -1,31 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: migration_assist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
5
- prerelease: !!null
4
+ version: 0.2.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kristian Mandrup
9
- autorequire: !!null
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2010-12-20 00:00:00.000000000 +01:00
13
- default_executable: !!null
12
+ date: 2011-03-04 00:00:00.000000000 +01:00
13
+ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
17
- requirement: &2152872100 !ruby/object:Gem::Requirement
17
+ requirement: &2158573420 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
21
21
  - !ruby/object:Gem::Version
22
- version: 2.0.1
22
+ version: 2.4.1
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *2152872100
25
+ version_requirements: *2158573420
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: mocha
28
- requirement: &2152945540 !ruby/object:Gem::Requirement
28
+ requirement: &2158572840 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,21 +33,21 @@ dependencies:
33
33
  version: 0.9.8
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *2152945540
36
+ version_requirements: *2158572840
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: generator-spec
39
- requirement: &2153076520 !ruby/object:Gem::Requirement
39
+ requirement: &2158572280 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
43
43
  - !ruby/object:Gem::Version
44
- version: 0.7.1
44
+ version: 0.7.3
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2153076520
47
+ version_requirements: *2158572280
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: require_all
50
- requirement: &2153134500 !ruby/object:Gem::Requirement
50
+ requirement: &2158571780 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 1.2.0
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *2153134500
58
+ version_requirements: *2158571780
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: rails
61
- requirement: &2153229880 !ruby/object:Gem::Requirement
61
+ requirement: &2158571300 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,7 +66,7 @@ dependencies:
66
66
  version: 3.0.1
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *2153229880
69
+ version_requirements: *2158571300
70
70
  description: Assists in handling migrations, including generating migration files
71
71
  from a Thor Generator
72
72
  email: kmandrup@gmail.com
@@ -88,6 +88,9 @@ files:
88
88
  - lib/migration_assist/implementation.rb
89
89
  - lib/migration_assist/namespaces.rb
90
90
  - migration_assist.gemspec
91
+ - spec/TODO.textile
92
+ - spec/generators/migration/migration_generator.rb
93
+ - spec/generators/migration/templates/create_users.erb
91
94
  - spec/load_spec.rb
92
95
  - spec/migration_assist/class_methods_spec.rb
93
96
  - spec/migration_assist/fixtures/001_migration_a.rb
@@ -99,7 +102,7 @@ files:
99
102
  has_rdoc: true
100
103
  homepage: http://github.com/kristianmandrup/migration_assist
101
104
  licenses: []
102
- post_install_message: !!null
105
+ post_install_message:
103
106
  rdoc_options: []
104
107
  require_paths:
105
108
  - lib
@@ -116,12 +119,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
119
  - !ruby/object:Gem::Version
117
120
  version: '0'
118
121
  requirements: []
119
- rubyforge_project: !!null
120
- rubygems_version: 1.5.0
121
- signing_key: !!null
122
+ rubyforge_project:
123
+ rubygems_version: 1.6.1
124
+ signing_key:
122
125
  specification_version: 3
123
126
  summary: Assists in handling migrations
124
127
  test_files:
128
+ - spec/generators/migration/migration_generator.rb
125
129
  - spec/load_spec.rb
126
130
  - spec/migration_assist/class_methods_spec.rb
127
131
  - spec/migration_assist/fixtures/001_migration_a.rb