cancan-sugar 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 94821b5d3984ab473055236ec9564694ab020a9c
4
+ data.tar.gz: c284e63d9b729ba91e82b70d96dc9fa0ffee1a52
5
+ SHA512:
6
+ metadata.gz: 26c0dc0430b3fd853c2a6777b9e803d8749adebd2d283f1bb7cdc552817d73e726e64fb7902f4c6dd8e6b5997517265158f36f6ba63dd6e8cbebc0452ff3d24c
7
+ data.tar.gz: d54049d21d58e81f438e6c20db8469dc42bb7d52e5fbec7f04fa9051a6c337653c1b2ed30c0d918db357127699b10e4b069adf7196dbbc618018bb4b806ac2a4
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ Gemfile.lock
2
+ .project
3
+ .idea
4
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'rake'
6
+ gem 'cancan'
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ CanCanSugar
2
+ ============
3
+
4
+ Syntax sugar for gem CanCan. Inspired by gem Padrino-CanCan.
5
+
6
+
7
+ # Installation
8
+
9
+ $ gem install cancan-sugar
10
+
11
+
12
+ # Usage
13
+
14
+ gem "cancan-sugar"
15
+
16
+
17
+ # Result
18
+
19
+
20
+
21
+ # License
22
+
23
+ (C)opyLeft & (C)odeRight Alexey Kolosov aka mr.huNTer <alexey.kolosov@gmail.com>
24
+
25
+ "Typographica" released without warranty under the terms of the Artistic License 2.0
26
+ http://www.opensource.org/licenses/artistic-license-2.0
27
+
28
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'rubygems'
2
+
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # CanCanSugar v0.1.0
4
+ #
5
+ # Syntax sugar for gem CanCan. Inspired by gem Padrino-CanCan.
6
+ #
7
+ # (C)opyLeft & (C)odeRight Alexey Kolosov aka mr.huNTer <alexey.kolosov@gmail.com>
8
+ #
9
+ # "CanCanSugar" released without warranty under the terms of the Artistic License 2.0
10
+ # http://www.opensource.org/licenses/artistic-license-2.0
11
+ #
12
+
13
+ $:.push File.expand_path("../lib", __FILE__)
14
+
15
+ require "cancan-sugar/version"
16
+
17
+ Gem::Specification.new do |s|
18
+ s.name = %q{cancan-sugar}
19
+ s.version = CanCanSugar::VERSION::STRING
20
+ s.platform = Gem::Platform::RUBY
21
+ s.summary = %q{Syntax sugar for gem CanCan. Inspired by gem Padrino-CanCan.}
22
+ s.email = %q{alexey.kolosov@gmail.com}
23
+ s.homepage = %q{http://github.com/akolosov/cancan-sugar}
24
+ s.description = %q{Syntax sugar for gem CanCan. Inspired by gem Padrino-CanCan.}
25
+ s.authors = ['Alexey Kolosov']
26
+
27
+ s.files = `git ls-files`.split("\n")
28
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
29
+ s.require_paths = ["lib"]
30
+
31
+ s.add_development_dependency('cancan')
32
+ s.add_development_dependency('rake')
33
+ end
@@ -0,0 +1,42 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # CanCanSugar v0.1.0
4
+ #
5
+ # Syntax sugar for gem CanCan. Inspired by gem Padrino-CanCan.
6
+ #
7
+ # (C)opyLeft & (C)odeRight Alexey Kolosov aka mr.huNTer <alexey.kolosov@gmail.com>
8
+ #
9
+ # "CanCanSugar" released without warranty under the terms of the Artistic License 2.0
10
+ # http://www.opensource.org/licenses/artistic-license-2.0
11
+ #
12
+
13
+ module CanCan
14
+ module Ability
15
+
16
+ def permissions_for user, roles, &block
17
+ if roles.is_a? Array
18
+ roles.each do |role|
19
+ set_premissions user, role, &block
20
+ end
21
+ elsif roles.is_a? Hash
22
+ if roles[:as].is_a? Array
23
+ roles[:as].each do |role|
24
+ set_premissions user, role, &block
25
+ end
26
+ else
27
+ set_premissions user, roles[:as], &block
28
+ end
29
+ else
30
+ set_premissions user, roles, &block
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def set_premissions user, role, &block
37
+ block.call if user.has_role? role
38
+ end
39
+
40
+ end
41
+
42
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # CanCanSugar v0.1.0
4
+ #
5
+ # Syntax sugar for gem CanCan. Inspired by gem Padrino-CanCan.
6
+ #
7
+ # (C)opyLeft & (C)odeRight Alexey Kolosov aka mr.huNTer <alexey.kolosov@gmail.com>
8
+ #
9
+ # "CanCanSugar" released without warranty under the terms of the Artistic License 2.0
10
+ # http://www.opensource.org/licenses/artistic-license-2.0
11
+ #
12
+
13
+ module CanCanSugar
14
+ module VERSION
15
+ MAJOR = 0
16
+ MINOR = 1
17
+ PATCH = 0
18
+
19
+ STRING = [MAJOR, MINOR, PATCH].join('.')
20
+ end
21
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # CanCanSugar v0.1.0
4
+ #
5
+ # Syntax sugar for gem CanCan. Inspired by gem Padrino-CanCan.
6
+ #
7
+ # (C)opyLeft & (C)odeRight Alexey Kolosov aka mr.huNTer <alexey.kolosov@gmail.com>
8
+ #
9
+ # "CanCanSugar" released without warranty under the terms of the Artistic License 2.0
10
+ # http://www.opensource.org/licenses/artistic-license-2.0
11
+ #
12
+
13
+ module CanCanSugar
14
+ require "cancan-sugar/version"
15
+ require "cancan-sugar/cancan-sugar"
16
+ end
17
+
18
+ module CanCan
19
+ module Ability
20
+ class << self
21
+ include ::CanCan::Ability
22
+ end
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cancan-sugar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexey Kolosov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cancan
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Syntax sugar for gem CanCan. Inspired by gem Padrino-CanCan.
42
+ email: alexey.kolosov@gmail.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - .gitignore
48
+ - Gemfile
49
+ - README.md
50
+ - Rakefile
51
+ - cancan-sugar.gemspec
52
+ - lib/cancan-sugar.rb
53
+ - lib/cancan-sugar/cancan-sugar.rb
54
+ - lib/cancan-sugar/version.rb
55
+ homepage: http://github.com/akolosov/cancan-sugar
56
+ licenses: []
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 2.0.5
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Syntax sugar for gem CanCan. Inspired by gem Padrino-CanCan.
78
+ test_files: []