toastyapps-migratory 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
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.4'
6
+ gem_spec.version = '0.0.5'
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'
@@ -1,61 +1,5 @@
1
- module Rails
2
- module Generator
3
- class GeneratedAttribute
4
- attr_accessor :default, :is_indexed, :limit, :precision, :scale
5
-
6
- def initialize_with_migratory(name, type, default = nil)
7
- @default = default
8
- @is_indexed = (name =~ /^\*/) && true
9
- if type =~ /\[.*?\]/
10
- details = type.match(/\[(.*?)\]/)[1]
11
- if details =~ /,/
12
- @precision, @scale = details.split(/,/).map(&:to_i)
13
- else
14
- case type.gsub(/\[.*?\]/, '').to_sym
15
- when :string, :text, :binary, :integer then @limit = details.to_i
16
- when :decimal, :float then @precision = details.to_i
17
- end
18
- end
19
- end
20
- initialize_without_migratory(name.gsub(/^\*/, ''), type.gsub(/\[.*?\]/, ''))
21
- end
22
-
23
- def options
24
- options = ''
25
- options << ", :limit => #{@limit}" if @limit
26
- options << ", :precision => #{@precision}" if @precision
27
- options << ", :scale => #{@scale}" if @scale
28
- if @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
36
- end
37
- end
38
- options
39
- end
40
-
41
- alias_method_chain :initialize, :migratory
42
- end
43
- end
44
- end
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
1
+ require 'migratory/generated_attribute'
2
+ require 'migratory/named_base'
59
3
 
60
4
  class ModelGenerator < Rails::Generator::NamedBase
61
5
  default_options :skip_timestamps => false, :skip_migration => false, :skip_fixture => false
@@ -0,0 +1,44 @@
1
+ module Rails
2
+ module Generator
3
+ class GeneratedAttribute
4
+ attr_accessor :default, :is_indexed, :limit, :precision, :scale
5
+
6
+ def initialize_with_migratory(name, type, default = nil)
7
+ @default = default
8
+ @is_indexed = (name =~ /^\*/) && true
9
+ if type =~ /\[.*?\]/
10
+ details = type.match(/\[(.*?)\]/)[1]
11
+ if details =~ /,/
12
+ @precision, @scale = details.split(/,/).map(&:to_i)
13
+ else
14
+ case type.gsub(/\[.*?\]/, '').to_sym
15
+ when :string, :text, :binary, :integer then @limit = details.to_i
16
+ when :decimal, :float then @precision = details.to_i
17
+ end
18
+ end
19
+ end
20
+ initialize_without_migratory(name.gsub(/^\*/, ''), type.gsub(/\[.*?\]/, ''))
21
+ end
22
+
23
+ def options
24
+ options = ''
25
+ options << ", :limit => #{@limit}" if @limit
26
+ options << ", :precision => #{@precision}" if @precision
27
+ options << ", :scale => #{@scale}" if @scale
28
+ if @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
36
+ end
37
+ end
38
+ options
39
+ end
40
+
41
+ alias_method_chain :initialize, :migratory
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,12 @@
1
+ module Rails
2
+ module Generator
3
+ class NamedBase < Rails::Generator::Base
4
+ protected
5
+ def attributes
6
+ @attributes ||= @args.collect do |attribute|
7
+ Rails::Generator::GeneratedAttribute.new(*attribute.split(":", -1))
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
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.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Mongeau
@@ -32,7 +32,9 @@ files:
32
32
  - generators/model/templates/migration.rb
33
33
  - generators/model/templates/model.rb
34
34
  - generators/model/templates/unit_test.rb
35
- - lib/README
35
+ - lib/migratory
36
+ - lib/migratory/generated_attribute.rb
37
+ - lib/migratory/named_base.rb
36
38
  has_rdoc: true
37
39
  homepage: http://github.com/toastyapps/migratory
38
40
  licenses: []
data/lib/README DELETED
@@ -1 +0,0 @@
1
- Nothing to see here