the_role 2.5.1 → 2.5.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 +4 -4
- data/README.md +1 -1
- data/app/models/concerns/base.rb +4 -4
- data/app/models/concerns/role.rb +12 -12
- data/lib/the_role/hash.rb +1 -1
- data/lib/the_role/version.rb +1 -1
- data/spec/dummy_app/Gemfile +6 -2
- data/spec/dummy_app/config/application.rb +2 -0
- data/spec/dummy_app/spec/models/param_process_spec.rb +7 -7
- data/the_role.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12b0ae2b2e4a5afcc9026717b0c81155f02fa4d7
|
4
|
+
data.tar.gz: 7867224f80ba6715d9d3a562e77ea04f642a592f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e768d539904516605ab9be3e3de04debe263116639edf2891eef306ced2db0c16008d3a7f9cfe3cc73f3ec054ca62d60deda76703e821c99d083d20ee7ee8681
|
7
|
+
data.tar.gz: d343d3fc7478400b0903eb278b0db31ce0653a27bf69ef478d9bd91486fafa06843bf9c57b01bd55c0903ff9ae07aa1ef4239534953396fa72c482ac5ffc1d4d
|
data/README.md
CHANGED
@@ -506,7 +506,7 @@ new_role_hash = {
|
|
506
506
|
|
507
507
|
### MIT-LICENSE
|
508
508
|
|
509
|
-
##### Copyright (c) 2012 [Ilya N.Zykin]
|
509
|
+
##### Copyright (c) 2012-2014 [Ilya N.Zykin]
|
510
510
|
|
511
511
|
Permission is hereby granted, free of charge, to any person obtaining
|
512
512
|
a copy of this software and associated documentation files (the
|
data/app/models/concerns/base.rb
CHANGED
@@ -2,15 +2,15 @@ module TheRole
|
|
2
2
|
module Base
|
3
3
|
def has_section? section_name
|
4
4
|
hash = role_hash
|
5
|
-
section_name = section_name.
|
5
|
+
section_name = section_name.to_slug_param(sep: '_')
|
6
6
|
return true if hash[section_name]
|
7
7
|
false
|
8
8
|
end
|
9
9
|
|
10
10
|
def has_role? section_name, rule_name
|
11
11
|
hash = role_hash
|
12
|
-
section_name = section_name.
|
13
|
-
rule_name = rule_name.
|
12
|
+
section_name = section_name.to_slug_param(sep: '_')
|
13
|
+
rule_name = rule_name.to_slug_param(sep: '_')
|
14
14
|
|
15
15
|
return true if hash.try(:[], 'system').try(:[], 'administrator')
|
16
16
|
return true if hash.try(:[], 'moderator').try(:[], section_name)
|
@@ -26,7 +26,7 @@ module TheRole
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def moderator? section_name
|
29
|
-
section_name = section_name.to_slug_param(
|
29
|
+
section_name = section_name.to_slug_param(sep: '_')
|
30
30
|
has_role? section_name, 'any_crazy_name'
|
31
31
|
end
|
32
32
|
|
data/app/models/concerns/role.rb
CHANGED
@@ -12,7 +12,7 @@ module TheRole
|
|
12
12
|
alias_method :any?, :any_role?
|
13
13
|
|
14
14
|
def has_section? section_name
|
15
|
-
to_hash.key? section_name.
|
15
|
+
to_hash.key? section_name.to_slug_param(sep: '_')
|
16
16
|
end
|
17
17
|
|
18
18
|
included do
|
@@ -22,7 +22,7 @@ module TheRole
|
|
22
22
|
validates :description, presence: true
|
23
23
|
|
24
24
|
before_save do
|
25
|
-
self.name = name.
|
25
|
+
self.name = name.to_slug_param(sep: '_')
|
26
26
|
|
27
27
|
rules_set = self.the_role
|
28
28
|
self.the_role = {}.to_json if rules_set.blank? # blank
|
@@ -41,7 +41,7 @@ module TheRole
|
|
41
41
|
def create_section section_name = nil
|
42
42
|
return false unless section_name
|
43
43
|
role = to_hash
|
44
|
-
section_name = section_name.
|
44
|
+
section_name = section_name.to_slug_param(sep: '_')
|
45
45
|
return false if section_name.blank?
|
46
46
|
return true if role[section_name]
|
47
47
|
role[section_name] = {}
|
@@ -53,8 +53,8 @@ module TheRole
|
|
53
53
|
return false unless create_section(section_name)
|
54
54
|
|
55
55
|
role = to_hash
|
56
|
-
rule_name = rule_name.
|
57
|
-
section_name = section_name.
|
56
|
+
rule_name = rule_name.to_slug_param(sep: '_')
|
57
|
+
section_name = section_name.to_slug_param(sep: '_')
|
58
58
|
|
59
59
|
return true if role[section_name][rule_name]
|
60
60
|
role[section_name][rule_name] = false
|
@@ -91,8 +91,8 @@ module TheRole
|
|
91
91
|
|
92
92
|
def rule_on section_name, rule_name
|
93
93
|
role = to_hash
|
94
|
-
rule_name = rule_name.
|
95
|
-
section_name = section_name.
|
94
|
+
rule_name = rule_name.to_slug_param(sep: '_')
|
95
|
+
section_name = section_name.to_slug_param(sep: '_')
|
96
96
|
|
97
97
|
return false unless role[section_name]
|
98
98
|
return false unless role[section_name].key? rule_name
|
@@ -104,8 +104,8 @@ module TheRole
|
|
104
104
|
|
105
105
|
def rule_off section_name, rule_name
|
106
106
|
role = to_hash
|
107
|
-
rule_name = rule_name.
|
108
|
-
section_name = section_name.
|
107
|
+
rule_name = rule_name.to_slug_param(sep: '_')
|
108
|
+
section_name = section_name.to_slug_param(sep: '_')
|
109
109
|
|
110
110
|
return false unless role[section_name]
|
111
111
|
return false unless role[section_name].key? rule_name
|
@@ -120,7 +120,7 @@ module TheRole
|
|
120
120
|
def delete_section section_name = nil
|
121
121
|
return false unless section_name
|
122
122
|
role = to_hash
|
123
|
-
section_name = section_name.
|
123
|
+
section_name = section_name.to_slug_param(sep: '_')
|
124
124
|
|
125
125
|
return false if section_name.blank?
|
126
126
|
return false unless role[section_name]
|
@@ -131,8 +131,8 @@ module TheRole
|
|
131
131
|
|
132
132
|
def delete_rule section_name, rule_name
|
133
133
|
role = to_hash
|
134
|
-
rule_name = rule_name.
|
135
|
-
section_name = section_name.
|
134
|
+
rule_name = rule_name.to_slug_param(sep: '_')
|
135
|
+
section_name = section_name.to_slug_param(sep: '_')
|
136
136
|
|
137
137
|
return false unless role[section_name]
|
138
138
|
return false unless role[section_name].key? rule_name
|
data/lib/the_role/hash.rb
CHANGED
data/lib/the_role/version.rb
CHANGED
data/spec/dummy_app/Gemfile
CHANGED
@@ -18,8 +18,12 @@ gem 'uglifier'
|
|
18
18
|
gem 'jquery-rails'
|
19
19
|
gem 'jbuilder', '~> 1.0.1'
|
20
20
|
|
21
|
-
gem '
|
22
|
-
|
21
|
+
gem 'the_string_to_slug',
|
22
|
+
path: "../../../the_string_to_slug"
|
23
|
+
|
24
|
+
gem 'the_role',
|
25
|
+
# "~> 2.5.1"
|
26
|
+
path: '../../'
|
23
27
|
|
24
28
|
gem 'the_role_bootstrap3_ui',
|
25
29
|
github: 'the-teacher/the_role_bootstrap3_ui',
|
@@ -6,6 +6,8 @@ require 'rails/all'
|
|
6
6
|
# you've limited to :test, :development, or :production.
|
7
7
|
Bundler.require(:default, Rails.env)
|
8
8
|
|
9
|
+
I18n.enforce_available_locales = true
|
10
|
+
|
9
11
|
module RailsApp
|
10
12
|
class Application < Rails::Application
|
11
13
|
# Settings in config/environments/* take precedence over those specified here.
|
@@ -4,29 +4,29 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
describe "String to slug" do
|
6
6
|
it 'string process 1' do
|
7
|
-
'hello world!'.to_slug_param(
|
7
|
+
'hello world!'.to_slug_param(sep: '_').should eq 'hello_world'
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'string process 2' do
|
11
|
-
:hello_world!.
|
11
|
+
:hello_world!.to_slug_param(sep: '_').should eq 'hello_world'
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'string process 3' do
|
15
|
-
"hello ! world".to_slug_param(
|
15
|
+
"hello ! world".to_slug_param(sep: '_').should eq 'hello_world'
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'string process 4' do
|
19
|
-
"HELLO $!= WorlD".to_slug_param(
|
19
|
+
"HELLO $!= WorlD".to_slug_param(sep: '_').should eq 'hello_world'
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'string process 5' do
|
23
|
-
"HELLO---WorlD".to_slug_param(
|
23
|
+
"HELLO---WorlD".to_slug_param(sep: '_').should eq 'hello_world'
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should work with Controller Name" do
|
27
27
|
ctrl = PagesController.new
|
28
28
|
ctrl.controller_path
|
29
|
-
ctrl.controller_path.to_slug_param(
|
29
|
+
ctrl.controller_path.to_slug_param(sep: '_').should eq 'pages'
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should work with Nested Controller Name" do
|
@@ -34,6 +34,6 @@ describe "String to slug" do
|
|
34
34
|
ctrl = Admin::PagesController.new
|
35
35
|
ctrl.controller_path
|
36
36
|
|
37
|
-
ctrl.controller_path.to_slug_param(
|
37
|
+
ctrl.controller_path.to_slug_param(sep: '_').should eq 'admin_pages'
|
38
38
|
end
|
39
39
|
end
|
data/the_role.gemspec
CHANGED
@@ -18,6 +18,6 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
s.add_dependency 'the_string_to_slug', '~> 1.
|
21
|
+
s.add_dependency 'the_string_to_slug', '~> 1.2'
|
22
22
|
s.add_runtime_dependency 'rails', ['>= 3', '< 5']
|
23
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_role
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya N. Zykin [the-teacher]
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: the_string_to_slug
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|