netzke-cancan 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Georg Meyer
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,29 @@
1
+ = netzke-cancan
2
+
3
+ netzke-cancan simply adds all {cancan}[https://github.com/ryanb/cancan] controller helper methods to all {Netzke}[https://github.com/nomadcoder/netzke-basepack/] components.
4
+
5
+ == Installation
6
+
7
+ In Rails 3, add this to your gem file and run the +bundle+ command.
8
+
9
+ gem 'netzke-cancan'
10
+
11
+ == Usage
12
+
13
+ Simply use all cancan helper methods like can?, cannot? or authorize! in your Netzke components the same way you would do that inside of your controller.
14
+
15
+ == Contributing to netzke-cancan
16
+
17
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
18
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
19
+ * Fork the project.
20
+ * Start a feature/bugfix branch.
21
+ * Commit and push until you are happy with your contribution.
22
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
23
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
24
+
25
+ == Copyright
26
+
27
+ Copyright (c) 2012 Georg Meyer. See LICENSE.txt for
28
+ further details.
29
+
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rspec/core/rake_task'
4
+ require 'bundler'
5
+
6
+ Bundler::GemHelper.install_tasks
7
+
8
+ desc "Run RSpec"
9
+ RSpec::Core::RakeTask.new do |t|
10
+ t.verbose = false
11
+ end
12
+
13
+ task :default => :spec
@@ -0,0 +1,11 @@
1
+ module Netzke
2
+ module CanCan
3
+ module Version
4
+ MAJOR = 0
5
+ MINOR = 0
6
+ PATCH = 1
7
+
8
+ STRING = [MAJOR, MINOR, PATCH].compact.join('.')
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,21 @@
1
+ module Netzke
2
+ class Base
3
+
4
+ # This method is returns the current ability with the current user from netzke
5
+ #
6
+ # @return [Ability]
7
+ def current_ability
8
+ @current_ability ||= Ability.new(Netzke::Core.current_user)
9
+ end
10
+
11
+ # cancan calls helper_method, which is present in any controller, but not in a netzke components
12
+ #
13
+ # @params *args
14
+ def self.helper_method(*args)
15
+ # We don't do anything since there is no view layer in netzke components
16
+ end
17
+
18
+ # Include the cancan controller additions
19
+ include ::CanCan::ControllerAdditions
20
+ end
21
+ end
@@ -0,0 +1 @@
1
+ require 'netzke/cancan'
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+ require 'netzke/core'
3
+
4
+ describe Netzke::CanCan do
5
+ before(:each) do
6
+ user = Object.new
7
+ stub(Netzke::Core).current_user{user}
8
+ @component = TestComponent.new
9
+ end
10
+
11
+ it "should respond to can?" do
12
+ @component.should respond_to(:can?)
13
+ end
14
+
15
+ it "should respond to cannot?" do
16
+ @component.should respond_to(:cannot?)
17
+ end
18
+
19
+ describe "#current_ability" do
20
+ it "should respond_to current_ability" do
21
+ @component.should respond_to(:current_ability)
22
+ end
23
+
24
+ it "should return instance of Ability" do
25
+ @component.current_ability.should be_a(Ability)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,25 @@
1
+ require 'rubygems'
2
+ require 'cancan'
3
+ require 'bundler/setup'
4
+
5
+ Bundler.require(:default)
6
+
7
+ require 'active_support/all'
8
+
9
+ RSpec.configure do |config|
10
+ config.treat_symbols_as_metadata_keys_with_true_values = true
11
+ config.filter_run :focus => true
12
+ config.run_all_when_everything_filtered = true
13
+ config.mock_with :rr
14
+ end
15
+
16
+ class Ability
17
+ include CanCan::Ability
18
+
19
+ def initialize(user)
20
+ end
21
+ end
22
+
23
+ class TestComponent < Netzke::Base
24
+
25
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: netzke-cancan
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Georg Meyer
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.6.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 2.6.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: rr
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.0.4
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.0.4
46
+ - !ruby/object:Gem::Dependency
47
+ name: cancan
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: netzke-core
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Includes cancan controller helpers in all netzke components.
79
+ email: georgmeyer83@googlemail.com
80
+ executables: []
81
+ extensions: []
82
+ extra_rdoc_files: []
83
+ files:
84
+ - lib/netzke/cancan.rb
85
+ - lib/netzke/cancan/version.rb
86
+ - lib/netzke_cancan.rb
87
+ - spec/netzke/cancan_spec.rb
88
+ - spec/spec_helper.rb
89
+ - README.rdoc
90
+ - LICENSE.txt
91
+ - Gemfile
92
+ - Rakefile
93
+ homepage: http://github.com/scho/netzke-cancan
94
+ licenses: []
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: 1.3.4
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 1.8.24
114
+ signing_key:
115
+ specification_version: 3
116
+ summary: Enables cancan in Netzke components
117
+ test_files: []