restful_acl 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.0
1
+ 3.0.1
@@ -4,18 +4,9 @@ module RestfulAcl
4
4
  attr_accessor :object, :parent, :user, :controller_name, :uri, :action, :object_id
5
5
 
6
6
 
7
- def initialize(options = {})
8
- @object_id = options[:object_id]
9
- @user = options[:user]
10
- @uri = options[:uri]
11
- @action = options[:action]
12
- @controller_name = options[:controller_name]
13
-
14
- if @object_id.present?
15
- load_actors_from_id
16
- else
17
- load_actors_from_uri
18
- end
7
+ def initialize(options)
8
+ options.each{|(k,v)| instance_variable_set "@#{k}", v}
9
+ (@object_id.present?) ? load_actors_from_id : load_actors_from_uri
19
10
  end
20
11
 
21
12
  def load_actors_from_id
@@ -8,5 +8,17 @@ module RestfulAcl
8
8
  yield if access.allowed?
9
9
  end
10
10
 
11
+ %w{creat delet updat read}.each do |m|
12
+ define_method("#{m}able?") do |*args, &block|
13
+ RAILS_DEFAULT_LOGGER.error <<-STR
14
+
15
+ *****************************************************************************************
16
+ * RESTful_ACL error => ##{m}able? has been removed as of v3.0.0, please use #allowable?
17
+ *****************************************************************************************
18
+
19
+ STR
20
+ end
21
+ end
22
+
11
23
  end
12
- end
24
+ end
@@ -8,23 +8,23 @@
8
8
  class UrlParser
9
9
 
10
10
  TypesOfURLs = [
11
- {:name => "parent_with_specific_child", :controller_bit => 3, :object_id_bit => 4, :regex => /\/(\w+)\/(\d+)[\w|-]*\/(\w+)\/(\d+)[\w|-]*$/},
12
- {:name => "parent_with_edit_child", :controller_bit => 3, :object_id_bit => 4, :regex => /\/(\w+)\/(\d+)[\w|-]*\/(\w+)\/(\d+)[\w|-]*\/edit$/},
13
- {:name => "parent_with_child_index", :controller_bit => 3, :object_id_bit => nil, :regex => /\/(\w+)\/(\d+)[\w|-]*\/(\w+)$/},
14
- {:name => "parent_with_new_child", :controller_bit => 3, :object_id_bit => nil, :regex => /\/(\w+)\/(\d+)[\w|-]*\/(\w+)\/new$/},
15
- {:name => "edit_singleton_child", :controller_bit => 3, :object_id_bit => nil, :regex => /\/(\w+)\/(\d+)[\w|-]*\/(\w+)\/edit$/},
16
- {:name => "new_singleton_child", :controller_bit => 3, :object_id_bit => nil, :regex => /\/(\w+)\/(\d+)[\w|-]*\/(\w+)\/new$/},
17
- {:name => "edit_parent", :controller_bit => 1, :object_id_bit => 2, :regex => /\/(\w+)\/edit$/},
11
+ {:name => "parent_with_specific_child", :controller_bit => 3, :object_id_bit => 4, :regex => /\/(\w+)\/(\d+)[\w-]*\/(\w+)\/(\d+)[\w-]*$/},
12
+ {:name => "parent_with_edit_child", :controller_bit => 3, :object_id_bit => 4, :regex => /\/(\w+)\/(\d+)[\w-]*\/(\w+)\/(\d+)[\w-]*\/edit$/},
13
+ {:name => "parent_with_child_index", :controller_bit => 3, :object_id_bit => nil, :regex => /\/(\w+)\/(\d+)[\w-]*\/(\w+)$/},
14
+ {:name => "parent_with_new_child", :controller_bit => 3, :object_id_bit => nil, :regex => /\/(\w+)\/(\d+)[\w-]*\/(\w+)\/new$/},
15
+ {:name => "edit_singleton_child", :controller_bit => 3, :object_id_bit => nil, :regex => /\/(\w+)\/(\d+)[\w-]*\/(\w+)\/edit$/},
16
+ {:name => "new_singleton_child", :controller_bit => 3, :object_id_bit => nil, :regex => /\/(\w+)\/(\d+)[\w-]*\/(\w+)\/new$/},
17
+ {:name => "edit_parent", :controller_bit => 1, :object_id_bit => 2, :regex => /\/(\w+)\/(\d+)[\w-]*\/edit$/},
18
18
  {:name => "new_parent", :controller_bit => 1, :object_id_bit => nil, :regex => /\/(\w+)\/new$/},
19
- {:name => "specific_parent", :controller_bit => 1, :object_id_bit => 2, :regex => /\/(\w+)\/(\d+)[\w|-]*$/},
19
+ {:name => "specific_parent", :controller_bit => 1, :object_id_bit => 2, :regex => /\/(\w+)\/(\d+)[\w-]*$/},
20
20
  {:name => "parent_index", :controller_bit => 1, :object_id_bit => nil, :regex => /\/(\w+)$/}
21
21
  ]
22
22
 
23
- URL = /href="([\w|\/|-]+)"/
24
- AJAXURL = /url:'([\w|\/|-]+)'/
23
+ URL = /href="([\w\/-?$_.+!*'(),]+)"/
24
+ AJAXURL = /url:'([\w\/-?$_.+!*'(),]+)'/
25
25
  NewURL = /\/new$/
26
26
  EditURL = /\/edit$/
27
- ObjectURL = /\/(\d+)[\w|-]*$/
27
+ ObjectURL = /\/(\d+)[\w-]*$/
28
28
  DestroyURL = /.*m\.setAttribute\('value', 'delete'\).*/
29
29
 
30
30
  attr_accessor :text, :user, :url
@@ -69,7 +69,8 @@ class UrlParser
69
69
 
70
70
  # Call the dynamically created method with arguments from deduced hash
71
71
  def invoke_url_type_method(type)
72
- send(type[:name], @url, type[:controller_bit], type[:object_id_bit], type[:regex])
72
+ data = OpenStruct.new(type)
73
+ send(data.name, @url, data.controller_bit, data.object_id_bit, data.regex)
73
74
  end
74
75
 
75
76
  # Deduce the requested URL's "type" based on the TypesOfURLs hash
data/restful_acl.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{restful_acl}
8
- s.version = "3.0.0"
8
+ s.version = "3.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Darby"]
12
- s.date = %q{2009-11-28}
12
+ s.date = %q{2009-12-07}
13
13
  s.description = %q{A Ruby on Rails plugin that provides fine grained access control to RESTful resources.}
14
14
  s.email = %q{matt@matt-darby.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restful_acl
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Darby
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-28 00:00:00 -05:00
12
+ date: 2009-12-07 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency