role_up 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,18 +1,77 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- role_up (0.1.2)
5
- activesupport (~> 3.0.0)
4
+ role_up (0.1.3)
6
5
  cancan (~> 1.6.5)
7
- i18n (~> 0.6.0)
6
+ rails (~> 3.0.0)
8
7
 
9
8
  GEM
10
9
  remote: http://rubygems.org/
11
10
  specs:
11
+ abstract (1.0.0)
12
+ actionmailer (3.0.7)
13
+ actionpack (= 3.0.7)
14
+ mail (~> 2.2.15)
15
+ actionpack (3.0.7)
16
+ activemodel (= 3.0.7)
17
+ activesupport (= 3.0.7)
18
+ builder (~> 2.1.2)
19
+ erubis (~> 2.6.6)
20
+ i18n (~> 0.5.0)
21
+ rack (~> 1.2.1)
22
+ rack-mount (~> 0.6.14)
23
+ rack-test (~> 0.5.7)
24
+ tzinfo (~> 0.3.23)
25
+ activemodel (3.0.7)
26
+ activesupport (= 3.0.7)
27
+ builder (~> 2.1.2)
28
+ i18n (~> 0.5.0)
29
+ activerecord (3.0.7)
30
+ activemodel (= 3.0.7)
31
+ activesupport (= 3.0.7)
32
+ arel (~> 2.0.2)
33
+ tzinfo (~> 0.3.23)
34
+ activeresource (3.0.7)
35
+ activemodel (= 3.0.7)
36
+ activesupport (= 3.0.7)
12
37
  activesupport (3.0.7)
38
+ arel (2.0.10)
39
+ builder (2.1.2)
13
40
  cancan (1.6.5)
14
- i18n (0.6.0)
41
+ erubis (2.6.6)
42
+ abstract (>= 1.0.0)
43
+ i18n (0.5.0)
44
+ mail (2.2.19)
45
+ activesupport (>= 2.3.6)
46
+ i18n (>= 0.4.0)
47
+ mime-types (~> 1.16)
48
+ treetop (~> 1.4.8)
49
+ mime-types (1.16)
15
50
  minitest (2.2.2)
51
+ polyglot (0.3.1)
52
+ rack (1.2.3)
53
+ rack-mount (0.6.14)
54
+ rack (>= 1.0.0)
55
+ rack-test (0.5.7)
56
+ rack (>= 1.0)
57
+ rails (3.0.7)
58
+ actionmailer (= 3.0.7)
59
+ actionpack (= 3.0.7)
60
+ activerecord (= 3.0.7)
61
+ activeresource (= 3.0.7)
62
+ activesupport (= 3.0.7)
63
+ bundler (~> 1.0)
64
+ railties (= 3.0.7)
65
+ railties (3.0.7)
66
+ actionpack (= 3.0.7)
67
+ activesupport (= 3.0.7)
68
+ rake (>= 0.8.7)
69
+ thor (~> 0.14.4)
70
+ rake (0.9.1)
71
+ thor (0.14.6)
72
+ treetop (1.4.9)
73
+ polyglot (>= 0.3.1)
74
+ tzinfo (0.3.27)
16
75
 
17
76
  PLATFORMS
18
77
  ruby
data/README.md CHANGED
@@ -2,6 +2,18 @@ Role Up
2
2
  ===========
3
3
  `CanCan` extension that adds some real-deal syntax and file organization lovin'!
4
4
 
5
+ ### Warning
6
+ * Rule loading on application boot is finicky - should be fixed with
7
+ Railtie commit
8
+ * Changing rules in an ability class is not reflected on page reload in
9
+ development mode
10
+
11
+ ### TODO
12
+ * Integration tests utilizing a complete `Rails` application
13
+ * Configure `role_up/railtie` to properly load the `app/abilities`
14
+ directory - currently hacked in
15
+ * Tests against `CanCan` 2.0 code base
16
+
5
17
  ### Convention
6
18
  Authorization definitions with `CanCan` quickly become verbose in complex
7
19
  applications. By breaking them up per model and being able to depend on
@@ -24,17 +36,19 @@ Here's an example ability file...
24
36
  # app/abilities/widget_ability.rb
25
37
  class WidgetAbility < Ability
26
38
 
27
- define_rules :widget do |user|
39
+ define_rules do |user|
28
40
  can :manage , Widget , :user_id => user.id
29
41
  end
30
42
 
31
43
  end
32
44
 
33
- The `define_rules` method accepts a block and yields the current user.
34
- In this block, the standard `CanCan` ability definitions methods apply. If
35
- you have a set of standard authorization rules, you can reopen the
36
- provided `Ability` class and define a `standard_rules` block. Check
37
- it...
45
+ The `define_rules` method accepts a block and yields the current authorization
46
+ instance. This might be a User object, an instance of what is specified
47
+ in the `RoleUp.setup` block, or the instance provided when the Ability
48
+ class was instantiated. In this block, the standard `CanCan` ability
49
+ definitions methods apply. If you have a set of standard authorization
50
+ rules, you can reopen the provided `Ability` class and define a `standard_rules`
51
+ block. Check it...
38
52
 
39
53
  # app/abilities/ability.rb
40
54
  class Ability
data/lib/role_up.rb CHANGED
@@ -6,6 +6,7 @@ module RoleUp
6
6
  # Lock 'n Load
7
7
  autoload :Errors , 'role_up/errors'
8
8
  require 'role_up/ability'
9
+ require 'role_up/railtie'
9
10
 
10
11
  # The class we'll authorize against
11
12
  mattr_accessor :authorization_class
@@ -0,0 +1,16 @@
1
+ require 'rails/railtie'
2
+
3
+ module RoleUp
4
+
5
+ class Railtie < Rails::Railtie
6
+
7
+ initializer "role_up.initialize_app_abilities" do |app|
8
+
9
+ # load our app/abilities directory
10
+ Dir[ "#{app.root}/app/abilities/**/*_ability.rb" ].each { |a| require a }
11
+
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -1,5 +1,5 @@
1
1
  module RoleUp
2
2
  # Our gem version
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
 
data/role_up.gemspec CHANGED
@@ -15,9 +15,8 @@ Gem::Specification.new do |s|
15
15
  s.rubyforge_project = "role_up"
16
16
 
17
17
  # Runtime Dependencies
18
- s.add_dependency "activesupport" , "~> 3.0.0"
19
18
  s.add_dependency "cancan" , "~> 1.6.5"
20
- s.add_dependency "i18n" , "~> 0.6.0"
19
+ s.add_dependency "rails" , "~> 3.0.0"
21
20
 
22
21
  # Development Dependencies
23
22
  s.add_development_dependency "bundler" , "~> 1.0.0"
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: role_up
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
5
4
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 2
10
- version: 0.1.2
5
+ version: 0.1.3
11
6
  platform: ruby
12
7
  authors:
13
8
  - Ryan Cook
@@ -15,89 +10,52 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-06-01 00:00:00 -06:00
19
- default_executable:
13
+ date: 2011-06-03 00:00:00 Z
20
14
  dependencies:
21
15
  - !ruby/object:Gem::Dependency
22
- name: activesupport
16
+ name: cancan
23
17
  prerelease: false
24
18
  requirement: &id001 !ruby/object:Gem::Requirement
25
19
  none: false
26
20
  requirements:
27
21
  - - ~>
28
22
  - !ruby/object:Gem::Version
29
- hash: 7
30
- segments:
31
- - 3
32
- - 0
33
- - 0
34
- version: 3.0.0
23
+ version: 1.6.5
35
24
  type: :runtime
36
25
  version_requirements: *id001
37
26
  - !ruby/object:Gem::Dependency
38
- name: cancan
27
+ name: rails
39
28
  prerelease: false
40
29
  requirement: &id002 !ruby/object:Gem::Requirement
41
30
  none: false
42
31
  requirements:
43
32
  - - ~>
44
33
  - !ruby/object:Gem::Version
45
- hash: 5
46
- segments:
47
- - 1
48
- - 6
49
- - 5
50
- version: 1.6.5
34
+ version: 3.0.0
51
35
  type: :runtime
52
36
  version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: i18n
55
- prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- hash: 7
62
- segments:
63
- - 0
64
- - 6
65
- - 0
66
- version: 0.6.0
67
- type: :runtime
68
- version_requirements: *id003
69
37
  - !ruby/object:Gem::Dependency
70
38
  name: bundler
71
39
  prerelease: false
72
- requirement: &id004 !ruby/object:Gem::Requirement
40
+ requirement: &id003 !ruby/object:Gem::Requirement
73
41
  none: false
74
42
  requirements:
75
43
  - - ~>
76
44
  - !ruby/object:Gem::Version
77
- hash: 23
78
- segments:
79
- - 1
80
- - 0
81
- - 0
82
45
  version: 1.0.0
83
46
  type: :development
84
- version_requirements: *id004
47
+ version_requirements: *id003
85
48
  - !ruby/object:Gem::Dependency
86
49
  name: minitest
87
50
  prerelease: false
88
- requirement: &id005 !ruby/object:Gem::Requirement
51
+ requirement: &id004 !ruby/object:Gem::Requirement
89
52
  none: false
90
53
  requirements:
91
54
  - - ~>
92
55
  - !ruby/object:Gem::Version
93
- hash: 3
94
- segments:
95
- - 2
96
- - 2
97
- - 2
98
56
  version: 2.2.2
99
57
  type: :development
100
- version_requirements: *id005
58
+ version_requirements: *id004
101
59
  description: CanCan extension that adds some real-deal syntax and file organization lovin'!
102
60
  email:
103
61
  - ryan@quickleft.com
@@ -118,6 +76,7 @@ files:
118
76
  - lib/role_up.rb
119
77
  - lib/role_up/ability.rb
120
78
  - lib/role_up/errors.rb
79
+ - lib/role_up/railtie.rb
121
80
  - lib/role_up/version.rb
122
81
  - role_up.gemspec
123
82
  - test/ability_spec_test.rb
@@ -127,7 +86,6 @@ files:
127
86
  - test/support/helper_classes.rb
128
87
  - test/support/helper_methods.rb
129
88
  - test/test_helper.rb
130
- has_rdoc: true
131
89
  homepage: https://github.com/quickleft/role_up
132
90
  licenses: []
133
91
 
@@ -141,26 +99,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
141
99
  requirements:
142
100
  - - ">="
143
101
  - !ruby/object:Gem::Version
144
- hash: 3
145
- segments:
146
- - 0
147
102
  version: "0"
148
103
  required_rubygems_version: !ruby/object:Gem::Requirement
149
104
  none: false
150
105
  requirements:
151
106
  - - ">="
152
107
  - !ruby/object:Gem::Version
153
- hash: 3
154
- segments:
155
- - 0
156
108
  version: "0"
157
109
  requirements: []
158
110
 
159
111
  rubyforge_project: role_up
160
- rubygems_version: 1.6.2
112
+ rubygems_version: 1.8.5
161
113
  signing_key:
162
114
  specification_version: 3
163
- summary: role_up-0.1.2
115
+ summary: role_up-0.1.3
164
116
  test_files:
165
117
  - test/ability_spec_test.rb
166
118
  - test/ability_test.rb