scaffold_plus 1.7.1 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 804c22bdff1126e023c334e10af6d849a2255a3e
|
4
|
+
data.tar.gz: 25e6941d686cde90c0d9ecbe902798d816c11abd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7902a9eeaa8d8e034be882a85acd16dda6d49face995a20ab7f94240ac30e40a6b0253c3e47a8569d13ca814d6f9b297dcf64af0b8de54020127d4fbff5bfe50
|
7
|
+
data.tar.gz: 6ef826a6a918e540433cb976045f20f156f5b6ecf2a966bd9cbbbbc3ca0e803e59b8de873d8fa4dbac789cf448e57d84f252fe307e65bdffa99a299c86d399a6
|
@@ -32,8 +32,10 @@ module ScaffoldPlus
|
|
32
32
|
" if geo.country_code.upcase == 'DE'",
|
33
33
|
" obj.country = 'DE'",
|
34
34
|
" obj.address = geo.address.gsub(/, Deutschland/, '')",
|
35
|
-
" obj.#{options.latitude}
|
36
|
-
"
|
35
|
+
" if obj.#{options.latitude}.blank? and obj.#{options.longitude}.blank?",
|
36
|
+
" obj.#{options.latitude} = geo.latitude",
|
37
|
+
" obj.#{options.longitude} = geo.longitude",
|
38
|
+
" end",
|
37
39
|
" end",
|
38
40
|
" end",
|
39
41
|
" end"
|
@@ -41,7 +43,7 @@ module ScaffoldPlus
|
|
41
43
|
else
|
42
44
|
country = []
|
43
45
|
end
|
44
|
-
lines = options.before? ? [ "
|
46
|
+
lines = options.before? ? [ "" ] : []
|
45
47
|
lines << [
|
46
48
|
geocoded,
|
47
49
|
country,
|
@@ -50,7 +52,7 @@ module ScaffoldPlus
|
|
50
52
|
" and obj.#{options.address}_changed? }",
|
51
53
|
""
|
52
54
|
]
|
53
|
-
lines << "
|
55
|
+
lines << "" if options.after?
|
54
56
|
inject_into_class "app/models/#{name}.rb", class_name do
|
55
57
|
lines.flatten.join("\n")
|
56
58
|
end
|
@@ -13,31 +13,29 @@ module ScaffoldPlus
|
|
13
13
|
|
14
14
|
def update_model
|
15
15
|
lat = options.latitude
|
16
|
-
|
16
|
+
lng = options.longitude
|
17
17
|
file = "app/models/#{name}.rb"
|
18
18
|
prepend_to_file file, "require 'geodesic_wgs84'\n\n"
|
19
19
|
lines = [
|
20
20
|
" def to_ary",
|
21
|
-
" [#{lat}, #{
|
21
|
+
" [#{lat}, #{lng}]",
|
22
22
|
" end",
|
23
23
|
"",
|
24
|
-
"
|
25
|
-
"",
|
26
|
-
"
|
24
|
+
" def as_dms(value)",
|
25
|
+
" return '' if value.blank?",
|
26
|
+
" wgs84 = Wgs84.new",
|
27
|
+
" wgs84.as_dms(value)",
|
28
|
+
" end",
|
27
29
|
"",
|
28
|
-
"
|
30
|
+
" before_save on: [:create, :update] do",
|
31
|
+
" # Normalize geo information",
|
29
32
|
" wgs84 = Wgs84.new",
|
30
|
-
" if self.#{lat}.
|
31
|
-
"
|
32
|
-
" self.#{lat}, self.#{lon} = wgs84.lat_lon(self.#{lat}_dms, self.#{lon}_dms)",
|
33
|
-
" end",
|
33
|
+
" if self.#{lat}.present?",
|
34
|
+
" self.#{lat} = wgs84.as_deg(self.#{lat})",
|
34
35
|
" end",
|
35
|
-
" if self.#{
|
36
|
-
"
|
37
|
-
" self.#{lat}_dms, self.#{lon}_dms = wgs84.lat_lon_dms(self.#{lat}, self.#{lon})",
|
38
|
-
" end",
|
36
|
+
" if self.#{lng}.present?",
|
37
|
+
" self.#{lng} = wgs84.as_deg(self.#{lng})",
|
39
38
|
" end",
|
40
|
-
" true",
|
41
39
|
" end",
|
42
40
|
""
|
43
41
|
]
|
@@ -39,7 +39,7 @@ module ScaffoldPlus
|
|
39
39
|
text << ", dependent: :#{dependent}" if options.dependent
|
40
40
|
text << "\n"
|
41
41
|
if options.nested
|
42
|
-
text << " accepts_nested_attributes_for :#{child}\n"
|
42
|
+
text << " accepts_nested_attributes_for :#{child}, allow_destroy: true\n"
|
43
43
|
end
|
44
44
|
text << "\n" if after_array.include?(name)
|
45
45
|
text
|
@@ -61,7 +61,7 @@ module ScaffoldPlus
|
|
61
61
|
def add_to_permit
|
62
62
|
return unless options.nested
|
63
63
|
list = options.nested.map{|n| ":#{n}"}.join(', ')
|
64
|
-
text = "#{child}_attributes: [ #{list} ]"
|
64
|
+
text = ":#{child}, #{child}_attributes: [ #{list} ]"
|
65
65
|
file = "app/controllers/#{table_name}_controller.rb"
|
66
66
|
gsub_file file, /(permit\(.*)\)/, "\\1, #{text})"
|
67
67
|
# Special case: no previous permit
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scaffold_plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Volker Wiegand
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|