permissify 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
|
|
1
|
+
Description:
|
2
|
+
The permissify:install generator creates migrations to establish the roles and associated manages_roles and roles_users join tables.
|
3
|
+
Inspect and modify these migrations to fit your implementation/adaptation.
|
4
|
+
When satisfied, run bundle exec rake db:migrate
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rails/generators/migration'
|
2
|
+
|
3
|
+
module Permissify
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
include Rails::Generators::Migration
|
7
|
+
source_root File.expand_path('../templates', __FILE__)
|
8
|
+
desc "add the migrations"
|
9
|
+
|
10
|
+
def self.next_migration_number(path)
|
11
|
+
unless @prev_migration_nr
|
12
|
+
@prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
|
13
|
+
else
|
14
|
+
@prev_migration_nr += 1
|
15
|
+
end
|
16
|
+
@prev_migration_nr.to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
def copy_migrations
|
20
|
+
migration_template "create_roles_tables.rb", "db/migrate/create_roles_tables.rb"
|
21
|
+
# migration_template "create_something_else.rb", "db/migrate/create_something_else.rb"
|
22
|
+
end
|
23
|
+
|
24
|
+
def generate_install
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
module YourGemName
|
34
|
+
module Generators
|
35
|
+
class InstallGenerator < ::Rails::Generators::Base
|
36
|
+
include Rails::Generators::Migration
|
37
|
+
source_root File.expand_path('../templates', __FILE__)
|
38
|
+
desc "add the migrations"
|
39
|
+
|
40
|
+
def self.next_migration_number(path)
|
41
|
+
unless @prev_migration_nr
|
42
|
+
@prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
|
43
|
+
else
|
44
|
+
@prev_migration_nr += 1
|
45
|
+
end
|
46
|
+
@prev_migration_nr.to_s
|
47
|
+
end
|
48
|
+
|
49
|
+
def copy_migrations
|
50
|
+
migration_template "create_something.rb", "db/migrate/create_something.rb"
|
51
|
+
migration_template "create_something_else.rb", "db/migrate/create_something_else.rb"
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class CreateRolesTables < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
|
4
|
+
create_table :roles, :force => true do |t|
|
5
|
+
t.string :name, :limit => 31
|
6
|
+
t.string :domain_type, :limit => 31
|
7
|
+
t.text :can_manage_roles
|
8
|
+
t.text :permissions
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
|
12
|
+
# the 'manages_roles' join table facilitates the expression of which roles manage other roles.
|
13
|
+
# see role.rb HABTM managers and manages associations.
|
14
|
+
create_table :manages_roles, :id => false, :force => true do |t|
|
15
|
+
t.references :manage, :null => false
|
16
|
+
t.references :role, :null => false
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
# NOTE 1: when associating roles to a model/table other than 'users',
|
21
|
+
# the 'roles_users' join table, and its :user_id field, need to be renamed.
|
22
|
+
|
23
|
+
# NOTE 2: roles can be associated to multiple models/tables.
|
24
|
+
# create a join table for each model/table which roles are associated to.
|
25
|
+
|
26
|
+
create_table :roles_users, :id => false, :force => true do |t|
|
27
|
+
t.integer :role_id, :null => false
|
28
|
+
t.integer :user_id, :null => false
|
29
|
+
end
|
30
|
+
|
31
|
+
# NOTE 3: add indexes as appropriate for your app.
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
def down
|
36
|
+
drop_table :roles
|
37
|
+
drop_table :manages_roles
|
38
|
+
drop_table :roles_users
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: permissify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 13
|
10
|
+
version: 0.0.13
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Frederick Fix
|
@@ -65,6 +65,9 @@ files:
|
|
65
65
|
- lib/generators/permissify/controller/template/permissified_controller.rb
|
66
66
|
- lib/generators/permissify/controller/template/permissions_controller.rb
|
67
67
|
- lib/generators/permissify/controller/USAGE
|
68
|
+
- lib/generators/permissify/install/install_generator.rb
|
69
|
+
- lib/generators/permissify/install/templates/create_roles_tables.rb
|
70
|
+
- lib/generators/permissify/install/USAGE
|
68
71
|
- lib/generators/permissify/product/product_generator.rb
|
69
72
|
- lib/generators/permissify/product/template/interface/permissified_brand.rb
|
70
73
|
- lib/generators/permissify/product/template/interface/permissified_merchant.rb
|