be9-acl9 0.9.3 → 0.9.4

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.
data/CHANGELOG.textile CHANGED
@@ -1,3 +1,7 @@
1
+ h2. 0.9.4 (27-Feb-2009)
2
+
3
+ * Introduce :if and :unless rule options.
4
+
1
5
  h2. 0.9.3 (04-Feb-2009)
2
6
 
3
7
  * Fix bug in delete_role - didn't work with custom class names
data/README.textile CHANGED
@@ -538,6 +538,30 @@ below). You can also use @:only@ and @:except@ options in the
538
538
  @access_control@ call which will serve as options of the @before_filter@ and thus
539
539
  limit the scope of the whole ACL.
540
540
 
541
+ h3. Rule conditions
542
+
543
+ You may create conditional rules using @:if@ and @:unless@ options.
544
+
545
+ <pre><code>
546
+ allow :owner, :of => :site, :to => [:delete, :destroy], :if => :chance_to_delete
547
+ </code></pre>
548
+
549
+ Controller's @:chance_to_delete@ method will be called here. The rule will match if the action
550
+ is 'delete' or 'destroy' AND if the method returned @true@.
551
+
552
+ @:unless@ has the opposite meaning and should return @false@ for a rule to match.
553
+
554
+ Both options can be specified in the same rule.
555
+
556
+ <pre><code>
557
+ allow :visitor, :to => [:index, :show], :if => :right_phase_of_the_moon?, :unless => :suspicious?
558
+ </code></pre>
559
+
560
+ @right_phase_of_the_moon?@ should return @true@ AND @suspicious?@ should return @false@ for a poor visitor to
561
+ see a page.
562
+
563
+ Currently only controller methods are supported (specify them as :symbols). Lambdas are *not* supported.
564
+
541
565
  h2. Rule matching order
542
566
 
543
567
  Rule matching system is similar to that of Apache web server. There are two modes: _default allow_
data/Rakefile CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'rubygems'
2
- require File.join(File.dirname(__FILE__), 'lib', 'acl9', 'version')
3
2
  require 'rake'
4
3
  require 'spec/rake/spectask'
5
4
 
@@ -7,21 +6,20 @@ desc 'Default: run specs.'
7
6
  task :default => :spec
8
7
 
9
8
  begin
10
- require 'echoe'
11
-
12
- Echoe.new 'acl9' do |p|
13
- p.version = Acl9::Version::STRING
14
- p.author = "Oleg Dashevskii"
15
- p.email = 'olegdashevskii@gmail.com'
16
- p.project = 'acl9'
17
- p.summary = "Yet another role-based authorization system for Rails with a nice DSL for access control lists."
18
- p.url = "http://github.com/be9/acl9"
19
- p.ignore_pattern = ["spec/db/*.sqlite3", "spec/debug.log"]
20
- p.development_dependencies = ["rspec >=1.1.12", "rspec-rails >=1.1.12"]
9
+ require 'jeweler'
10
+ Jeweler::Tasks.new do |s|
11
+ s.name = "acl9"
12
+ s.summary = "Yet another role-based authorization system for Rails with a nice DSL for access control lists."
13
+ s.email = "olegdashevskii@gmail.com"
14
+ s.homepage = "http://github.com/be9/acl9"
15
+ s.description = "Yet another role-based authorization system for Rails with a nice DSL for access control lists."
16
+ s.authors = ["oleg dashevskii"]
17
+ s.files = FileList["[A-Z]*", "{lib,spec}/**/*.rb"]
18
+ s.add_development_dependency "rspec", ">= 1.1.12"
19
+ s.add_development_dependency "rspec-rails", ">= 1.1.12"
21
20
  end
22
- rescue LoadError => boom
23
- puts "You are missing a dependency required for meta-operations on this gem."
24
- puts "#{boom.to_s.capitalize}."
21
+ rescue LoadError
22
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
25
23
  end
26
24
 
27
25
  desc 'Run the specs'
@@ -29,9 +27,3 @@ Spec::Rake::SpecTask.new(:spec) do |t|
29
27
  t.spec_opts = ['--colour --format progress --loadby mtime --reverse']
30
28
  t.spec_files = FileList['spec/**/*_spec.rb']
31
29
  end
32
-
33
- desc 'Regenerate the .gemspec'
34
- task :gemspec => :package do
35
- gemspec = Dir["pkg/**/*.gemspec"].first
36
- FileUtils.cp gemspec, "."
37
- end
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :minor: 9
3
+ :patch: 4
4
+ :major: 0
@@ -2,7 +2,7 @@ module Acl9
2
2
  module Dsl
3
3
  class Base
4
4
  attr_reader :allows, :denys
5
-
5
+
6
6
  def initialize(*args)
7
7
  @default_action = nil
8
8
 
@@ -11,15 +11,15 @@ module Acl9
11
11
 
12
12
  @original_args = args
13
13
  end
14
-
14
+
15
15
  def acl_block!(&acl_block)
16
- self.instance_eval(&acl_block)
16
+ instance_eval(&acl_block)
17
17
  end
18
-
18
+
19
19
  def default_action
20
- @default_action.nil? ? :deny : @default_action
20
+ if @default_action.nil? then :deny else @default_action end
21
21
  end
22
-
22
+
23
23
  def allowance_expression
24
24
  allowed_expr = if @allows.size > 0
25
25
  @allows.map { |clause| "(#{clause})" }.join(' || ')
@@ -56,24 +56,24 @@ module Acl9
56
56
  @current_rule = :allow
57
57
  _parse_and_add_rule(*args)
58
58
  end
59
-
59
+
60
60
  def deny(*args)
61
61
  @current_rule = :deny
62
62
  _parse_and_add_rule(*args)
63
63
  end
64
64
 
65
65
  def actions(*args, &block)
66
- raise ArgumentError, "actions should receive at least 1 action as argument" if args.size < 1
67
-
66
+ raise ArgumentError, "actions should receive at least 1 action as argument" if args.size < 1
67
+
68
68
  subsidiary = self.class.new(*@original_args)
69
69
 
70
70
  class <<subsidiary
71
71
  def actions(*args)
72
- raise ArgumentError, "You cannot use actions inside another actions block"
72
+ raise ArgumentError, "You cannot use actions inside another actions block"
73
73
  end
74
74
 
75
75
  def default(*args)
76
- raise ArgumentError, "You cannot use default inside an actions block"
76
+ raise ArgumentError, "You cannot use default inside an actions block"
77
77
  end
78
78
 
79
79
  def _set_action_clause(to, except)
@@ -84,7 +84,7 @@ module Acl9
84
84
  subsidiary.acl_block!(&block)
85
85
 
86
86
  action_check = _action_check_expression(args)
87
-
87
+
88
88
  squash = lambda do |rules|
89
89
  _either_of(rules) + ' && ' + action_check
90
90
  end
@@ -98,18 +98,14 @@ module Acl9
98
98
  def anonymous; nil end
99
99
  def all; true end
100
100
  def logged_in; false end
101
-
101
+
102
102
  def _parse_and_add_rule(*args)
103
- options = if args.last.is_a? Hash
104
- args.pop
105
- else
106
- {}
107
- end
103
+ options = args.extract_options!
108
104
 
109
105
  _set_action_clause(options.delete(:to), options.delete(:except))
110
106
 
111
107
  object = _role_object(options)
112
-
108
+
113
109
  role_checks = args.map do |who|
114
110
  case who
115
111
  when nil then "#{_subject_ref}.nil?" # anonymous
@@ -120,23 +116,36 @@ module Acl9
120
116
  end
121
117
  end
122
118
 
123
- _add_rule case role_checks.size
119
+ [:if, :unless].each do |cond|
120
+ val = options[cond]
121
+ raise ArgumentError, "#{cond} option must be a Symbol" if val && !val.is_a?(Symbol)
122
+ end
123
+
124
+ condition = [
125
+ (_method_ref(options[:if]) if options[:if]),
126
+ ("!#{_method_ref(options[:unless])}" if options[:unless])
127
+ ].compact.join(' && ')
128
+
129
+ condition = nil if condition.blank?
130
+
131
+ _add_rule(case role_checks.size
124
132
  when 0
125
133
  raise ArgumentError, "allow/deny should have at least 1 argument"
126
134
  when 1 then role_checks.first
127
135
  else
128
136
  _either_of(role_checks)
129
- end
137
+ end, condition)
130
138
  end
131
139
 
132
140
  def _either_of(exprs)
133
141
  exprs.map { |expr| "(#{expr})" }.join(' || ')
134
142
  end
135
143
 
136
- def _add_rule(what)
137
- what = "(#{what}) && #{@action_clause}" if @action_clause
144
+ def _add_rule(what, condition)
145
+ anded = [what] + [@action_clause, condition].compact
146
+ anded[0] = "(#{anded[0]})" if anded.size > 1
138
147
 
139
- (@current_rule == :allow ? @allows : @denys) << what
148
+ (@current_rule == :allow ? @allows : @denys) << anded.join(' && ')
140
149
  end
141
150
 
142
151
  def _set_action_clause(to, except)
@@ -148,14 +157,14 @@ module Acl9
148
157
  return unless action_list
149
158
 
150
159
  expr = _action_check_expression(action_list)
151
-
160
+
152
161
  @action_clause = if to
153
162
  "#{expr}"
154
163
  else
155
164
  "!#{expr}"
156
165
  end
157
166
  end
158
-
167
+
159
168
  def _action_check_expression(action_list)
160
169
  unless action_list.is_a?(Array)
161
170
  action_list = [ action_list.to_s ]
@@ -167,7 +176,7 @@ module Acl9
167
176
  else
168
177
  set_of_actions = "Set.new([" + action_list.map { |act| "'#{act}'"}.join(',') + "])"
169
178
 
170
- "#{set_of_actions}.include?(#{_action_ref})"
179
+ "#{set_of_actions}.include?(#{_action_ref})"
171
180
  end
172
181
  end
173
182
 
@@ -194,7 +203,7 @@ module Acl9
194
203
  else
195
204
  raise ArgumentError, "object specified by preposition can only be a Class or a Symbol"
196
205
  end
197
- end
206
+ end
198
207
 
199
208
  def _subject_ref
200
209
  raise
@@ -207,6 +216,10 @@ module Acl9
207
216
  def _action_ref
208
217
  raise
209
218
  end
219
+
220
+ def _method_ref(method)
221
+ raise
222
+ end
210
223
  end
211
224
  end
212
225
  end
@@ -31,6 +31,10 @@ module Acl9
31
31
  "#{_controller_ref}action_name"
32
32
  end
33
33
 
34
+ def _method_ref(method)
35
+ "#{_controller_ref}send(:#{method})"
36
+ end
37
+
34
38
  def _controller_ref
35
39
  @controller ? "#{@controller}." : ''
36
40
  end
data/spec/controllers.rb CHANGED
@@ -21,6 +21,13 @@ class EmptyController < ApplicationController
21
21
  end
22
22
  end
23
23
 
24
+ module TrueFalse
25
+ private
26
+
27
+ def true_meth; true end
28
+ def false_meth; false end
29
+ end
30
+
24
31
  # all these controllers behave the same way
25
32
 
26
33
  class ACLBlock < EmptyController
@@ -46,14 +53,18 @@ end
46
53
 
47
54
  class ACLArguments < EmptyController
48
55
  access_control :except => [:index, :show] do
49
- allow :admin
56
+ allow :admin, :if => :true_meth, :unless => :false_meth
50
57
  end
58
+
59
+ include TrueFalse
51
60
  end
52
61
 
53
62
  class ACLBooleanMethod < EmptyController
54
63
  access_control :acl, :filter => false do
55
- allow all, :to => [:index, :show]
56
- allow :admin
64
+ allow all, :to => [:index, :show], :if => :true_meth
65
+ allow :admin, :unless => :false_meth
66
+ allow all, :if => :false_meth
67
+ allow all, :unless => :true_meth
57
68
  end
58
69
 
59
70
  before_filter :check_acl
@@ -65,6 +76,8 @@ class ACLBooleanMethod < EmptyController
65
76
  raise Acl9::AccessDenied
66
77
  end
67
78
  end
79
+
80
+ include TrueFalse
68
81
  end
69
82
 
70
83
  ###########################################
@@ -1,3 +1,4 @@
1
+ require 'ostruct'
1
2
  require File.join(File.dirname(__FILE__), 'spec_helper')
2
3
  require File.join(File.dirname(__FILE__), '..', 'lib', 'acl9', 'controller_extensions', 'dsl_base')
3
4
 
@@ -54,6 +55,7 @@ class DslTester < Acl9::Dsl::Base
54
55
  @_subject = subject
55
56
  @_current_action = (args[0] || 'index').to_s
56
57
  @_objects = args.last.is_a?(Hash) ? args.last : {}
58
+ @_callable = @_objects.delete(:call)
57
59
 
58
60
  instance_eval(allowance_expression)
59
61
  end
@@ -63,17 +65,21 @@ class DslTester < Acl9::Dsl::Base
63
65
  end
64
66
 
65
67
  def _object_ref(object)
66
- "@_objects[:#{object.to_s}]"
68
+ "@_objects[:#{object}]"
67
69
  end
68
70
 
69
71
  def _action_ref
70
72
  "@_current_action"
71
73
  end
74
+
75
+ def _method_ref(method)
76
+ "@_callable.send(:#{method})"
77
+ end
72
78
  end
73
79
 
74
80
  describe Acl9::Dsl::Base do
75
- class Foo; end
76
- class Bar; end
81
+ class ThatFoo; end
82
+ class ThatBar; end
77
83
 
78
84
  def arg_err(&block)
79
85
  lambda do
@@ -97,9 +103,9 @@ describe Acl9::Dsl::Base do
97
103
  @user = FakeUser.new
98
104
  @user2 = FakeUser.new
99
105
  @user3 = FakeUser.new
100
- @foo = Foo.new
101
- @foo2 = Foo.new
102
- @foo3 = Foo.new
106
+ @foo = ThatFoo.new
107
+ @foo2 = ThatFoo.new
108
+ @foo3 = ThatFoo.new
103
109
  end
104
110
 
105
111
  describe "default" do
@@ -368,7 +374,7 @@ describe Acl9::Dsl::Base do
368
374
  end.
369
375
  permit(@user, :foo => @foo).
370
376
  forbid(@user, :foo => @foo2).
371
- forbid(@user, :foo => Foo).
377
+ forbid(@user, :foo => ThatFoo).
372
378
  forbid(nil, :foo => @foo).
373
379
  forbid(@user2, :foo => @foo)
374
380
  end
@@ -381,10 +387,10 @@ describe Acl9::Dsl::Base do
381
387
  end
382
388
 
383
389
  it "#allow with a class role should verify this role against a class" do
384
- @user << [:owner, Foo]
390
+ @user << [:owner, ThatFoo]
385
391
 
386
392
  acl do
387
- allow :owner, :of => Foo
393
+ allow :owner, :of => ThatFoo
388
394
  end.permit(@user).forbid(nil).forbid(@user2)
389
395
  end
390
396
 
@@ -398,7 +404,7 @@ describe Acl9::Dsl::Base do
398
404
  end.
399
405
  forbid(@user, :foo => @foo).
400
406
  permit(@user, :foo => @foo2).
401
- permit(@user, :foo => Foo).
407
+ permit(@user, :foo => ThatFoo).
402
408
  permit(nil, :foo => @foo).
403
409
  permit(@user2, :foo => @foo)
404
410
  end
@@ -411,11 +417,11 @@ describe Acl9::Dsl::Base do
411
417
  end
412
418
 
413
419
  it "#deny with a class role should verify this role against a class" do
414
- @user << [:ignorant, Foo]
420
+ @user << [:ignorant, ThatFoo]
415
421
 
416
422
  acl do
417
423
  default :allow
418
- deny :ignorant, :of => Foo
424
+ deny :ignorant, :of => ThatFoo
419
425
  end.forbid(@user).permit(nil).permit(@user2)
420
426
  end
421
427
 
@@ -477,6 +483,51 @@ describe Acl9::Dsl::Base do
477
483
  end
478
484
  end
479
485
 
486
+ describe "conditions" do
487
+ [:if, :unless].each do |cond|
488
+ it "should raise ArgumentError when #{cond} is not a Symbol" do
489
+ arg_err do
490
+ allow nil, cond => 123
491
+ end
492
+ end
493
+ end
494
+
495
+ it "allow ... :if" do
496
+ acl do
497
+ allow nil, :if => :meth
498
+ end.
499
+ permit(nil, :call => OpenStruct.new(:meth => true)).
500
+ forbid(nil, :call => OpenStruct.new(:meth => false))
501
+ end
502
+
503
+ it "allow ... :unless" do
504
+ acl do
505
+ allow nil, :unless => :meth
506
+ end.
507
+ permit(nil, :call => OpenStruct.new(:meth => false)).
508
+ forbid(nil, :call => OpenStruct.new(:meth => true))
509
+ end
510
+
511
+ it "deny ... :if" do
512
+ acl do
513
+ default :allow
514
+ deny nil, :if => :meth
515
+ end.
516
+ permit(nil, :call => OpenStruct.new(:meth => false)).
517
+ forbid(nil, :call => OpenStruct.new(:meth => true))
518
+ end
519
+
520
+ it "deny ... :unless" do
521
+ acl do
522
+ default :allow
523
+ deny nil, :unless => :meth
524
+ end.
525
+ permit(nil, :call => OpenStruct.new(:meth => true)).
526
+ forbid(nil, :call => OpenStruct.new(:meth => false))
527
+ end
528
+
529
+ end
530
+
480
531
  describe "several roles as arguments" do
481
532
  it "#allow should be able to receive a role list (global roles)" do
482
533
  @user << :bzz
@@ -504,12 +555,12 @@ describe Acl9::Dsl::Base do
504
555
  end
505
556
 
506
557
  it "#allow should be able to receive a role list (class roles)" do
507
- @user << [:frooble, Foo]
508
- @user2 << [:oombigle, Foo]
558
+ @user << [:frooble, ThatFoo]
559
+ @user2 << [:oombigle, ThatFoo]
509
560
  @user3 << :frooble
510
561
 
511
562
  acl do
512
- allow :frooble, :oombigle, :by => Foo
563
+ allow :frooble, :oombigle, :by => ThatFoo
513
564
  end.
514
565
  permit(@user).
515
566
  permit(@user2).
@@ -546,13 +597,13 @@ describe Acl9::Dsl::Base do
546
597
  end
547
598
 
548
599
  it "#deny should be able to receive a role list (class roles)" do
549
- @user << [:frooble, Foo]
550
- @user2 << [:oombigle, Foo]
600
+ @user << [:frooble, ThatFoo]
601
+ @user2 << [:oombigle, ThatFoo]
551
602
  @user3 << :frooble
552
603
 
553
604
  acl do
554
605
  default :allow
555
- deny :frooble, :oombigle, :by => Foo
606
+ deny :frooble, :oombigle, :by => ThatFoo
556
607
  end.
557
608
  forbid(@user).
558
609
  forbid(@user2).
@@ -670,7 +721,7 @@ describe Acl9::Dsl::Base do
670
721
  end
671
722
 
672
723
  it "#allow and #deny should work together inside actions block" do
673
- @foo = Foo.new
724
+ @foo = ThatFoo.new
674
725
  @user << [:owner, @foo]
675
726
  @user2 << :hacker
676
727
  @user2 << :the_destroyer
metadata CHANGED
@@ -1,19 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: be9-acl9
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
- - Oleg Dashevskii
7
+ - oleg dashevskii
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-04 00:00:00 -08:00
12
+ date: 2009-02-27 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
17
+ type: :development
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
@@ -23,6 +24,7 @@ dependencies:
23
24
  version:
24
25
  - !ruby/object:Gem::Dependency
25
26
  name: rspec-rails
27
+ type: :development
26
28
  version_requirement:
27
29
  version_requirements: !ruby/object:Gem::Requirement
28
30
  requirements:
@@ -36,57 +38,38 @@ executables: []
36
38
 
37
39
  extensions: []
38
40
 
39
- extra_rdoc_files:
40
- - lib/acl9/helpers.rb
41
+ extra_rdoc_files: []
42
+
43
+ files:
44
+ - CHANGELOG.textile
45
+ - MIT-LICENSE
46
+ - Rakefile
47
+ - README.textile
48
+ - TODO
49
+ - VERSION.yml
41
50
  - lib/acl9/config.rb
42
- - lib/acl9/model_extensions/subject.rb
43
- - lib/acl9/model_extensions/object.rb
44
- - lib/acl9/controller_extensions.rb
45
- - lib/acl9/controller_extensions/generators.rb
46
51
  - lib/acl9/controller_extensions/dsl_base.rb
47
- - lib/acl9/version.rb
48
- - lib/acl9/model_extensions.rb
49
- - lib/acl9.rb
50
- - TODO
51
- - README.textile
52
- - CHANGELOG.textile
53
- files:
52
+ - lib/acl9/controller_extensions/generators.rb
53
+ - lib/acl9/controller_extensions.rb
54
54
  - lib/acl9/helpers.rb
55
- - lib/acl9/config.rb
56
- - lib/acl9/model_extensions/subject.rb
57
55
  - lib/acl9/model_extensions/object.rb
58
- - lib/acl9/controller_extensions.rb
59
- - lib/acl9/controller_extensions/generators.rb
60
- - lib/acl9/controller_extensions/dsl_base.rb
61
- - lib/acl9/version.rb
56
+ - lib/acl9/model_extensions/subject.rb
62
57
  - lib/acl9/model_extensions.rb
63
58
  - lib/acl9.rb
64
- - TODO
59
+ - spec/access_control_spec.rb
60
+ - spec/controllers.rb
65
61
  - spec/db/schema.rb
62
+ - spec/dsl_base_spec.rb
66
63
  - spec/helpers_spec.rb
67
- - spec/spec_helper.rb
68
64
  - spec/models.rb
69
- - spec/dsl_base_spec.rb
70
- - spec/access_control_spec.rb
71
- - spec/controllers.rb
72
65
  - spec/roles_spec.rb
73
- - acl9.gemspec
74
- - Manifest
75
- - MIT-LICENSE
76
- - Rakefile
77
- - README.textile
78
- - init.rb
79
- - CHANGELOG.textile
66
+ - spec/spec_helper.rb
80
67
  has_rdoc: true
81
68
  homepage: http://github.com/be9/acl9
82
69
  post_install_message:
83
70
  rdoc_options:
84
- - --line-numbers
85
71
  - --inline-source
86
- - --title
87
- - Acl9
88
- - --main
89
- - README.textile
72
+ - --charset=UTF-8
90
73
  require_paths:
91
74
  - lib
92
75
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -99,11 +82,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
82
  requirements:
100
83
  - - ">="
101
84
  - !ruby/object:Gem::Version
102
- version: "1.2"
85
+ version: "0"
103
86
  version:
104
87
  requirements: []
105
88
 
106
- rubyforge_project: acl9
89
+ rubyforge_project:
107
90
  rubygems_version: 1.2.0
108
91
  signing_key:
109
92
  specification_version: 2
data/Manifest DELETED
@@ -1,26 +0,0 @@
1
- lib/acl9/helpers.rb
2
- lib/acl9/config.rb
3
- lib/acl9/model_extensions/subject.rb
4
- lib/acl9/model_extensions/object.rb
5
- lib/acl9/controller_extensions.rb
6
- lib/acl9/controller_extensions/generators.rb
7
- lib/acl9/controller_extensions/dsl_base.rb
8
- lib/acl9/version.rb
9
- lib/acl9/model_extensions.rb
10
- lib/acl9.rb
11
- TODO
12
- spec/db/schema.rb
13
- spec/helpers_spec.rb
14
- spec/spec_helper.rb
15
- spec/models.rb
16
- spec/dsl_base_spec.rb
17
- spec/access_control_spec.rb
18
- spec/controllers.rb
19
- spec/roles_spec.rb
20
- acl9.gemspec
21
- Manifest
22
- MIT-LICENSE
23
- Rakefile
24
- README.textile
25
- init.rb
26
- CHANGELOG.textile
data/acl9.gemspec DELETED
@@ -1,37 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{acl9}
5
- s.version = "0.9.3"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Oleg Dashevskii"]
9
- s.date = %q{2009-02-04}
10
- s.description = %q{Yet another role-based authorization system for Rails with a nice DSL for access control lists.}
11
- s.email = %q{olegdashevskii@gmail.com}
12
- s.extra_rdoc_files = ["lib/acl9/helpers.rb", "lib/acl9/config.rb", "lib/acl9/model_extensions/subject.rb", "lib/acl9/model_extensions/object.rb", "lib/acl9/controller_extensions.rb", "lib/acl9/controller_extensions/generators.rb", "lib/acl9/controller_extensions/dsl_base.rb", "lib/acl9/version.rb", "lib/acl9/model_extensions.rb", "lib/acl9.rb", "TODO", "README.textile", "CHANGELOG.textile"]
13
- s.files = ["lib/acl9/helpers.rb", "lib/acl9/config.rb", "lib/acl9/model_extensions/subject.rb", "lib/acl9/model_extensions/object.rb", "lib/acl9/controller_extensions.rb", "lib/acl9/controller_extensions/generators.rb", "lib/acl9/controller_extensions/dsl_base.rb", "lib/acl9/version.rb", "lib/acl9/model_extensions.rb", "lib/acl9.rb", "TODO", "spec/db/schema.rb", "spec/helpers_spec.rb", "spec/spec_helper.rb", "spec/models.rb", "spec/dsl_base_spec.rb", "spec/access_control_spec.rb", "spec/controllers.rb", "spec/roles_spec.rb", "acl9.gemspec", "Manifest", "MIT-LICENSE", "Rakefile", "README.textile", "init.rb", "CHANGELOG.textile"]
14
- s.has_rdoc = true
15
- s.homepage = %q{http://github.com/be9/acl9}
16
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Acl9", "--main", "README.textile"]
17
- s.require_paths = ["lib"]
18
- s.rubyforge_project = %q{acl9}
19
- s.rubygems_version = %q{1.3.1}
20
- s.summary = %q{Yet another role-based authorization system for Rails with a nice DSL for access control lists.}
21
-
22
- if s.respond_to? :specification_version then
23
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
- s.specification_version = 2
25
-
26
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
- s.add_development_dependency(%q<rspec>, [">= 1.1.12"])
28
- s.add_development_dependency(%q<rspec-rails>, [">= 1.1.12"])
29
- else
30
- s.add_dependency(%q<rspec>, [">= 1.1.12"])
31
- s.add_dependency(%q<rspec-rails>, [">= 1.1.12"])
32
- end
33
- else
34
- s.add_dependency(%q<rspec>, [">= 1.1.12"])
35
- s.add_dependency(%q<rspec-rails>, [">= 1.1.12"])
36
- end
37
- end
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require 'acl9'
data/lib/acl9/version.rb DELETED
@@ -1,54 +0,0 @@
1
- module Acl9 # :nodoc:
2
- # = Version
3
- #
4
- # A class for describing the current version of a library. The version
5
- # consists of three parts: the +major+ number, the +minor+ number, and the
6
- # +tiny+ (or +patch+) number.
7
- class Version
8
-
9
- include Comparable
10
-
11
- # A convenience method for instantiating a new Version instance with the
12
- # given +major+, +minor+, and +tiny+ components.
13
- def self.[](major, minor, tiny)
14
- new(major, minor, tiny)
15
- end
16
-
17
- attr_reader :major, :minor, :tiny
18
-
19
- # Create a new Version object with the given components.
20
- def initialize(major, minor, tiny)
21
- @major, @minor, @tiny = major, minor, tiny
22
- end
23
-
24
- # Compare this version to the given +version+ object.
25
- def <=>(version)
26
- to_i <=> version.to_i
27
- end
28
-
29
- # Converts this version object to a string, where each of the three
30
- # version components are joined by the '.' character. E.g., 2.0.0.
31
- def to_s
32
- @to_s ||= [@major, @minor, @tiny].join(".")
33
- end
34
-
35
- # Converts this version to a canonical integer that may be compared
36
- # against other version objects.
37
- def to_i
38
- @to_i ||= @major * 1_000_000 + @minor * 1_000 + @tiny
39
- end
40
-
41
- def to_a
42
- [@major, @minor, @tiny]
43
- end
44
-
45
- MAJOR = 0
46
- MINOR = 9
47
- TINY = 3
48
-
49
- # The current version as a Version instance
50
- CURRENT = new(MAJOR, MINOR, TINY)
51
- # The current version as a String
52
- STRING = CURRENT.to_s
53
- end
54
- end