scaffold_plus 1.9.3 → 1.10.0
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: bd975f400bfb58723ae822f419e6f8513bcf6450
|
4
|
+
data.tar.gz: 07a1eee7285b33845aae690f86d9b4a74a69aa97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6eacc8b85d167e3330b3c11e5295239f92b57d1bfc8e26d9aa8edf125c026cbec62f4de881e65a8baa3fbbfe599d746c4d95b31f7823062dbcc35fc97163247
|
7
|
+
data.tar.gz: fa0f839435ae9a3f3eecb7cf797f2419c9ef504cfc6a74347bf71822493d35a0b177620bb58181031f728a9e673fa32e93c37ef0e4a749fe2d248da32a9483e1
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rails/generators/active_record'
|
2
|
+
|
3
|
+
module ScaffoldPlus
|
4
|
+
module Generators
|
5
|
+
class AuthorityGenerator < ActiveRecord::Generators::Base
|
6
|
+
desc "Add authorization to resource (requires authority gem)"
|
7
|
+
argument :name, type: :string,
|
8
|
+
desc: 'The object that will be protected'
|
9
|
+
class_option :authorizer, type: :string,
|
10
|
+
desc: 'authorizer (full name) instead of <class name>Authorizer'
|
11
|
+
class_option :before, type: :boolean, default: false,
|
12
|
+
desc: 'Add a line before generated text in model'
|
13
|
+
class_option :after, type: :boolean, default: false,
|
14
|
+
desc: 'Add a line after generated text in model'
|
15
|
+
source_root File.expand_path('../templates', __FILE__)
|
16
|
+
|
17
|
+
def update_model
|
18
|
+
inject_into_class "app/models/#{name}.rb", class_name do
|
19
|
+
text = options.before? ? "\n" : ""
|
20
|
+
text << " include Authority::Abilities\n"
|
21
|
+
if options.authorizer.present?
|
22
|
+
text << " self.authorizer_name = '#{options.authorizer}'\n"
|
23
|
+
else
|
24
|
+
text << " self.authorizer_name = '#{class_name}Authorizer'\n"
|
25
|
+
end
|
26
|
+
text << "\n" if options.after?
|
27
|
+
text
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def add_authorizer
|
32
|
+
template "authorizer.rb", "app/authorizers/#{name}_authorizer.rb"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
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
|
+
version: 1.10.0
|
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-11-
|
11
|
+
date: 2014-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -81,6 +81,8 @@ files:
|
|
81
81
|
- Rakefile
|
82
82
|
- lib/generators/scaffold_plus/ancestry/ancestry_generator.rb
|
83
83
|
- lib/generators/scaffold_plus/ancestry/templates/ancestry_migration.rb
|
84
|
+
- lib/generators/scaffold_plus/authority/authority_generator.rb
|
85
|
+
- lib/generators/scaffold_plus/authority/templates/authorizer.rb
|
84
86
|
- lib/generators/scaffold_plus/autofocus/autofocus_generator.rb
|
85
87
|
- lib/generators/scaffold_plus/collection/collection_generator.rb
|
86
88
|
- lib/generators/scaffold_plus/collection/templates/view.html.erb
|
@@ -130,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
132
|
version: '0'
|
131
133
|
requirements: []
|
132
134
|
rubyforge_project:
|
133
|
-
rubygems_version: 2.4.
|
135
|
+
rubygems_version: 2.4.3
|
134
136
|
signing_key:
|
135
137
|
specification_version: 4
|
136
138
|
summary: A collection of little helpers for Rails scaffolding
|