cantango-masquerade 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +39 -0
  4. data/Gemfile.lock +155 -0
  5. data/LICENSE.txt +20 -0
  6. data/README.mdown +95 -0
  7. data/Rakefile +49 -0
  8. data/VERSION +1 -0
  9. data/cantango-masquerade.gemspec +107 -0
  10. data/lib/cantango/masquerade.rb +14 -0
  11. data/lib/cantango/masquerade/ability.rb +1 -0
  12. data/lib/cantango/masquerade/ability/helper/masquerade.rb +29 -0
  13. data/lib/cantango/masquerade/api.rb +7 -0
  14. data/lib/cantango/masquerade/api/masquerade.rb +9 -0
  15. data/lib/cantango/masquerade/api/masquerade/account.rb +33 -0
  16. data/lib/cantango/masquerade/api/masquerade/user.rb +31 -0
  17. data/lib/cantango/masquerade/macros.rb +7 -0
  18. data/lib/cantango/masquerade/macros/masquerader.rb +7 -0
  19. data/lib/cantango/masquerade/macros/masquerader/account.rb +7 -0
  20. data/lib/cantango/masquerade/macros/masquerader/user.rb +7 -0
  21. data/lib/cantango/masquerade_ext.rb +5 -0
  22. data/lib/cantango/masquerade_ext/macros.rb +11 -0
  23. data/lib/cantango/masquerade_ext/macros/account.rb +13 -0
  24. data/lib/cantango/masquerade_ext/macros/user.rb +13 -0
  25. data/spec/cantango/ability/masquerade/helper_spec.rb +92 -0
  26. data/spec/cantango/api/masquerade/account_spec.rb +62 -0
  27. data/spec/cantango/api/masquerade/user_spec.rb +60 -0
  28. data/spec/cantango/macros/masquerade/account_spec.rb +44 -0
  29. data/spec/cantango/macros/masquerade/user_spec.rb +37 -0
  30. data/spec/cantango/masquerade_ext/macros/admin_account_spec.rb +41 -0
  31. data/spec/cantango/masquerade_ext/macros/admin_user_spec.rb +38 -0
  32. data/spec/cantango/masquerade_spec.rb +7 -0
  33. data/spec/fixtures/models.rb +2 -0
  34. data/spec/fixtures/models/admin.rb +2 -0
  35. data/spec/fixtures/models/admin_account.rb +22 -0
  36. data/spec/fixtures/models/items.rb +8 -0
  37. data/spec/fixtures/models/permission.rb +12 -0
  38. data/spec/fixtures/models/project.rb +2 -0
  39. data/spec/fixtures/models/simple_roles.rb +49 -0
  40. data/spec/fixtures/models/user.rb +52 -0
  41. data/spec/fixtures/models/user_account.rb +7 -0
  42. data/spec/helpers/current_user_accounts.rb +20 -0
  43. data/spec/helpers/current_users.rb +10 -0
  44. data/spec/spec_helper.rb +15 -0
  45. metadata +193 -0
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,39 @@
1
+ source :rubygems
2
+
3
+ group :default do
4
+ gem 'rails', '>= 3.1'
5
+ gem 'sugar-high', '~> 0.6.2'
6
+ gem 'sweetloader', '~> 0.1.6'
7
+ gem 'hashie', '~> 1.2'
8
+
9
+ gem 'cantango-core', '>= 0.1.9.1'
10
+ end
11
+
12
+ group :development do
13
+ gem "bundler", ">= 1.1.rc"
14
+ gem "jeweler", ">= 1.6.4"
15
+ gem "rcov", ">= 0"
16
+ end
17
+
18
+ group :test do
19
+ gem 'require_all', '~> 1.2.0'
20
+
21
+ gem 'cantango-config', '>= 0.1.8.1'
22
+ gem 'cantango-api'
23
+
24
+ gem 'forgery'
25
+ gem 'sqlite3'
26
+ # Data
27
+ gem 'database_cleaner'
28
+ gem 'factory_girl'
29
+
30
+ # Specs
31
+ gem 'spork'
32
+
33
+ # Debug and performance tests
34
+ gem 'cutter'
35
+ end
36
+
37
+ group :test, :development do
38
+ gem "rspec", ">= 2.6.0"
39
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,155 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionmailer (3.1.3)
5
+ actionpack (= 3.1.3)
6
+ mail (~> 2.3.0)
7
+ actionpack (3.1.3)
8
+ activemodel (= 3.1.3)
9
+ activesupport (= 3.1.3)
10
+ builder (~> 3.0.0)
11
+ erubis (~> 2.7.0)
12
+ i18n (~> 0.6)
13
+ rack (~> 1.3.5)
14
+ rack-cache (~> 1.1)
15
+ rack-mount (~> 0.8.2)
16
+ rack-test (~> 0.6.1)
17
+ sprockets (~> 2.0.3)
18
+ activemodel (3.1.3)
19
+ activesupport (= 3.1.3)
20
+ builder (~> 3.0.0)
21
+ i18n (~> 0.6)
22
+ activerecord (3.1.3)
23
+ activemodel (= 3.1.3)
24
+ activesupport (= 3.1.3)
25
+ arel (~> 2.2.1)
26
+ tzinfo (~> 0.3.29)
27
+ activeresource (3.1.3)
28
+ activemodel (= 3.1.3)
29
+ activesupport (= 3.1.3)
30
+ activesupport (3.1.3)
31
+ multi_json (~> 1.0)
32
+ arel (2.2.1)
33
+ builder (3.0.0)
34
+ cancan (1.6.7)
35
+ cantango-api (0.0.0)
36
+ cantango-config
37
+ hashie
38
+ rails (>= 3.1)
39
+ sugar-high (>= 0.6.0)
40
+ sweetloader (~> 0.1.0)
41
+ cantango-config (0.1.9.2)
42
+ cantango-core (~> 0.1.9)
43
+ hashie (~> 1.2)
44
+ rails (>= 3.1)
45
+ sugar-high (>= 0.6.1)
46
+ sweetloader (~> 0.1.6)
47
+ cantango-core (0.1.9.1)
48
+ cancan (>= 1.4)
49
+ hashie
50
+ rails (>= 3.0.1)
51
+ sugar-high (>= 0.6.0)
52
+ sweetloader (~> 0.1.5)
53
+ colorize (0.5.8)
54
+ cutter (0.8.2)
55
+ activesupport (>= 2.3.5)
56
+ colorize (>= 0.5)
57
+ database_cleaner (0.7.0)
58
+ diff-lcs (1.1.3)
59
+ erubis (2.7.0)
60
+ factory_girl (2.3.2)
61
+ activesupport
62
+ forgery (0.5.0)
63
+ git (1.2.5)
64
+ hashie (1.2.0)
65
+ hike (1.2.1)
66
+ i18n (0.6.0)
67
+ jeweler (1.6.4)
68
+ bundler (~> 1.0)
69
+ git (>= 1.2.5)
70
+ rake
71
+ json (1.6.3)
72
+ mail (2.3.0)
73
+ i18n (>= 0.4.0)
74
+ mime-types (~> 1.16)
75
+ treetop (~> 1.4.8)
76
+ mime-types (1.17.2)
77
+ multi_json (1.0.4)
78
+ polyglot (0.3.3)
79
+ rack (1.3.5)
80
+ rack-cache (1.1)
81
+ rack (>= 0.4)
82
+ rack-mount (0.8.3)
83
+ rack (>= 1.0.0)
84
+ rack-ssl (1.3.2)
85
+ rack
86
+ rack-test (0.6.1)
87
+ rack (>= 1.0)
88
+ rails (3.1.3)
89
+ actionmailer (= 3.1.3)
90
+ actionpack (= 3.1.3)
91
+ activerecord (= 3.1.3)
92
+ activeresource (= 3.1.3)
93
+ activesupport (= 3.1.3)
94
+ bundler (~> 1.0)
95
+ railties (= 3.1.3)
96
+ railties (3.1.3)
97
+ actionpack (= 3.1.3)
98
+ activesupport (= 3.1.3)
99
+ rack-ssl (~> 1.3.2)
100
+ rake (>= 0.8.7)
101
+ rdoc (~> 3.4)
102
+ thor (~> 0.14.6)
103
+ rake (0.9.2.2)
104
+ rcov (0.9.11)
105
+ rdoc (3.11)
106
+ json (~> 1.4)
107
+ require_all (1.2.0)
108
+ rspec (2.7.0)
109
+ rspec-core (~> 2.7.0)
110
+ rspec-expectations (~> 2.7.0)
111
+ rspec-mocks (~> 2.7.0)
112
+ rspec-core (2.7.1)
113
+ rspec-expectations (2.7.0)
114
+ diff-lcs (~> 1.1.2)
115
+ rspec-mocks (2.7.0)
116
+ spork (0.8.5)
117
+ sprockets (2.0.3)
118
+ hike (~> 1.2)
119
+ rack (~> 1.0)
120
+ tilt (~> 1.1, != 1.3.0)
121
+ sqlite3 (1.3.5)
122
+ sugar-high (0.6.2.1)
123
+ activesupport (>= 3.0.1)
124
+ sweetloader (0.1.6)
125
+ activesupport (>= 3.0.1)
126
+ i18n
127
+ thor (0.14.6)
128
+ tilt (1.3.3)
129
+ treetop (1.4.10)
130
+ polyglot
131
+ polyglot (>= 0.3.1)
132
+ tzinfo (0.3.31)
133
+
134
+ PLATFORMS
135
+ ruby
136
+
137
+ DEPENDENCIES
138
+ bundler (>= 1.1.rc)
139
+ cantango-api
140
+ cantango-config (>= 0.1.8.1)
141
+ cantango-core (>= 0.1.9.1)
142
+ cutter
143
+ database_cleaner
144
+ factory_girl
145
+ forgery
146
+ hashie (~> 1.2)
147
+ jeweler (>= 1.6.4)
148
+ rails (>= 3.1)
149
+ rcov
150
+ require_all (~> 1.2.0)
151
+ rspec (>= 2.6.0)
152
+ spork
153
+ sqlite3
154
+ sugar-high (~> 0.6.2)
155
+ sweetloader (~> 0.1.6)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Kristian Mandrup
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.mdown ADDED
@@ -0,0 +1,95 @@
1
+ # Cantango Masquerade
2
+
3
+ The Masquerade API for [CanTango](https://github.com/kristianmandrup/cantango)
4
+
5
+ ## Status: Dec 8 2011
6
+
7
+ Initial Gem created
8
+
9
+ ## Dependencies
10
+
11
+ This extension depends on the CanTango [core](https://github.com/kristianmandrup/cantango-core) and follows the extension conventions as described there.
12
+
13
+ ## Add-ons
14
+
15
+ * CanTango
16
+ * Ability
17
+ * Helper
18
+ * Masquerade
19
+ * Api
20
+ * Masquerade
21
+ * Account
22
+ * User
23
+ * Macros
24
+ * Masquerader
25
+ * Account
26
+ * User
27
+
28
+ ## Core extensions
29
+
30
+ * CanTango
31
+ * Macros
32
+ * Account
33
+ * User
34
+
35
+ These macros add the ability to specify usage of masquerade API using a :masquerade option (true or false)
36
+
37
+ ## Usage examples
38
+
39
+ Masquerader as User example:
40
+
41
+ ```ruby
42
+ class User
43
+ tango_user :masquerade
44
+ end
45
+
46
+ class Admin
47
+ tango_user :masquerade
48
+ end
49
+
50
+ mike = User.new 'mike'
51
+ admin = Admin.new 'admin'
52
+
53
+ admin.masquerade_as mike
54
+ admin.masquerade? # => true
55
+ # ...
56
+ admin.stop_masquerade
57
+ admin.masquerade? # => false
58
+ ```
59
+
60
+ Masquerade as Account example:
61
+
62
+ ````ruby
63
+ class UserAccount
64
+ tango_account :masquerade
65
+ end
66
+
67
+ class AdminAccount
68
+ tango_account :masquerade
69
+ end
70
+
71
+ mike_ac_ = UserAccount.new mike
72
+ admin_ac_ = Admin.new admin
73
+
74
+ admin_ac.masquerade_as mike_ac_
75
+ admin_ac.masquerade? # => true
76
+ # ...
77
+ admin_ac.stop_masquerade
78
+ admin_ac.masquerade? # => false
79
+ ```
80
+
81
+ ## Contributing to cantango-masquerade
82
+
83
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
84
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
85
+ * Fork the project
86
+ * Start a feature/bugfix branch
87
+ * Commit and push until you are happy with your contribution
88
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
89
+ * 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.
90
+
91
+ ## Copyright
92
+
93
+ Copyright (c) 2011 Kristian Mandrup. See LICENSE.txt for
94
+ further details.
95
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "cantango-masquerade"
18
+ gem.homepage = "http://github.com/kristianmandrup/cantango-masquerade"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Masquerade extension for CanTango}
21
+ gem.description = %Q{Masquerade extensions and macros for CanTango}
22
+ gem.email = "kmandrup@gmail.com"
23
+ gem.authors = ["Kristian Mandrup"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "cantango-masquerade #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
@@ -0,0 +1,107 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{cantango-masquerade}
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = [%q{Kristian Mandrup}]
12
+ s.date = %q{2011-12-08}
13
+ s.description = %q{Masquerade extensions and macros for CanTango}
14
+ s.email = %q{kmandrup@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.mdown"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.mdown",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "cantango-masquerade.gemspec",
29
+ "lib/cantango/masquerade.rb",
30
+ "lib/cantango/masquerade/ability.rb",
31
+ "lib/cantango/masquerade/ability/helper/masquerade.rb",
32
+ "lib/cantango/masquerade/api.rb",
33
+ "lib/cantango/masquerade/api/masquerade.rb",
34
+ "lib/cantango/masquerade/api/masquerade/account.rb",
35
+ "lib/cantango/masquerade/api/masquerade/user.rb",
36
+ "lib/cantango/masquerade/macros.rb",
37
+ "lib/cantango/masquerade/macros/masquerader.rb",
38
+ "lib/cantango/masquerade/macros/masquerader/account.rb",
39
+ "lib/cantango/masquerade/macros/masquerader/user.rb",
40
+ "lib/cantango/masquerade_ext.rb",
41
+ "lib/cantango/masquerade_ext/macros.rb",
42
+ "lib/cantango/masquerade_ext/macros/account.rb",
43
+ "lib/cantango/masquerade_ext/macros/user.rb",
44
+ "spec/cantango/ability/masquerade/helper_spec.rb",
45
+ "spec/cantango/api/masquerade/account_spec.rb",
46
+ "spec/cantango/api/masquerade/user_spec.rb",
47
+ "spec/cantango/macros/masquerade/account_spec.rb",
48
+ "spec/cantango/macros/masquerade/user_spec.rb",
49
+ "spec/cantango/masquerade_ext/macros/admin_account_spec.rb",
50
+ "spec/cantango/masquerade_ext/macros/admin_user_spec.rb",
51
+ "spec/cantango/masquerade_spec.rb",
52
+ "spec/fixtures/models.rb",
53
+ "spec/fixtures/models/admin.rb",
54
+ "spec/fixtures/models/admin_account.rb",
55
+ "spec/fixtures/models/items.rb",
56
+ "spec/fixtures/models/permission.rb",
57
+ "spec/fixtures/models/project.rb",
58
+ "spec/fixtures/models/simple_roles.rb",
59
+ "spec/fixtures/models/user.rb",
60
+ "spec/fixtures/models/user_account.rb",
61
+ "spec/helpers/current_user_accounts.rb",
62
+ "spec/helpers/current_users.rb",
63
+ "spec/spec_helper.rb"
64
+ ]
65
+ s.homepage = %q{http://github.com/kristianmandrup/cantango-masquerade}
66
+ s.licenses = [%q{MIT}]
67
+ s.require_paths = [%q{lib}]
68
+ s.rubygems_version = %q{1.8.6}
69
+ s.summary = %q{Masquerade extension for CanTango}
70
+
71
+ if s.respond_to? :specification_version then
72
+ s.specification_version = 3
73
+
74
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
75
+ s.add_runtime_dependency(%q<rails>, [">= 3.1"])
76
+ s.add_runtime_dependency(%q<sugar-high>, ["~> 0.6.2"])
77
+ s.add_runtime_dependency(%q<sweetloader>, ["~> 0.1.6"])
78
+ s.add_runtime_dependency(%q<hashie>, ["~> 1.2"])
79
+ s.add_runtime_dependency(%q<cantango-core>, [">= 0.1.9.1"])
80
+ s.add_development_dependency(%q<bundler>, [">= 1.1.rc"])
81
+ s.add_development_dependency(%q<jeweler>, [">= 1.6.4"])
82
+ s.add_development_dependency(%q<rcov>, [">= 0"])
83
+ s.add_development_dependency(%q<rspec>, [">= 2.6.0"])
84
+ else
85
+ s.add_dependency(%q<rails>, [">= 3.1"])
86
+ s.add_dependency(%q<sugar-high>, ["~> 0.6.2"])
87
+ s.add_dependency(%q<sweetloader>, ["~> 0.1.6"])
88
+ s.add_dependency(%q<hashie>, ["~> 1.2"])
89
+ s.add_dependency(%q<cantango-core>, [">= 0.1.9.1"])
90
+ s.add_dependency(%q<bundler>, [">= 1.1.rc"])
91
+ s.add_dependency(%q<jeweler>, [">= 1.6.4"])
92
+ s.add_dependency(%q<rcov>, [">= 0"])
93
+ s.add_dependency(%q<rspec>, [">= 2.6.0"])
94
+ end
95
+ else
96
+ s.add_dependency(%q<rails>, [">= 3.1"])
97
+ s.add_dependency(%q<sugar-high>, ["~> 0.6.2"])
98
+ s.add_dependency(%q<sweetloader>, ["~> 0.1.6"])
99
+ s.add_dependency(%q<hashie>, ["~> 1.2"])
100
+ s.add_dependency(%q<cantango-core>, [">= 0.1.9.1"])
101
+ s.add_dependency(%q<bundler>, [">= 1.1.rc"])
102
+ s.add_dependency(%q<jeweler>, [">= 1.6.4"])
103
+ s.add_dependency(%q<rcov>, [">= 0"])
104
+ s.add_dependency(%q<rspec>, [">= 2.6.0"])
105
+ end
106
+ end
107
+