canard 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/TODO CHANGED
@@ -2,4 +2,5 @@
2
2
  * Test the ability class.
3
3
  * Test the generators.
4
4
  * Test the railtie
5
- * Add scopes by default and :scopes => false to acts_as_user
5
+ * Add scopes by default and :scopes => false to acts_as_user
6
+ * Expand the tests to produce all the standard abilities: index,show,read,new,create,edit,update,destroy.
@@ -1,3 +1,3 @@
1
1
  module Canard
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -6,12 +6,12 @@ class AbilityDefinition
6
6
 
7
7
  def self.parse(definitions)
8
8
  @@ability_definitions ||= {}
9
- limitation, ability_names, model_names = *definitions.split(':')
10
- abilities, models = extract(ability_names), extract(model_names)
11
- models.each do |model|
12
- definition = @@ability_definitions[model] || AbilityDefinition.new
13
- definition.merge(limitation.pluralize, abilities)
14
- @@ability_definitions[model] = definition
9
+ limitation, ability_list, model_list = *definitions.split(':')
10
+ ability_names, model_names = extract(ability_list), extract(model_list)
11
+ model_names.each do |model_name|
12
+ definition = @@ability_definitions[model_name] || AbilityDefinition.new
13
+ definition.merge(limitation.pluralize, ability_names)
14
+ @@ability_definitions[model_name] = definition
15
15
  end
16
16
  end
17
17
 
@@ -27,9 +27,9 @@ class AbilityDefinition
27
27
  @cans, @cannots = [], []
28
28
  end
29
29
 
30
- def merge(limitation, abilities)
31
- combined_abilities = instance_variable_get("@#{limitation}") | abilities
32
- instance_variable_set("@#{limitation}", combined_abilities)
30
+ def merge(limitation, ability_names)
31
+ combined_ability_names = instance_variable_get("@#{limitation}") | ability_names
32
+ instance_variable_set("@#{limitation}", combined_ability_names)
33
33
  end
34
34
 
35
35
  def can
@@ -8,15 +8,11 @@ module Rspec
8
8
  argument :ability_definitions, :type => :array, :default => [], :banner => "can:abilities:models cannot:abilities:models"
9
9
 
10
10
  def generate_ability_spec
11
- template "abilities_spec.rb.erb", "spec/abilities/#{file_name}_spec.rb"
11
+ template "abilities_spec.rb.erb", "spec/abilities/#{file_name.pluralize}_spec.rb"
12
12
  end
13
13
 
14
14
  private
15
15
 
16
- def add_new_abilities
17
- gsub_file "spec/abilities/#{file_name}_spec.rb", /^(\s*end\s*\Z)/, 'wibble' + '\1'
18
- end
19
-
20
16
  def definitions(&block)
21
17
  ability_definitions.each { |definition| AbilityDefinition.parse(definition) }
22
18
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
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-10-02 00:00:00.000000000Z
12
+ date: 2011-10-10 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
16
- requirement: &2153881520 !ruby/object:Gem::Requirement
16
+ requirement: &2153302940 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '2'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2153881520
24
+ version_requirements: *2153302940
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sqlite3
27
- requirement: &2153881100 !ruby/object:Gem::Requirement
27
+ requirement: &2153302520 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2153881100
35
+ version_requirements: *2153302520
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activerecord
38
- requirement: &2153880640 !ruby/object:Gem::Requirement
38
+ requirement: &2153302060 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2153880640
46
+ version_requirements: *2153302060
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: cancan
49
- requirement: &2153880220 !ruby/object:Gem::Requirement
49
+ requirement: &2153301640 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2153880220
57
+ version_requirements: *2153301640
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: role_model
60
- requirement: &2153879800 !ruby/object:Gem::Requirement
60
+ requirement: &2153301220 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *2153879800
68
+ version_requirements: *2153301220
69
69
  description: Wraps CanCan and RoleModel up with a generator and makes role based authorisation
70
70
  really easy in Rails 3.x.
71
71
  email: