permission 0.0.1 → 0.0.2
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: 07fb222ed30cb7aab50606a52b6036344ea2fe46
|
|
4
|
+
data.tar.gz: e2ae602e54108f088d7b0d614a3a50094c337b3d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 48bc12f8d0d2c3b7151929eff4713ef963244c40b5d3db87e1531d496566085bac769309e50e76a72d9145640a40bfdccf6833eb2be4cb00e5080315218bf95f
|
|
7
|
+
data.tar.gz: abcc717c6505b79af13f2957000b4d6f2cc83c2bbbdef71a602bbbf4c2164a078446e1a5c5ee40dc1b38568c33cc4c88432916edeb084c494f3f66eea280371c
|
|
@@ -3,7 +3,7 @@ require 'rails/generators/base'
|
|
|
3
3
|
module Permission
|
|
4
4
|
# module Generators
|
|
5
5
|
class InstallGenerator < Rails::Generators::Base
|
|
6
|
-
|
|
6
|
+
source_root File.expand_path("../templates", __FILE__)
|
|
7
7
|
def copy_initializer
|
|
8
8
|
template "permission_config.rb", "config/initializers/permission.rb"
|
|
9
9
|
end
|
|
@@ -11,13 +11,13 @@ module Permission
|
|
|
11
11
|
# create_file Rails.root.join("config", "initializers", "permission.rb"), "This is a test"
|
|
12
12
|
# end
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
def create_migrations
|
|
15
|
+
Dir["#{self.class.source_root}/migrations/*.rb"].sort.each do |filepath|
|
|
16
|
+
name = File.basename(filepath)
|
|
17
|
+
template "migrations/#{name}", "db/migrate/#{name}"
|
|
18
|
+
sleep 1
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
21
|
|
|
22
22
|
end
|
|
23
23
|
# end
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
#
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
#
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
1
|
+
module Permission
|
|
2
|
+
module Generators
|
|
3
|
+
module OrmHelpers
|
|
4
|
+
def model_contents
|
|
5
|
+
buffer = <<-CONTENT
|
|
6
|
+
# Add belongs_to :user here for the permission for.
|
|
7
|
+
belongs_to :user
|
|
8
|
+
CONTENT
|
|
9
|
+
buffer += <<-CONTENT
|
|
10
|
+
# Setup accessible (or protected) attributes for your model
|
|
11
|
+
CONTENT
|
|
12
|
+
buffer
|
|
13
|
+
end
|
|
14
|
+
# def needs_attr_accessible?
|
|
15
|
+
# rails_3? && !strong_parameters_enabled?
|
|
16
|
+
# end
|
|
17
|
+
# def rails_3?
|
|
18
|
+
# Rails::VERSION::MAJOR == 3
|
|
19
|
+
# end
|
|
20
|
+
# def strong_parameters_enabled?
|
|
21
|
+
# defined?(ActionController::StrongParameters)
|
|
22
|
+
# end
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
private
|
|
25
|
+
def model_exists?
|
|
26
|
+
File.exists?(File.join(destination_root, model_path))
|
|
27
|
+
end
|
|
28
|
+
def migration_exists?(table_name)
|
|
29
|
+
Dir.glob("#{File.join(destination_root, migration_path)}/[0-9]*_*.rb").grep(/\d+_#{table_name}.rb$/).first
|
|
30
|
+
end
|
|
31
|
+
def migration_path
|
|
32
|
+
@migration_path ||= File.join("db", "migrate")
|
|
33
|
+
end
|
|
34
|
+
def model_path
|
|
35
|
+
@model_path ||= File.join("app", "models", "#{file_path}.rb")
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
require 'rails/generators/named_base'
|
|
2
|
+
module permission
|
|
3
|
+
module Generators
|
|
4
|
+
class PermissionGenerator < Rails::Generators::NamedBase
|
|
5
|
+
include Rails::Generators::ResourceHelpers
|
|
6
|
+
namespace "permission"
|
|
7
|
+
source_root File.expand_path("../templates", __FILE__)
|
|
8
|
+
desc "Generates a model with the given NAME (if one does not exist) with permission " <<
|
|
9
|
+
"configuration plus a migration file."
|
|
10
|
+
hook_for :orm
|
|
11
|
+
class_option :routes, desc: "Generate routes", type: :boolean, default: true
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
data/lib/permission/version.rb
CHANGED
data/lib/permission_config.rb
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
::Permission_for = [Page, Category]
|