scaffold_plus 1.7.7 → 1.7.8
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a8de459e175237fd6d5333753480595d776524e
|
4
|
+
data.tar.gz: f8421fe1fb8d53ef51fadb6c465d0dee66501db4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00dca3e633506ad5ceac27a7366ca6829a234c8ed86edb95e321dc3942b4794e0a57c547f07145c2e6d98caaeb807c894fae365848b22b673c9880425738d98e
|
7
|
+
data.tar.gz: 7106a4ef8f5708e6184b25280e3bd4ed7211805b049bf22dbf1e28993bf3e3c8146805aa455cc657ce8408a34e54ff136b59d52a0a0fd4a00df33d013fa1f4d4
|
@@ -14,6 +14,10 @@ module ScaffoldPlus
|
|
14
14
|
desc: 'Create a migration for added attributes'
|
15
15
|
class_option :address, type: :boolean, default: true,
|
16
16
|
desc: 'Add an address field to the migration'
|
17
|
+
class_option :before, type: :boolean, default: false,
|
18
|
+
desc: 'Add a line before generated text in model'
|
19
|
+
class_option :after, type: :boolean, default: false,
|
20
|
+
desc: 'Add a line after generated text in model'
|
17
21
|
source_root File.expand_path('../templates', __FILE__)
|
18
22
|
|
19
23
|
def add_migration
|
@@ -26,7 +30,8 @@ module ScaffoldPlus
|
|
26
30
|
lng = options.longitude
|
27
31
|
file = "app/models/#{name}.rb"
|
28
32
|
prepend_to_file file, "require 'geodesic_wgs84'\n\n"
|
29
|
-
lines = [
|
33
|
+
lines = options.before? ? [ "" ] : []
|
34
|
+
lines << [
|
30
35
|
" def to_lat_lon",
|
31
36
|
" [#{lat}, #{lng}]",
|
32
37
|
" end",
|
@@ -49,6 +54,7 @@ module ScaffoldPlus
|
|
49
54
|
" end",
|
50
55
|
""
|
51
56
|
]
|
57
|
+
lines << "" if options.after?
|
52
58
|
inject_into_class file, class_name, lines.join("\n")
|
53
59
|
end
|
54
60
|
|