liangzan-intercession 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +15 -0
- data/Manifest.txt +7 -0
- data/README.rdoc +76 -0
- data/Rakefile +12 -0
- data/install.rb +11 -0
- data/lib/intercession.rb +21 -0
- data/session.template +23 -0
- metadata +97 -0
data/CHANGELOG.rdoc
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
=== 3.0.0 / 2011-01-27
|
2
|
+
* Rails 3.0.3 compatible
|
3
|
+
* Usage and installation is backward compatible
|
4
|
+
|
5
|
+
=== 2.0.0 / 2009-09-28
|
6
|
+
|
7
|
+
* Different approach. Supports Rails v2.2.2 and v2.3.4.
|
8
|
+
* Rails 2.3 compatibility. [W. Andrew Loe III]
|
9
|
+
* Switch to standard Hoe structure.
|
10
|
+
* Standardizing the Rakefile.
|
11
|
+
* Clean up example gist link.
|
12
|
+
|
13
|
+
=== 1.0.0 / 2009-02-24
|
14
|
+
|
15
|
+
* Birthday!
|
data/Manifest.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
= Intercession
|
2
|
+
|
3
|
+
* http://github.com/jbarnette/intercession
|
4
|
+
|
5
|
+
== Description
|
6
|
+
|
7
|
+
This fork is Rails 3.0.3 compatible
|
8
|
+
|
9
|
+
Treat your sessions like models, not hashes. Intercession mixes a module into
|
10
|
+
the session on each request, allowing you to nicely encapsulate (and test!)
|
11
|
+
lots of user and session-specific behavior.
|
12
|
+
|
13
|
+
== Examples
|
14
|
+
|
15
|
+
Check out this gist: http://gist.github.com/44506
|
16
|
+
|
17
|
+
Unit tests for your session model! Mix it in to a Hash and go to town:
|
18
|
+
|
19
|
+
def setup
|
20
|
+
@session = Hash.new
|
21
|
+
@session.extend Transient::Session
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_session_user_lazily_loads_from_user_id
|
25
|
+
assert_nil @session.user
|
26
|
+
@session[:user_id] = users(:default).id
|
27
|
+
assert_equal users(:default), @session.user
|
28
|
+
end
|
29
|
+
|
30
|
+
== Installation
|
31
|
+
|
32
|
+
I've used Intercession with Rails v2.2.2 and v2.3.4. Anything else
|
33
|
+
might give you hives.
|
34
|
+
|
35
|
+
Intercession works as a plugin or a gem. If you install it as a
|
36
|
+
plugin, it'll create you a stub session module in
|
37
|
+
<tt>app/models/transient/session.rb</tt>. If you're using it as a gem,
|
38
|
+
do it yourself. :)
|
39
|
+
|
40
|
+
As a plugin:
|
41
|
+
|
42
|
+
$ script/plugin install git://github.com/jbarnette/intercession.git
|
43
|
+
|
44
|
+
As a gem (preferred):
|
45
|
+
|
46
|
+
$ gem install intercession
|
47
|
+
|
48
|
+
If you're using Intercession as a gem, add it to your app's gem
|
49
|
+
dependency mechanism.
|
50
|
+
|
51
|
+
After installation, add <tt>include Intercession</tt> to your
|
52
|
+
ApplicationController. To enable Intercession in your tests, call
|
53
|
+
<tt>Intercession.test!</tt> in your <tt>test_helper.rb</tt>.
|
54
|
+
|
55
|
+
== License
|
56
|
+
|
57
|
+
Copyright 2009 John Barnette (jbarnette@rubyforge.org)
|
58
|
+
|
59
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
60
|
+
a copy of this software and associated documentation files (the
|
61
|
+
'Software'), to deal in the Software without restriction, including
|
62
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
63
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
64
|
+
permit persons to whom the Software is furnished to do so, subject to
|
65
|
+
the following conditions:
|
66
|
+
|
67
|
+
The above copyright notice and this permission notice shall be
|
68
|
+
included in all copies or substantial portions of the Software.
|
69
|
+
|
70
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
71
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
72
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
73
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
74
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
75
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
76
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "hoe"
|
3
|
+
|
4
|
+
Hoe.plugin :doofus, :git
|
5
|
+
|
6
|
+
Hoe.spec "liangzan-intercession" do
|
7
|
+
developer "John Barnette", "jbarnette@rubyforge.org"
|
8
|
+
|
9
|
+
self.extra_rdoc_files = FileList["*.rdoc"]
|
10
|
+
self.history_file = "CHANGELOG.rdoc"
|
11
|
+
self.readme_file = "README.rdoc"
|
12
|
+
end
|
data/install.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
source = File.join File.dirname(__FILE__), "session.template"
|
2
|
+
relative = File.join "app", "models", "transient", "session.rb"
|
3
|
+
destination = File.join Rails.root, relative
|
4
|
+
|
5
|
+
if File.exist? destination
|
6
|
+
puts "#{relative} already exists, so I won't overwrite it."
|
7
|
+
else
|
8
|
+
FileUtils.mkdir_p File.dirname(destination)
|
9
|
+
FileUtils.cp source, destination
|
10
|
+
puts "Installed an empty session module in #{destination}. Go edit it!"
|
11
|
+
end
|
data/lib/intercession.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Intercession
|
2
|
+
# Duh.
|
3
|
+
VERSION = "3.0.0"
|
4
|
+
|
5
|
+
def self.included klass
|
6
|
+
klass.append_after_filter :intercede_after
|
7
|
+
|
8
|
+
ks = []
|
9
|
+
ks << ActionDispatch::Session::AbstractStore::SessionHash rescue nil
|
10
|
+
ks.compact.each { |c| c.send :include, Transient::Session }
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.test!
|
14
|
+
ActionController::TestSession.send :include, Transient::Session
|
15
|
+
end
|
16
|
+
|
17
|
+
def intercede_after
|
18
|
+
# FIX: this obviously won't work with after filters in subclasses.
|
19
|
+
session.before_save if session.respond_to? :before_save
|
20
|
+
end
|
21
|
+
end
|
data/session.template
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Transient
|
2
|
+
|
3
|
+
# This module gets mixed in to the Rails session, and lets you
|
4
|
+
# treat the session more like a real object. Note that while most things
|
5
|
+
# this module is mixed in to are Hashlike, they vary in capabilitites.
|
6
|
+
# Safest to assume that the index[] op is the only thing that's available.
|
7
|
+
|
8
|
+
module Session
|
9
|
+
attr_accessor :controller, :request, :response
|
10
|
+
|
11
|
+
# Called by a before_filter in the application controller. A good place
|
12
|
+
# to eagerly populate member models from IDs, if you're not feeling lazy.
|
13
|
+
|
14
|
+
def after_initialize
|
15
|
+
end
|
16
|
+
|
17
|
+
# Called by an after_filter in the application controller. A good
|
18
|
+
# opportunity to turn heavy lists of stuff into IDs, etc.
|
19
|
+
|
20
|
+
def before_save
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: liangzan-intercession
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 7
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 3.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- John Barnette
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-01-27 00:00:00 +08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: hoe
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 47
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 8
|
33
|
+
- 0
|
34
|
+
version: 2.8.0
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
description: |-
|
38
|
+
This fork is Rails 3.0.3 compatible
|
39
|
+
|
40
|
+
Treat your sessions like models, not hashes. Intercession mixes a module into
|
41
|
+
the session on each request, allowing you to nicely encapsulate (and test!)
|
42
|
+
lots of user and session-specific behavior.
|
43
|
+
email:
|
44
|
+
- jbarnette@rubyforge.org
|
45
|
+
executables: []
|
46
|
+
|
47
|
+
extensions: []
|
48
|
+
|
49
|
+
extra_rdoc_files:
|
50
|
+
- Manifest.txt
|
51
|
+
- CHANGELOG.rdoc
|
52
|
+
- README.rdoc
|
53
|
+
files:
|
54
|
+
- CHANGELOG.rdoc
|
55
|
+
- Manifest.txt
|
56
|
+
- README.rdoc
|
57
|
+
- Rakefile
|
58
|
+
- install.rb
|
59
|
+
- lib/intercession.rb
|
60
|
+
- session.template
|
61
|
+
has_rdoc: true
|
62
|
+
homepage: http://github.com/jbarnette/intercession
|
63
|
+
licenses: []
|
64
|
+
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options:
|
67
|
+
- --main
|
68
|
+
- README.rdoc
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 3
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
version: "0"
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
|
+
requirements: []
|
90
|
+
|
91
|
+
rubyforge_project: liangzan-intercession
|
92
|
+
rubygems_version: 1.4.2
|
93
|
+
signing_key:
|
94
|
+
specification_version: 3
|
95
|
+
summary: This fork is Rails 3.0.3 compatible Treat your sessions like models, not hashes
|
96
|
+
test_files: []
|
97
|
+
|