scaffold_plus 1.7.5 → 1.7.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dbfbc1604c1f6d200fbd60cc086e9dd1276512ea
4
- data.tar.gz: 533ec872a540106525ea897c3538e16cf0135019
3
+ metadata.gz: d086d36b9eb62d10cb0d98dc72dd6ab7691e1394
4
+ data.tar.gz: a73dd1c0b68f5b1e09e09f6006a28db56868251f
5
5
  SHA512:
6
- metadata.gz: 9e8e4e1a13f2e736099adf843d0eaf8bfbe57d2ab712abd221a9bcbf952c4f77d4d2065079a9237662069e2bec37855efe6fa9310c441d0d16bb749024c56874
7
- data.tar.gz: 8c7c02bc8ca4ce04a9414cfe7080f10bc821b000e520ee93a5fed40bb5f23b399e1d9313949f84b1c7ea03b58b4c55a6f68422bb47232863032ee70a85b9e3e6
6
+ metadata.gz: 3fcc8daf9c6b5d2ecf7f2ec6e46e76bc87e2a8744f1a18ec53d3c524593c69a51fc0aca6bbea8b725744a7d346656861b212ff313f69a53918d8d771a1bd9c5c
7
+ data.tar.gz: 45e7c6988952b0377c26ec4e6b633d6988adf62ea18aba95d70a035e06f875db879000a0a15dafeb687d60890c31b53819ea10c30626347f3d633a7bed8f6965
@@ -10,6 +10,16 @@ module ScaffoldPlus
10
10
  desc: 'Attribute used for storing latitude'
11
11
  class_option :longitude, type: :string, default: "lng",
12
12
  desc: 'Attribute used for storing longitude'
13
+ class_option :migration, type: :boolean, default: false,
14
+ desc: 'Create a migration for added attributes'
15
+ class_option :address, type: :boolean, default: true,
16
+ desc: 'Add an address field to the migration'
17
+ source_root File.expand_path('../templates', __FILE__)
18
+
19
+ def add_migration
20
+ return unless options.migration?
21
+ migration_template 'geodesic.rb', "db/migrate/#{migration_name}.rb"
22
+ end
13
23
 
14
24
  def update_model
15
25
  lat = options.latitude
@@ -41,6 +51,12 @@ module ScaffoldPlus
41
51
  ]
42
52
  inject_into_class file, class_name, lines.join("\n")
43
53
  end
54
+
55
+ protected
56
+
57
+ def migration_name
58
+ "add_geodesic_to_#{table_name}"
59
+ end
44
60
  end
45
61
  end
46
62
  end
@@ -0,0 +1,11 @@
1
+ class <%= migration_name.camelize %> < ActiveRecord::Migration
2
+ def change
3
+ add_column :<%= table_name %>, :<%= options.latitude %>, :float
4
+ add_column :<%= table_name %>, :<%= options.longitude %>, :float
5
+ <%- if options.address? -%>
6
+ add_column :<%= table_name %>, :address, :string
7
+ <%- end -%>
8
+ add_index :<%= table_name %>, :<%= options.latitude %>
9
+ add_index :<%= table_name %>, :<%= options.longitude %>
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module ScaffoldPlus
2
- VERSION = "1.7.5"
2
+ VERSION = "1.7.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scaffold_plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.5
4
+ version: 1.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Volker Wiegand
@@ -91,6 +91,7 @@ files:
91
91
  - lib/generators/scaffold_plus/geocoder_init/geocoder_init_generator.rb
92
92
  - lib/generators/scaffold_plus/geocoder_init/templates/geocoder.rb
93
93
  - lib/generators/scaffold_plus/geodesic/geodesic_generator.rb
94
+ - lib/generators/scaffold_plus/geodesic/templates/geodesic_migration.rb
94
95
  - lib/generators/scaffold_plus/habtm/habtm_generator.rb
95
96
  - lib/generators/scaffold_plus/habtm/templates/habtm_migration.rb
96
97
  - lib/generators/scaffold_plus/has_many/has_many_generator.rb