session-hack-rails2-rails3 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.
- data/LICENSE.txt +20 -0
- data/README.md +36 -0
- data/README.rdoc +39 -0
- data/lib/rails2_to_3_flash_serialization.rb +12 -0
- data/lib/rails3_to_2_flash_serialization.rb +37 -0
- metadata +131 -0
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 MC Pair 1
|
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.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
session-hack-rails2-rails3
|
2
|
+
==========================
|
3
|
+
|
4
|
+
Hackery to get Rails 2 and 3 to share a common session in the browser.
|
5
|
+
Rails 2 and 3 both put FlashHash in the session but have different APIs and cannot de-serialize sessions from the other version.
|
6
|
+
|
7
|
+
Installation
|
8
|
+
============
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
<p><code>gem 'session-hack-rails2-rails3'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
<p><code> $ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
<p><code> $ gem install 'session-hack-rails2-rails3'
|
17
|
+
|
18
|
+
Usage
|
19
|
+
=====
|
20
|
+
In your rails3 app, add the following in the config/initializers/session_store.rb
|
21
|
+
<p><code>require 'rails2_to_3_flash_serialization'
|
22
|
+
|
23
|
+
In your rails2 app, add the following in the config/initializers/session_store.rb
|
24
|
+
<p><code>require 'rails3_to_2_flash_serialization'
|
25
|
+
|
26
|
+
That's all! You should be able to share session object between your rails2 and rails3 apps.
|
27
|
+
|
28
|
+
Contributing to session-hack-rails2-rails3
|
29
|
+
==========================================
|
30
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
31
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
32
|
+
* Fork the project.
|
33
|
+
* Start a feature/bugfix branch.
|
34
|
+
* Commit and push until you are happy with your contribution.
|
35
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
36
|
+
* 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.
|
data/README.rdoc
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
= session-hack-rails2-rails3
|
2
|
+
|
3
|
+
Hackery to get Rails 2 to share a common session in the browser with Rails 3
|
4
|
+
Rails 2 and 3 both put FlashHash in the session but have different APIs and cannot de-serialize sessions from the other version.
|
5
|
+
|
6
|
+
= Installation
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
* gem 'session-hack-rails2-rails3'
|
9
|
+
|
10
|
+
And then execute:
|
11
|
+
* $ bundle
|
12
|
+
|
13
|
+
Or install it yourself as:
|
14
|
+
* $ gem install 'session-hack-rails2-rails3'
|
15
|
+
|
16
|
+
= Usage
|
17
|
+
In your rails3 app, add the following in the config/initializers/session_store.rb
|
18
|
+
* require 'rails2_to_3_flash_serialization'
|
19
|
+
|
20
|
+
In your rails2 app, add the following in the config/initializers/session_store.rb
|
21
|
+
* require 'rails3_to_2_flash_serialization'
|
22
|
+
|
23
|
+
That's all! You should be able to share session object between your rails2 and rails3 apps.
|
24
|
+
|
25
|
+
== Contributing to session-hack-rails2-rails3
|
26
|
+
|
27
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
28
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
29
|
+
* Fork the project.
|
30
|
+
* Start a feature/bugfix branch.
|
31
|
+
* Commit and push until you are happy with your contribution.
|
32
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
33
|
+
* 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.
|
34
|
+
|
35
|
+
== Copyright
|
36
|
+
|
37
|
+
Copyright (c) 2012 MC Pair 1. See LICENSE.txt for
|
38
|
+
further details.
|
39
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Hackery to get Rails 3 to share a common session in the browser with Rails 2
|
2
|
+
# Rails 2 and 3 both put FlashHash in the session but have different APIs and cannot de-serialize sessions from the other version.
|
3
|
+
|
4
|
+
# Provide empty stub of Rails2 FlashHash so Rails3 can de-serialize the session in the browser
|
5
|
+
module ActionController
|
6
|
+
module Flash
|
7
|
+
class FlashHash < Hash
|
8
|
+
def method_missing(m, *a, &b)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Hackery to get Rails 2 to share a common session in the browser with Rails 3
|
2
|
+
# Rails 2 and 3 both put FlashHash in the session but have different APIs and cannot de-serialize sessions from the other version.
|
3
|
+
|
4
|
+
# Provide empty stub of Rails3 FlashHash so Rails2 can de-serialize the session in the browser
|
5
|
+
module ActionDispatch
|
6
|
+
class Flash
|
7
|
+
class FlashHash
|
8
|
+
def method_missing(m, *a, &b)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# Provide Rails2 with its own namespace for flash messages in the session to prevent name collisions with Rails3
|
15
|
+
module ActionController
|
16
|
+
module Flash
|
17
|
+
class FlashHash < Hash
|
18
|
+
def store(session, key = "legacy_flash")
|
19
|
+
return if self.empty?
|
20
|
+
session[key] = self
|
21
|
+
end
|
22
|
+
end
|
23
|
+
module InstanceMethods
|
24
|
+
# Access the contents of the flash. Use <tt>flash["notice"]</tt> to
|
25
|
+
# read a notice you put there or <tt>flash["notice"] = "hello"</tt>
|
26
|
+
# to put a new one.
|
27
|
+
def flash #:doc:
|
28
|
+
if !defined?(@_flash)
|
29
|
+
@_flash = session["legacy_flash"] || FlashHash.new
|
30
|
+
@_flash.sweep
|
31
|
+
end
|
32
|
+
|
33
|
+
@_flash
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: session-hack-rails2-rails3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- mc-deploy
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-07-12 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
hash: 31
|
27
|
+
segments:
|
28
|
+
- 3
|
29
|
+
- 12
|
30
|
+
version: "3.12"
|
31
|
+
version_requirements: *id001
|
32
|
+
name: rdoc
|
33
|
+
prerelease: false
|
34
|
+
type: :development
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
hash: 23
|
42
|
+
segments:
|
43
|
+
- 1
|
44
|
+
- 0
|
45
|
+
- 0
|
46
|
+
version: 1.0.0
|
47
|
+
version_requirements: *id002
|
48
|
+
name: bundler
|
49
|
+
prerelease: false
|
50
|
+
type: :development
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ~>
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 63
|
58
|
+
segments:
|
59
|
+
- 1
|
60
|
+
- 8
|
61
|
+
- 4
|
62
|
+
version: 1.8.4
|
63
|
+
version_requirements: *id003
|
64
|
+
name: jeweler
|
65
|
+
prerelease: false
|
66
|
+
type: :development
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
version: "0"
|
77
|
+
version_requirements: *id004
|
78
|
+
name: rcov
|
79
|
+
prerelease: false
|
80
|
+
type: :development
|
81
|
+
description: "Hackery to get Rails 2 and 3 to share a common session in the browser. "
|
82
|
+
email: dev+gems@mobilecause.com
|
83
|
+
executables: []
|
84
|
+
|
85
|
+
extensions: []
|
86
|
+
|
87
|
+
extra_rdoc_files:
|
88
|
+
- LICENSE.txt
|
89
|
+
- README.md
|
90
|
+
- README.rdoc
|
91
|
+
files:
|
92
|
+
- lib/rails2_to_3_flash_serialization.rb
|
93
|
+
- lib/rails3_to_2_flash_serialization.rb
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- README.rdoc
|
97
|
+
homepage: http://github.com/mobilecause/session-hack-rails2-rails3
|
98
|
+
licenses:
|
99
|
+
- MIT
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
hash: 3
|
111
|
+
segments:
|
112
|
+
- 0
|
113
|
+
version: "0"
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
hash: 3
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
version: "0"
|
123
|
+
requirements: []
|
124
|
+
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 1.8.15
|
127
|
+
signing_key:
|
128
|
+
specification_version: 3
|
129
|
+
summary: Share browser session object between Rails2 and Rails3 apps
|
130
|
+
test_files: []
|
131
|
+
|