toastyapps-migratory 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 ToastyApps
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/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rake/testtask'
3
3
 
4
4
  gem_spec = Gem::Specification.new do |gem_spec|
5
5
  gem_spec.name = 'migratory'
6
- gem_spec.version = '0.0.3'
6
+ gem_spec.version = '0.0.4'
7
7
  gem_spec.summary = 'Rails migration extender for default values and adding indexes'
8
8
  gem_spec.description = 'Rails migration extender for default values and adding indexes'
9
9
  gem_spec.email = 'matt@toastyapps.com'
@@ -26,9 +26,13 @@ module Rails
26
26
  options << ", :precision => #{@precision}" if @precision
27
27
  options << ", :scale => #{@scale}" if @scale
28
28
  if @default
29
- options << case @type
30
- when :string, :text, :date, :datetime, :time, :timestamp then ', :default => "'+@default+'"'
31
- else ", :default => #{@default}"
29
+ if @default == ''
30
+ options << ", :default => nil"
31
+ else
32
+ options << case @type
33
+ when :string, :text, :date, :datetime, :time, :timestamp then ', :default => "'+@default+'"'
34
+ else ", :default => #{@default}"
35
+ end
32
36
  end
33
37
  end
34
38
  options
@@ -39,6 +43,20 @@ module Rails
39
43
  end
40
44
  end
41
45
 
46
+
47
+ module Rails
48
+ module Generator
49
+ class NamedBase < Rails::Generator::Base
50
+ protected
51
+ def attributes
52
+ @attributes ||= @args.collect do |attribute|
53
+ Rails::Generator::GeneratedAttribute.new(*attribute.split(":", -1))
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+
42
60
  class ModelGenerator < Rails::Generator::NamedBase
43
61
  default_options :skip_timestamps => false, :skip_migration => false, :skip_fixture => false
44
62
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toastyapps-migratory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Mongeau
@@ -22,6 +22,7 @@ extensions: []
22
22
  extra_rdoc_files: []
23
23
 
24
24
  files:
25
+ - MIT-LICENSE
25
26
  - Rakefile
26
27
  - README.textile
27
28
  - generators/model