pretender 0.0.1 → 0.0.2
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.
- data/README.md +6 -5
- data/lib/pretender.rb +3 -2
- data/lib/pretender/version.rb +1 -1
- data/pretender.gemspec +3 -3
- metadata +12 -7
data/README.md
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
# Pretender
|
2
2
|
|
3
|
-
As an admin, there are times you want to see exactly what another user sees or take action on behalf of a user. Pretender
|
4
|
-
|
5
|
-
What is the right way?
|
3
|
+
As an admin, there are times you want to see exactly what another user sees or take action on behalf of a user. Meet Pretender.
|
6
4
|
|
7
5
|
- Easy to switch back and forth between roles
|
8
6
|
- Minimal code changes
|
9
|
-
- Plays nicely with auditing tools
|
7
|
+
- Plays nicely with auditing tools - **this is crucial**
|
10
8
|
|
11
9
|
[Rock on](http://www.youtube.com/watch?v=SBjQ9tuuTJQ) :boom:
|
12
10
|
|
13
11
|
Pretender is also flexible and lightweight - less than 40 lines of code :-)
|
14
12
|
|
15
|
-
Pretender works with Rails 2.3 and
|
13
|
+
Pretender works with Rails 2.3+ and almost any authentication system.
|
14
|
+
(devise, authlogic, sorcery, and many more - it's agnostic)
|
15
|
+
|
16
|
+
[Battle-tested at Instacart](https://www.instacart.com)
|
16
17
|
|
17
18
|
## Get started
|
18
19
|
|
data/lib/pretender.rb
CHANGED
@@ -14,9 +14,10 @@ module Pretender
|
|
14
14
|
helper_method true_method
|
15
15
|
|
16
16
|
define_method impersonated_method do
|
17
|
-
# only try to fetch impersonation if impersonation_id exists
|
18
17
|
if !instance_variable_get(impersonated_var)
|
19
|
-
|
18
|
+
# only fetch impersonation if user is logged in and impersonation_id exists
|
19
|
+
true_resource = send(true_method)
|
20
|
+
value = (true_resource && session[session_key] && impersonate_with.call(session[session_key])) || true_resource
|
20
21
|
instance_variable_set(impersonated_var, value) if value
|
21
22
|
end
|
22
23
|
instance_variable_get(impersonated_var)
|
data/lib/pretender/version.rb
CHANGED
data/pretender.gemspec
CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Pretender::VERSION
|
9
9
|
spec.authors = ["Andrew Kane"]
|
10
10
|
spec.email = ["acekane1@gmail.com"]
|
11
|
-
spec.description = %q{
|
12
|
-
spec.summary = %q{
|
13
|
-
spec.homepage = "
|
11
|
+
spec.description = %q{Simple, powerful user impersonation for Rails}
|
12
|
+
spec.summary = %q{Easy to switch back and forth between roles, minimal code changes, and plays nicely with auditing tools}
|
13
|
+
spec.homepage = "http://ankane.github.com/pretender/"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pretender
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
-
description:
|
46
|
+
description: Simple, powerful user impersonation for Rails
|
47
47
|
email:
|
48
48
|
- acekane1@gmail.com
|
49
49
|
executables: []
|
@@ -58,7 +58,7 @@ files:
|
|
58
58
|
- lib/pretender.rb
|
59
59
|
- lib/pretender/version.rb
|
60
60
|
- pretender.gemspec
|
61
|
-
homepage:
|
61
|
+
homepage: http://ankane.github.com/pretender/
|
62
62
|
licenses:
|
63
63
|
- MIT
|
64
64
|
post_install_message:
|
@@ -71,18 +71,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
71
|
- - ! '>='
|
72
72
|
- !ruby/object:Gem::Version
|
73
73
|
version: '0'
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
hash: -122711431740665312
|
74
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
78
|
none: false
|
76
79
|
requirements:
|
77
80
|
- - ! '>='
|
78
81
|
- !ruby/object:Gem::Version
|
79
82
|
version: '0'
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
hash: -122711431740665312
|
80
86
|
requirements: []
|
81
87
|
rubyforge_project:
|
82
88
|
rubygems_version: 1.8.23
|
83
89
|
signing_key:
|
84
90
|
specification_version: 3
|
85
|
-
summary:
|
86
|
-
|
91
|
+
summary: Easy to switch back and forth between roles, minimal code changes, and plays
|
92
|
+
nicely with auditing tools
|
87
93
|
test_files: []
|
88
|
-
has_rdoc:
|