scaffold_plus 2.1.1 → 2.1.2

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: c7d2e202759f6157c5bca94e2616ea117b144a0a
4
- data.tar.gz: c7594d18a5918aaa42d210770a61e251cac06205
3
+ metadata.gz: 450cf4b87abe4a2a86ad00fe8b053a71c6fba8c7
4
+ data.tar.gz: 74a215ecd8504a343c96ce597d8135208b0c0d36
5
5
  SHA512:
6
- metadata.gz: d0590b2b7ae236631523e25e1dafc44a0472eb982929904891f532dc1976b98c9c345e18564e3acac04be72e8a5edaf142f233b3d3cfd089cc43e749ef0c9a87
7
- data.tar.gz: f24bed53fcac42c60699a1ae75dc561039cdce7dbababb3c7e2d46842c374073f4fc3a510a4290e8f3ad44c5c40ebfb2bab2223c77b13bae64b2cd9d30b9f1eb
6
+ metadata.gz: 398ecfa0f85c0d931fabc4a844e1864a10851fe758d97e6478d270e3d29758c38f1da2c212ace792473d0edb462f97a1f498b6ed41d1d5f09f786605b0c59e24
7
+ data.tar.gz: d8af2ce1c3b5ed8455c80edd10d0bd0da937a82eb44f649ab10518ed24a39693589596b4efecf22868036d37b1d3496c2aba6dc9f0109c37d0d38aed4d29e0d3
@@ -86,6 +86,7 @@ module ScaffoldPlus
86
86
  list = options.nested.map{|n| ":#{n}"}.join(', ')
87
87
  text = "#{children}_attributes: [ #{list} ]"
88
88
  file = "app/controllers/#{table_name}_controller.rb"
89
+ return unless File.exist?(file)
89
90
  gsub_file file, /(permit\(.*)\)/, "\\1, #{text})"
90
91
  # Special case: no previous permit
91
92
  gsub_file file, /^(\s*params)\[:#{name}\]$/, "\\1.require(:#{name}).permit(#{text})"
@@ -95,6 +96,7 @@ module ScaffoldPlus
95
96
  return unless options.permit?
96
97
  text = ":#{name}_id"
97
98
  file = "app/controllers/#{children}_controller.rb"
99
+ return unless File.exist?(file)
98
100
  gsub_file file, /(permit\(.*)\)/, "\\1, #{text})"
99
101
  # Special case: no previous permit
100
102
  gsub_file file, /^(\s*params)\[:#{name}\]$/, "\\1.require(:#{name}).permit(#{text})"
@@ -104,16 +106,20 @@ module ScaffoldPlus
104
106
  return unless options.route?
105
107
  child = children.singularize
106
108
  file = "app/controllers/#{children}_controller.rb"
107
- gsub_file file, /GET .#{children}.new$/ do |match|
108
- match = "GET /#{table_name}/:id/#{children}/new"
109
- end
110
- gsub_file file, /^ @#{child} = #{child.camelize}.new$/ do |match|
111
- match = " @#{name} = #{class_name}.find(params[:#{name}_id])\n" +
112
- " @#{child} = @#{name}.#{children}.build"
109
+ if File.exist?(file)
110
+ gsub_file file, /GET .#{children}.new$/ do |match|
111
+ match = "GET /#{table_name}/:id/#{children}/new"
112
+ end
113
+ gsub_file file, /^ @#{child} = #{child.camelize}.new$/ do |match|
114
+ match = " @#{name} = #{class_name}.find(params[:#{name}_id])\n" +
115
+ " @#{child} = @#{name}.#{children}.build"
116
+ end
113
117
  end
114
118
  file = "app/views/#{children}/_form.html.erb"
115
- gsub_file file, /form_for\(@#{child}/ do |match|
116
- match = "form_for([@#{name}, @#{child}]"
119
+ if File.exist?(file)
120
+ gsub_file file, /form_for\(@#{child}/ do |match|
121
+ match = "form_for([@#{name}, @#{child}]"
122
+ end
117
123
  end
118
124
  end
119
125
 
@@ -145,3 +151,5 @@ module ScaffoldPlus
145
151
  end
146
152
  end
147
153
  end
154
+
155
+ # vim: set expandtab softtabstop=2 shiftwidth=2 autoindent :
@@ -1,3 +1,3 @@
1
1
  module ScaffoldPlus
2
- VERSION = "2.1.1"
2
+ VERSION = "2.1.2"
3
3
  end
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: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Volker Wiegand
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-10 00:00:00.000000000 Z
11
+ date: 2016-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  version: '0'
149
149
  requirements: []
150
150
  rubyforge_project:
151
- rubygems_version: 2.6.6
151
+ rubygems_version: 2.6.8
152
152
  signing_key:
153
153
  specification_version: 4
154
154
  summary: A collection of helpers for Rails scaffolding