roles_generic 0.3.9 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +13 -7
- data/README.textile +7 -0
- data/Rakefile +46 -25
- data/VERSION +1 -1
- data/lib/roles_generic.rb +1 -0
- data/lib/roles_generic/generic.rb +23 -3
- data/lib/roles_generic/generic/user/implementation.rb +1 -0
- data/roles_generic.gemspec +18 -42
- metadata +32 -67
data/Gemfile
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
source :rubygems
|
2
2
|
|
3
3
|
gem "require_all", "~> 1.2.0"
|
4
|
-
gem "activesupport", ">= 3.0.1"
|
5
|
-
gem 'sugar-high', "
|
6
|
-
gem 'rails_artifactor', '
|
7
|
-
# gem 'logging_assist', '>= 0.2.0'
|
4
|
+
gem "activesupport", ">= 3.0.1"
|
5
|
+
gem 'sugar-high', ">= 0.5.0"
|
6
|
+
gem 'rails_artifactor', '>= 0.4.0'
|
8
7
|
|
9
8
|
group :test do
|
10
|
-
gem "rspec", ">= 2.
|
11
|
-
gem "generator-spec", ">= 0.7.
|
12
|
-
end
|
9
|
+
gem "rspec", ">= 2.5.0"
|
10
|
+
gem "generator-spec", ">= 0.7.5"
|
11
|
+
end
|
12
|
+
|
13
|
+
group :development do
|
14
|
+
gem "jeweler", ">= 1.6.4"
|
15
|
+
gem "bundler", ">= 1.0.10"
|
16
|
+
gem "rdoc"
|
17
|
+
end
|
18
|
+
|
data/README.textile
CHANGED
@@ -8,6 +8,13 @@ Each ORM Roles implementation should have its own generator suited for that part
|
|
8
8
|
|
9
9
|
Since Jan. 2011, Roles now includes a Group API that allows ordering roles into groups (see below).
|
10
10
|
|
11
|
+
h2. You need help?
|
12
|
+
|
13
|
+
Please post questions in the "rails-roles":http://groups.google.com/group/rails-roles group.
|
14
|
+
If you have issues or bug reports, please post these as Issues on the github.
|
15
|
+
I recommend you try to fix any problems you might encounter by forking the project, implement the fix by writing specs
|
16
|
+
and make a pull request to integrate it into my master. Thanks!
|
17
|
+
|
11
18
|
h2. Roles ORM implementations
|
12
19
|
|
13
20
|
The following ORM specific Roles implementations are currently available
|
data/Rakefile
CHANGED
@@ -1,27 +1,48 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
1
5
|
begin
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "roles_generic"
|
18
|
+
gem.summary = %Q{Generic role strategies sharing the same API}
|
19
|
+
gem.description = %Q{Generic role strategies sharing the same API. Easy to insert in any model}
|
20
|
+
gem.email = "kmandrup@gmail.com"
|
21
|
+
gem.homepage = "http://github.com/kristianmandrup/roles_generic"
|
22
|
+
gem.email = "kmandrup@gmail.com"
|
23
|
+
gem.authors = ["Kristian Mandrup"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
task :default => :test
|
36
|
+
|
37
|
+
require 'rake/rdoctask'
|
38
|
+
Rake::RDocTask.new do |rdoc|
|
39
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
40
|
+
|
41
|
+
rdoc.rdoc_dir = 'rdoc'
|
42
|
+
rdoc.title = "roles_generic #{version}"
|
43
|
+
rdoc.rdoc_files.include('README*')
|
44
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
27
45
|
end
|
46
|
+
|
47
|
+
|
48
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/lib/roles_generic.rb
CHANGED
@@ -26,10 +26,29 @@ module Roles
|
|
26
26
|
:embed_one_role => "attr_accessor :one_role"
|
27
27
|
}
|
28
28
|
|
29
|
-
attr_accessor :role_groups
|
29
|
+
attr_accessor :role_groups, :valid_role_groups
|
30
|
+
|
30
31
|
def role_groups
|
31
32
|
@role_groups ||= {}
|
32
33
|
end
|
34
|
+
|
35
|
+
def valid_role_groups
|
36
|
+
@valid_role_groups ||= Set.new
|
37
|
+
end
|
38
|
+
|
39
|
+
def valid_role_groups= *group
|
40
|
+
group = group.flatten.compact
|
41
|
+
raise ArgumentError, "Must be a list of Symbols" if !group.only_labels?
|
42
|
+
@valid_role_groups = group.to_symbols
|
43
|
+
end
|
44
|
+
|
45
|
+
def valid_role_groups_are *group
|
46
|
+
valid_role_groups = group
|
47
|
+
end
|
48
|
+
|
49
|
+
def valid_role_group? name
|
50
|
+
valid_role_groups.include? name.to_sym
|
51
|
+
end
|
33
52
|
|
34
53
|
def strategy name, options = {}
|
35
54
|
strategy_name = name.to_sym
|
@@ -64,9 +83,10 @@ module Roles
|
|
64
83
|
raise ArgumentError, '#add_role_group must be a Hash with a single key value pair' if group_hash.size > 1
|
65
84
|
|
66
85
|
# first key/value pair?
|
67
|
-
group = group_hash.keys.first
|
68
|
-
|
86
|
+
group = group_hash.keys.first
|
69
87
|
raise ArgumentError, "Role group identifier must be a String or Symbol " if !group.kind_of_label?
|
88
|
+
raise ArgumentError, "Role group is not valid, must be one of: #{valid_role_groups}"if !valid_role_group? group
|
89
|
+
|
70
90
|
role_list = group_hash.values.first
|
71
91
|
hash = {group.to_sym => [role_list].flat_uniq.to_symbols}
|
72
92
|
|
data/roles_generic.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{roles_generic}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.5.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{Kristian Mandrup}]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-08-17}
|
13
13
|
s.description = %q{Generic role strategies sharing the same API. Easy to insert in any model}
|
14
14
|
s.email = %q{kmandrup@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -87,26 +87,8 @@ Gem::Specification.new do |s|
|
|
87
87
|
]
|
88
88
|
s.homepage = %q{http://github.com/kristianmandrup/roles_generic}
|
89
89
|
s.require_paths = [%q{lib}]
|
90
|
-
s.rubygems_version = %q{1.8.
|
90
|
+
s.rubygems_version = %q{1.8.8}
|
91
91
|
s.summary = %q{Generic role strategies sharing the same API}
|
92
|
-
s.test_files = [
|
93
|
-
"spec/generator_spec_helper.rb",
|
94
|
-
"spec/roles_generic/generators/admin_flag_generator_spec.rb",
|
95
|
-
"spec/roles_generic/generators/many_roles_generator_spec.rb",
|
96
|
-
"spec/roles_generic/generators/one_role_generator_spec.rb",
|
97
|
-
"spec/roles_generic/generators/role_string_generator_spec.rb",
|
98
|
-
"spec/roles_generic/generators/role_strings_generator_spec.rb",
|
99
|
-
"spec/roles_generic/generators/roles_mask_generator_spec.rb",
|
100
|
-
"spec/roles_generic/generators/roles_string_generator_spec.rb",
|
101
|
-
"spec/roles_generic/strategy/multi/many_roles_spec.rb",
|
102
|
-
"spec/roles_generic/strategy/multi/role_strings_spec.rb",
|
103
|
-
"spec/roles_generic/strategy/multi/roles_mask_spec.rb",
|
104
|
-
"spec/roles_generic/strategy/multi/roles_string_spec.rb",
|
105
|
-
"spec/roles_generic/strategy/single/admin_flag_spec.rb",
|
106
|
-
"spec/roles_generic/strategy/single/one_role_spec.rb",
|
107
|
-
"spec/roles_generic/strategy/single/role_string_spec.rb",
|
108
|
-
"spec/spec_helper.rb"
|
109
|
-
]
|
110
92
|
|
111
93
|
if s.respond_to? :specification_version then
|
112
94
|
s.specification_version = 3
|
@@ -114,34 +96,28 @@ Gem::Specification.new do |s|
|
|
114
96
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
115
97
|
s.add_runtime_dependency(%q<require_all>, ["~> 1.2.0"])
|
116
98
|
s.add_runtime_dependency(%q<activesupport>, [">= 3.0.1"])
|
117
|
-
s.add_runtime_dependency(%q<sugar-high>, ["
|
118
|
-
s.add_runtime_dependency(%q<rails_artifactor>, ["
|
119
|
-
s.add_development_dependency(%q<
|
120
|
-
s.add_development_dependency(%q<
|
121
|
-
s.
|
122
|
-
s.add_runtime_dependency(%q<activesupport>, [">= 3.0.1"])
|
123
|
-
s.add_runtime_dependency(%q<sugar-high>, ["~> 0.4.0"])
|
99
|
+
s.add_runtime_dependency(%q<sugar-high>, [">= 0.5.0"])
|
100
|
+
s.add_runtime_dependency(%q<rails_artifactor>, [">= 0.4.0"])
|
101
|
+
s.add_development_dependency(%q<jeweler>, [">= 1.6.4"])
|
102
|
+
s.add_development_dependency(%q<bundler>, [">= 1.0.10"])
|
103
|
+
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
124
104
|
else
|
125
105
|
s.add_dependency(%q<require_all>, ["~> 1.2.0"])
|
126
106
|
s.add_dependency(%q<activesupport>, [">= 3.0.1"])
|
127
|
-
s.add_dependency(%q<sugar-high>, ["
|
128
|
-
s.add_dependency(%q<rails_artifactor>, ["
|
129
|
-
s.add_dependency(%q<
|
130
|
-
s.add_dependency(%q<
|
131
|
-
s.add_dependency(%q<
|
132
|
-
s.add_dependency(%q<activesupport>, [">= 3.0.1"])
|
133
|
-
s.add_dependency(%q<sugar-high>, ["~> 0.4.0"])
|
107
|
+
s.add_dependency(%q<sugar-high>, [">= 0.5.0"])
|
108
|
+
s.add_dependency(%q<rails_artifactor>, [">= 0.4.0"])
|
109
|
+
s.add_dependency(%q<jeweler>, [">= 1.6.4"])
|
110
|
+
s.add_dependency(%q<bundler>, [">= 1.0.10"])
|
111
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
134
112
|
end
|
135
113
|
else
|
136
114
|
s.add_dependency(%q<require_all>, ["~> 1.2.0"])
|
137
115
|
s.add_dependency(%q<activesupport>, [">= 3.0.1"])
|
138
|
-
s.add_dependency(%q<sugar-high>, ["
|
139
|
-
s.add_dependency(%q<rails_artifactor>, ["
|
140
|
-
s.add_dependency(%q<
|
141
|
-
s.add_dependency(%q<
|
142
|
-
s.add_dependency(%q<
|
143
|
-
s.add_dependency(%q<activesupport>, [">= 3.0.1"])
|
144
|
-
s.add_dependency(%q<sugar-high>, ["~> 0.4.0"])
|
116
|
+
s.add_dependency(%q<sugar-high>, [">= 0.5.0"])
|
117
|
+
s.add_dependency(%q<rails_artifactor>, [">= 0.4.0"])
|
118
|
+
s.add_dependency(%q<jeweler>, [">= 1.6.4"])
|
119
|
+
s.add_dependency(%q<bundler>, [">= 1.0.10"])
|
120
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
145
121
|
end
|
146
122
|
end
|
147
123
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roles_generic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-08-17 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: require_all
|
16
|
-
requirement: &
|
16
|
+
requirement: &2156083460 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2156083460
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &2156081880 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,84 +32,62 @@ dependencies:
|
|
32
32
|
version: 3.0.1
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2156081880
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sugar-high
|
38
|
-
requirement: &
|
38
|
+
requirement: &2156076120 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
|
-
- -
|
41
|
+
- - ! '>='
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0.
|
43
|
+
version: 0.5.0
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2156076120
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rails_artifactor
|
49
|
-
requirement: &
|
49
|
+
requirement: &2156073720 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.4.0
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2156073720
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
|
-
name:
|
60
|
-
requirement: &
|
59
|
+
name: jeweler
|
60
|
+
requirement: &2156070960 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version:
|
65
|
+
version: 1.6.4
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2156070960
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
71
|
-
requirement: &
|
70
|
+
name: bundler
|
71
|
+
requirement: &2156066900 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: 0.
|
76
|
+
version: 1.0.10
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
|
-
name: require_all
|
82
|
-
requirement: &2158403860 !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
|
-
requirements:
|
85
|
-
- - ~>
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version: 1.2.0
|
88
|
-
type: :runtime
|
89
|
-
prerelease: false
|
90
|
-
version_requirements: *2158403860
|
79
|
+
version_requirements: *2156066900
|
91
80
|
- !ruby/object:Gem::Dependency
|
92
|
-
name:
|
93
|
-
requirement: &
|
81
|
+
name: rdoc
|
82
|
+
requirement: &2156063960 !ruby/object:Gem::Requirement
|
94
83
|
none: false
|
95
84
|
requirements:
|
96
85
|
- - ! '>='
|
97
86
|
- !ruby/object:Gem::Version
|
98
|
-
version:
|
99
|
-
type: :
|
100
|
-
prerelease: false
|
101
|
-
version_requirements: *2158403140
|
102
|
-
- !ruby/object:Gem::Dependency
|
103
|
-
name: sugar-high
|
104
|
-
requirement: &2158402520 !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ~>
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: 0.4.0
|
110
|
-
type: :runtime
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
111
89
|
prerelease: false
|
112
|
-
version_requirements: *
|
90
|
+
version_requirements: *2156063960
|
113
91
|
description: Generic role strategies sharing the same API. Easy to insert in any model
|
114
92
|
email: kmandrup@gmail.com
|
115
93
|
executables: []
|
@@ -197,6 +175,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
197
175
|
- - ! '>='
|
198
176
|
- !ruby/object:Gem::Version
|
199
177
|
version: '0'
|
178
|
+
segments:
|
179
|
+
- 0
|
180
|
+
hash: -2069952262275566965
|
200
181
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
182
|
none: false
|
202
183
|
requirements:
|
@@ -205,24 +186,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
205
186
|
version: '0'
|
206
187
|
requirements: []
|
207
188
|
rubyforge_project:
|
208
|
-
rubygems_version: 1.8.
|
189
|
+
rubygems_version: 1.8.8
|
209
190
|
signing_key:
|
210
191
|
specification_version: 3
|
211
192
|
summary: Generic role strategies sharing the same API
|
212
|
-
test_files:
|
213
|
-
- spec/generator_spec_helper.rb
|
214
|
-
- spec/roles_generic/generators/admin_flag_generator_spec.rb
|
215
|
-
- spec/roles_generic/generators/many_roles_generator_spec.rb
|
216
|
-
- spec/roles_generic/generators/one_role_generator_spec.rb
|
217
|
-
- spec/roles_generic/generators/role_string_generator_spec.rb
|
218
|
-
- spec/roles_generic/generators/role_strings_generator_spec.rb
|
219
|
-
- spec/roles_generic/generators/roles_mask_generator_spec.rb
|
220
|
-
- spec/roles_generic/generators/roles_string_generator_spec.rb
|
221
|
-
- spec/roles_generic/strategy/multi/many_roles_spec.rb
|
222
|
-
- spec/roles_generic/strategy/multi/role_strings_spec.rb
|
223
|
-
- spec/roles_generic/strategy/multi/roles_mask_spec.rb
|
224
|
-
- spec/roles_generic/strategy/multi/roles_string_spec.rb
|
225
|
-
- spec/roles_generic/strategy/single/admin_flag_spec.rb
|
226
|
-
- spec/roles_generic/strategy/single/one_role_spec.rb
|
227
|
-
- spec/roles_generic/strategy/single/role_string_spec.rb
|
228
|
-
- spec/spec_helper.rb
|
193
|
+
test_files: []
|