scaffold_plus 1.4.13 → 1.4.14

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: fbd3ae21d33e7cde43f61957f21682f8f1fe8151
4
- data.tar.gz: 0f0665c8b030be1e814b979db36ba0f103ee4d4d
3
+ metadata.gz: 42c2230db8f4b8c89abd5f925ff381bd7244c6b4
4
+ data.tar.gz: 1e02a4c4eb1e4b0d134abdbeffa94f09b7c51f51
5
5
  SHA512:
6
- metadata.gz: dc0851549aba8b398381ef30f68332bfc979c82e2e500da3747d4cbf686d321a2a9e051bb7a0a3e2179dc21f663431c1dfff41dc80e896e52911460bd530ea66
7
- data.tar.gz: ae04e3e21bb18927b15add1683ff7326381d98e2fd77281a67719e5eb30d30c1ea47a46e2123b47f185a44f92697423d1e868e8375bf595da5b5d4dee55f4e71
6
+ metadata.gz: 077668d6fb7ef1684d222b681134525559603c6ba283617854a9305c737601e718b997771a62db2c5f716e8b1f3959a53f5598d19056de995611915c7282adcd
7
+ data.tar.gz: 38b3ece4c2f89de9e21c8fbab2df58e3965bbb6e03c96fda6aa4c4362c04912e43ae0899dd8aed7369710bb3c7ef30179618cb0a7d816c9926ba7e3eb7ddf560
@@ -25,7 +25,7 @@ module ScaffoldPlus
25
25
  migration_template "ancestry_migration.rb", "db/migrate/#{migration_name}.rb"
26
26
  end
27
27
 
28
- def add_to_model
28
+ def update_model
29
29
  inject_into_class "app/models/#{name}.rb", class_name do
30
30
  text = options.before? ? "\n" : ""
31
31
  text << " has_ancestry"
@@ -36,7 +36,7 @@ module ScaffoldPlus
36
36
  end
37
37
  end
38
38
 
39
- def add_to_permit
39
+ def update_controller
40
40
  return unless options.permit?
41
41
  text = ":ancestry"
42
42
  file = "app/controllers/#{table_name}_controller.rb"
@@ -0,0 +1,46 @@
1
+ require 'rails/generators/active_record'
2
+
3
+ module ScaffoldPlus
4
+ module Generators
5
+ class ForceSslGenerator < ActiveRecord::Generators::Base
6
+ desc "Enforce SSL for this controller in production"
7
+ argument :name, type: :string,
8
+ desc: "The resource that is SSL protected"
9
+ class_option :only, type: :array,
10
+ desc: 'Enforce for these actions'
11
+ class_option :except, type: :array,
12
+ desc: 'Do not enforce for these actions'
13
+
14
+ def update_controller
15
+ file = "app/controllers/#{table_name}_controller.rb"
16
+ inject_into_file file, after: /^class.*ApplicationController$/ do
17
+ text = "\n force_ssl if: :ssl_configured?"
18
+ text << ", only: [ #{only_list} ]", if options.only.present?
19
+ text << ", except: [ #{except_list} ]", if options.except.present?
20
+ text
21
+ end
22
+ inject_into_file file, after: /private$/ do
23
+ [
24
+ "",
25
+ " # When to enforce SSL for this controller",
26
+ " def ssl_configured?",
27
+ " Rails.env.production?",
28
+ " end",
29
+ "",
30
+ ""
31
+ ].join("\n")
32
+ end
33
+ end
34
+
35
+ protected
36
+
37
+ def only_list
38
+ [ options.only ].join(", ")
39
+ end
40
+
41
+ def except_list
42
+ [ options.except ].join(", ")
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,3 +1,3 @@
1
1
  module ScaffoldPlus
2
- VERSION = "1.4.13"
2
+ VERSION = "1.4.14"
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: 1.4.13
4
+ version: 1.4.14
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-08-21 00:00:00.000000000 Z
11
+ date: 2014-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -84,6 +84,7 @@ files:
84
84
  - lib/generators/scaffold_plus/autofocus/autofocus_generator.rb
85
85
  - lib/generators/scaffold_plus/collection/collection_generator.rb
86
86
  - lib/generators/scaffold_plus/collection/templates/view.html.erb
87
+ - lib/generators/scaffold_plus/force_ssl/force_ssl_generator.rb
87
88
  - lib/generators/scaffold_plus/habtm/habtm_generator.rb
88
89
  - lib/generators/scaffold_plus/habtm/templates/habtm_migration.rb
89
90
  - lib/generators/scaffold_plus/has_many/has_many_generator.rb