memflash 1.0.1 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3e406b04c7b307c66848e8b98bb2e852fe1eaeaf
4
+ data.tar.gz: 78b8332bf373aaf4af970de9e3f0867deeeb5086
5
+ SHA512:
6
+ metadata.gz: 57d925d7ae63392a65d1198c9c7dcbbd11d79f160b66f554a39c794f3c6d74d92fbadfd8320a4240645e8103d283fa45a81afe589764e9c0cd3739e96b7f59f1
7
+ data.tar.gz: 513b4b7c3532f300b7d92a753bd95e0df42a0e51397730a5cff310d3785606bc80387f8feef1c0c2f70bc705299e7daab30f19e77a16ef737cbeaa28fdf007af
data/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
data/README.md ADDED
@@ -0,0 +1,62 @@
1
+ ## Memflash [![Build Status](https://secure.travis-ci.org/zendesk/memflash.png)](http://travis-ci.org/zendesk/memflash)
2
+
3
+ Memflash is a gem which enables storing really long values in the Rails FlashHash
4
+ without writing them to the session. Instead, it transparently uses `Rails.cache`, thus
5
+ enabling the flash in your actions to contain large values, and still fit in a cookie-based
6
+ session store.
7
+
8
+ ## How do I use it?
9
+
10
+ Memflash is completely transparent -- requiring the gem automatically enhances FlashHash
11
+ with caching-enabled reads and writes.
12
+
13
+ By default, any message that is over 300 characters long, will be saved in Rails.cache,
14
+ and a pointer to it stored in the flash. You can change this anywhere in your app by:
15
+
16
+ ```ruby
17
+ Memflash.threshold = #{length-at-which-writing-to-the-cache-is-trigerred}
18
+ ```
19
+
20
+ ## How does it work?
21
+
22
+ Memflash ties into the `[]` and `[]=` methods of Rails's FlashHash. On writes, if the value
23
+ being written has a length over Memflash.threshold, Memflash generates a pseudo-random
24
+ key for it, writes the pseudo-random key and original value to `Rails.cache`, and stores
25
+ the original key and pseudo-random key in the flash. Conceptually, when you write
26
+ `flash[:error] = "some message"`, this is equivalent to:
27
+
28
+ ```ruby
29
+ if "some message".length >= Memflash.threshold
30
+ # generate a psedudo-random key, memflash_key
31
+ # write memflash_key, "some message" to Rails.cache
32
+ # write :error, memflash_key to the flash
33
+ else
34
+ # write :error, "some message" to the flash, as usual
35
+ end
36
+ ```
37
+
38
+ On the flip side, reading from the flash, `flash[:error]` is conceptually equivalent to:
39
+
40
+ ```ruby
41
+ if the value for :error stored in the flash is a memflash key
42
+ # read the original (large) value from Rails.cache
43
+ # return the original (large) value
44
+ else
45
+ # return the value stored in the flash, as usual
46
+ end
47
+ ```
48
+
49
+ ## Author
50
+
51
+ Authored by [Vladimir Andrijevik](mailto:vladimir@zendesk.com)
52
+
53
+ ## Copyright and license
54
+
55
+ Copyright 2013 Zendesk
56
+
57
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
58
+ You may obtain a copy of the License at
59
+
60
+ http://www.apache.org/licenses/LICENSE-2.0
61
+
62
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
metadata CHANGED
@@ -1,38 +1,119 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memflash
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
4
+ version: 2.0.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Vladimir Andrijevik
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-07-10 00:00:00.000000000 Z
11
+ date: 2014-12-18 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: actionpack
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: 2.3.6
22
- - - <
19
+ version: 3.2.15
20
+ - - "<"
23
21
  - !ruby/object:Gem::Version
24
- version: '3.3'
22
+ version: '4.2'
25
23
  type: :runtime
26
24
  prerelease: false
27
25
  version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
26
  requirements:
30
- - - ! '>='
27
+ - - ">="
31
28
  - !ruby/object:Gem::Version
32
- version: 2.3.6
33
- - - <
29
+ version: 3.2.15
30
+ - - "<"
34
31
  - !ruby/object:Gem::Version
35
- version: '3.3'
32
+ version: '4.2'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rake
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: minitest
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: minitest-rg
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: wwtd
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: bump
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: mocha
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
36
117
  description: Memflash is a gem which enables storing really long values in the Rails
37
118
  FlashHash without writing them to the session. Instead, it transparently uses `Rails.cache`,
38
119
  thus enabling the flash in your actions to contain large values, and still fit in
@@ -42,54 +123,32 @@ executables: []
42
123
  extensions: []
43
124
  extra_rdoc_files: []
44
125
  files:
45
- - .gitignore
46
- - .travis.yml
47
- - Appraisals
48
- - Gemfile
49
- - Gemfile.lock
50
- - MIT-LICENSE
51
- - Rakefile
52
- - Readme.md
53
- - gemfiles/rails-2.3.gemfile
54
- - gemfiles/rails-2.3.gemfile.lock
55
- - gemfiles/rails-3.0.gemfile
56
- - gemfiles/rails-3.0.gemfile.lock
57
- - gemfiles/rails-3.2.gemfile
58
- - gemfiles/rails-3.2.gemfile.lock
126
+ - LICENSE
127
+ - README.md
59
128
  - lib/memflash.rb
60
- - memflash.gemspec
61
- - test/memflash_test.rb
62
- - test/test_helper.rb
63
- homepage: http://github.com/zendesk/memflash
129
+ homepage: https://github.com/zendesk/memflash
64
130
  licenses:
65
- - MIT
131
+ - Apache License Version 2.0
132
+ metadata: {}
66
133
  post_install_message:
67
134
  rdoc_options: []
68
135
  require_paths:
69
136
  - lib
70
137
  required_ruby_version: !ruby/object:Gem::Requirement
71
- none: false
72
138
  requirements:
73
- - - ! '>='
139
+ - - ">="
74
140
  - !ruby/object:Gem::Version
75
141
  version: '0'
76
- segments:
77
- - 0
78
- hash: 4171930608334764832
79
142
  required_rubygems_version: !ruby/object:Gem::Requirement
80
- none: false
81
143
  requirements:
82
- - - ! '>='
144
+ - - ">="
83
145
  - !ruby/object:Gem::Version
84
146
  version: '0'
85
- segments:
86
- - 0
87
- hash: 4171930608334764832
88
147
  requirements: []
89
148
  rubyforge_project:
90
- rubygems_version: 1.8.24
149
+ rubygems_version: 2.2.2
91
150
  signing_key:
92
- specification_version: 3
151
+ specification_version: 4
93
152
  summary: Memflash is a gem which enables storing really long values in the Rails FlashHash
94
153
  without writing them to the session
95
154
  test_files: []
data/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- test/rails/log/*.log
2
- pkg
data/.travis.yml DELETED
@@ -1,8 +0,0 @@
1
- script: "bundle exec rake test"
2
- rvm:
3
- - 1.8.7
4
- - 1.9.3
5
- gemfile:
6
- - gemfiles/rails-2.3.gemfile
7
- - gemfiles/rails-3.0.gemfile
8
- - gemfiles/rails-3.2.gemfile
data/Appraisals DELETED
@@ -1,15 +0,0 @@
1
- appraise "rails-2.3" do
2
- gem "rails", "~> 2.3.14"
3
- gem "actionpack", "~> 2.3.14"
4
- end
5
-
6
- appraise "rails-3.0" do
7
- gem "rails", "~> 3.0.0"
8
- gem "actionpack", "~> 3.0.0"
9
- end
10
-
11
- appraise "rails-3.2" do
12
- gem "rails", "~> 3.2.6"
13
- gem "actionpack", "~> 3.2.6"
14
- end
15
-
data/Gemfile DELETED
@@ -1,9 +0,0 @@
1
- source :rubygems
2
- gemspec
3
-
4
- gem "rake"
5
- gem "test-unit", ">=2.5.1"
6
- gem "mocha", "~>0.11.0" # 0.12 breaks test-unit
7
- gem "appraisal"
8
- gem "shoulda"
9
- gem "rails"
data/Gemfile.lock DELETED
@@ -1,48 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- memflash (1.0.1)
5
- actionpack (>= 2.3.6, < 3.3)
6
-
7
- GEM
8
- remote: http://rubygems.org/
9
- specs:
10
- actionmailer (2.3.14)
11
- actionpack (= 2.3.14)
12
- actionpack (2.3.14)
13
- activesupport (= 2.3.14)
14
- rack (~> 1.1.0)
15
- activerecord (2.3.14)
16
- activesupport (= 2.3.14)
17
- activeresource (2.3.14)
18
- activesupport (= 2.3.14)
19
- activesupport (2.3.14)
20
- appraisal (0.4.1)
21
- bundler
22
- rake
23
- metaclass (0.0.1)
24
- mocha (0.11.4)
25
- metaclass (~> 0.0.1)
26
- rack (1.1.3)
27
- rails (2.3.14)
28
- actionmailer (= 2.3.14)
29
- actionpack (= 2.3.14)
30
- activerecord (= 2.3.14)
31
- activeresource (= 2.3.14)
32
- activesupport (= 2.3.14)
33
- rake (>= 0.8.3)
34
- rake (0.9.2.2)
35
- shoulda (2.11.3)
36
- test-unit (2.5.1)
37
-
38
- PLATFORMS
39
- ruby
40
-
41
- DEPENDENCIES
42
- appraisal
43
- memflash!
44
- mocha (~> 0.11.0)
45
- rails
46
- rake
47
- shoulda
48
- test-unit (>= 2.5.1)
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2009 [name of plugin creator]
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/Rakefile DELETED
@@ -1,13 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'appraisal'
3
-
4
- require 'rake/testtask'
5
- Rake::TestTask.new do |test|
6
- test.libs << 'lib'
7
- test.pattern = 'test/**/*_test.rb'
8
- test.verbose = true
9
- end
10
-
11
- task :default do
12
- sh "bundle exec rake appraisal:install && bundle exec rake appraisal test"
13
- end
data/Readme.md DELETED
@@ -1,53 +0,0 @@
1
- Memflash
2
- ========
3
-
4
- Memflash is a gem which enables storing really long values in the Rails FlashHash
5
- without writing them to the session. Instead, it transparently uses `Rails.cache`, thus
6
- enabling the flash in your actions to contain large values, and still fit in a cookie-based
7
- session store.
8
-
9
- How do I use it?
10
- ================
11
-
12
- Memflash is completely transparent -- requiring the gem automatically enhances FlashHash
13
- with caching-enabled reads and writes.
14
-
15
- By default, any message that is over 300 characters long, will be saved in Rails.cache,
16
- and a pointer to it stored in the flash. You can change this anywhere in your app by:
17
-
18
- Memflash.threshold = #{length-at-which-writing-to-the-cache-is-trigerred}
19
-
20
- How does it work?
21
- =================
22
-
23
- Memflash ties into the [] and []= methods of Rails's FlashHash. On writes, if the value
24
- being written has a length over Memflash.threshold, Memflash generates a pseudo-random
25
- key for it, writes the pseudo-random key and original value to `Rails.cache`, and stores
26
- the original key and pseudo-random key in the flash. Conceptually, when you write
27
- `flash[:error] = "some message"`, this is equivalent to:
28
-
29
- if "some message".length >= Memflash.threshold
30
- # generate a psedudo-random key, memflash_key
31
- # write memflash_key, "some message" to Rails.cache
32
- # write :error, memflash_key to the flash
33
- else
34
- # write :error, "some message" to the flash, as usual
35
- end
36
-
37
- On the flip side, reading from the flash, `flash[:error]` is conceptually equivalent to:
38
-
39
- if the value for :error stored in the flash is a memflash key
40
- # read the original (large) value from Rails.cache
41
- # return the original (large) value
42
- else
43
- # return the value stored in the flash, as usual
44
- end
45
-
46
- Author
47
- ======
48
-
49
- Authored by [Vladimir Andrijevik](mailto:vladimir@zendesk.com)
50
-
51
- Copyright (c) 2010 Zendesk, released under the MIT license
52
-
53
- [![Build Status](https://secure.travis-ci.org/zendesk/memflash.png)](http://travis-ci.org/zendesk/memflash)
@@ -1,13 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source :rubygems
4
-
5
- gem "rake"
6
- gem "test-unit", ">=2.5.1"
7
- gem "mocha", "~>0.11.0"
8
- gem "appraisal"
9
- gem "shoulda"
10
- gem "rails", "~> 2.3.14"
11
- gem "actionpack", "~> 2.3.14"
12
-
13
- gemspec :path=>"../"
@@ -1,53 +0,0 @@
1
- PATH
2
- remote: /Users/mgrosser/code/tools/memflash
3
- specs:
4
- memflash (1.0.0)
5
- actionpack (>= 2.3.6, < 3.3)
6
-
7
- GEM
8
- remote: http://rubygems.org/
9
- specs:
10
- actionmailer (2.3.14)
11
- actionpack (= 2.3.14)
12
- actionpack (2.3.14)
13
- activesupport (= 2.3.14)
14
- rack (~> 1.1.0)
15
- activerecord (2.3.14)
16
- activesupport (= 2.3.14)
17
- activeresource (2.3.14)
18
- activesupport (= 2.3.14)
19
- activesupport (2.3.14)
20
- appraisal (0.4.1)
21
- bundler
22
- rake
23
- metaclass (0.0.1)
24
- mocha (0.11.4)
25
- metaclass (~> 0.0.1)
26
- rack (1.1.3)
27
- rails (2.3.14)
28
- actionmailer (= 2.3.14)
29
- actionpack (= 2.3.14)
30
- activerecord (= 2.3.14)
31
- activeresource (= 2.3.14)
32
- activesupport (= 2.3.14)
33
- rake (>= 0.8.3)
34
- rake (0.9.2.2)
35
- shoulda (3.0.1)
36
- shoulda-context (~> 1.0.0)
37
- shoulda-matchers (~> 1.0.0)
38
- shoulda-context (1.0.0)
39
- shoulda-matchers (1.0.0)
40
- test-unit (2.5.1)
41
-
42
- PLATFORMS
43
- ruby
44
-
45
- DEPENDENCIES
46
- actionpack (~> 2.3.14)
47
- appraisal
48
- memflash!
49
- mocha (~> 0.11.0)
50
- rails (~> 2.3.14)
51
- rake
52
- shoulda
53
- test-unit (>= 2.5.1)
@@ -1,13 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source :rubygems
4
-
5
- gem "rake"
6
- gem "test-unit", ">=2.5.1"
7
- gem "mocha", "~>0.11.0"
8
- gem "appraisal"
9
- gem "shoulda"
10
- gem "rails", "~> 3.0.0"
11
- gem "actionpack", "~> 3.0.0"
12
-
13
- gemspec :path=>"../"
@@ -1,101 +0,0 @@
1
- PATH
2
- remote: /Users/mgrosser/code/tools/memflash
3
- specs:
4
- memflash (1.0.0)
5
- actionpack (>= 2.3.6, < 3.3)
6
-
7
- GEM
8
- remote: http://rubygems.org/
9
- specs:
10
- abstract (1.0.0)
11
- actionmailer (3.0.15)
12
- actionpack (= 3.0.15)
13
- mail (~> 2.2.19)
14
- actionpack (3.0.15)
15
- activemodel (= 3.0.15)
16
- activesupport (= 3.0.15)
17
- builder (~> 2.1.2)
18
- erubis (~> 2.6.6)
19
- i18n (~> 0.5.0)
20
- rack (~> 1.2.5)
21
- rack-mount (~> 0.6.14)
22
- rack-test (~> 0.5.7)
23
- tzinfo (~> 0.3.23)
24
- activemodel (3.0.15)
25
- activesupport (= 3.0.15)
26
- builder (~> 2.1.2)
27
- i18n (~> 0.5.0)
28
- activerecord (3.0.15)
29
- activemodel (= 3.0.15)
30
- activesupport (= 3.0.15)
31
- arel (~> 2.0.10)
32
- tzinfo (~> 0.3.23)
33
- activeresource (3.0.15)
34
- activemodel (= 3.0.15)
35
- activesupport (= 3.0.15)
36
- activesupport (3.0.15)
37
- appraisal (0.4.1)
38
- bundler
39
- rake
40
- arel (2.0.10)
41
- builder (2.1.2)
42
- erubis (2.6.6)
43
- abstract (>= 1.0.0)
44
- i18n (0.5.0)
45
- json (1.7.3)
46
- mail (2.2.19)
47
- activesupport (>= 2.3.6)
48
- i18n (>= 0.4.0)
49
- mime-types (~> 1.16)
50
- treetop (~> 1.4.8)
51
- metaclass (0.0.1)
52
- mime-types (1.19)
53
- mocha (0.11.4)
54
- metaclass (~> 0.0.1)
55
- polyglot (0.3.3)
56
- rack (1.2.5)
57
- rack-mount (0.6.14)
58
- rack (>= 1.0.0)
59
- rack-test (0.5.7)
60
- rack (>= 1.0)
61
- rails (3.0.15)
62
- actionmailer (= 3.0.15)
63
- actionpack (= 3.0.15)
64
- activerecord (= 3.0.15)
65
- activeresource (= 3.0.15)
66
- activesupport (= 3.0.15)
67
- bundler (~> 1.0)
68
- railties (= 3.0.15)
69
- railties (3.0.15)
70
- actionpack (= 3.0.15)
71
- activesupport (= 3.0.15)
72
- rake (>= 0.8.7)
73
- rdoc (~> 3.4)
74
- thor (~> 0.14.4)
75
- rake (0.9.2.2)
76
- rdoc (3.12)
77
- json (~> 1.4)
78
- shoulda (3.0.1)
79
- shoulda-context (~> 1.0.0)
80
- shoulda-matchers (~> 1.0.0)
81
- shoulda-context (1.0.0)
82
- shoulda-matchers (1.0.0)
83
- test-unit (2.5.1)
84
- thor (0.14.6)
85
- treetop (1.4.10)
86
- polyglot
87
- polyglot (>= 0.3.1)
88
- tzinfo (0.3.33)
89
-
90
- PLATFORMS
91
- ruby
92
-
93
- DEPENDENCIES
94
- actionpack (~> 3.0.0)
95
- appraisal
96
- memflash!
97
- mocha (~> 0.11.0)
98
- rails (~> 3.0.0)
99
- rake
100
- shoulda
101
- test-unit (>= 2.5.1)
@@ -1,13 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source :rubygems
4
-
5
- gem "rake"
6
- gem "test-unit", ">=2.5.1"
7
- gem "mocha", "~>0.11.0"
8
- gem "appraisal"
9
- gem "shoulda"
10
- gem "rails", "~> 3.2.6"
11
- gem "actionpack", "~> 3.2.6"
12
-
13
- gemspec :path=>"../"
@@ -1,110 +0,0 @@
1
- PATH
2
- remote: /Users/mgrosser/code/tools/memflash
3
- specs:
4
- memflash (1.0.0)
5
- actionpack (>= 2.3.6, < 3.3)
6
-
7
- GEM
8
- remote: http://rubygems.org/
9
- specs:
10
- actionmailer (3.2.6)
11
- actionpack (= 3.2.6)
12
- mail (~> 2.4.4)
13
- actionpack (3.2.6)
14
- activemodel (= 3.2.6)
15
- activesupport (= 3.2.6)
16
- builder (~> 3.0.0)
17
- erubis (~> 2.7.0)
18
- journey (~> 1.0.1)
19
- rack (~> 1.4.0)
20
- rack-cache (~> 1.2)
21
- rack-test (~> 0.6.1)
22
- sprockets (~> 2.1.3)
23
- activemodel (3.2.6)
24
- activesupport (= 3.2.6)
25
- builder (~> 3.0.0)
26
- activerecord (3.2.6)
27
- activemodel (= 3.2.6)
28
- activesupport (= 3.2.6)
29
- arel (~> 3.0.2)
30
- tzinfo (~> 0.3.29)
31
- activeresource (3.2.6)
32
- activemodel (= 3.2.6)
33
- activesupport (= 3.2.6)
34
- activesupport (3.2.6)
35
- i18n (~> 0.6)
36
- multi_json (~> 1.0)
37
- appraisal (0.4.1)
38
- bundler
39
- rake
40
- arel (3.0.2)
41
- builder (3.0.0)
42
- erubis (2.7.0)
43
- hike (1.2.1)
44
- i18n (0.6.0)
45
- journey (1.0.4)
46
- json (1.7.3)
47
- mail (2.4.4)
48
- i18n (>= 0.4.0)
49
- mime-types (~> 1.16)
50
- treetop (~> 1.4.8)
51
- metaclass (0.0.1)
52
- mime-types (1.19)
53
- mocha (0.11.4)
54
- metaclass (~> 0.0.1)
55
- multi_json (1.3.6)
56
- polyglot (0.3.3)
57
- rack (1.4.1)
58
- rack-cache (1.2)
59
- rack (>= 0.4)
60
- rack-ssl (1.3.2)
61
- rack
62
- rack-test (0.6.1)
63
- rack (>= 1.0)
64
- rails (3.2.6)
65
- actionmailer (= 3.2.6)
66
- actionpack (= 3.2.6)
67
- activerecord (= 3.2.6)
68
- activeresource (= 3.2.6)
69
- activesupport (= 3.2.6)
70
- bundler (~> 1.0)
71
- railties (= 3.2.6)
72
- railties (3.2.6)
73
- actionpack (= 3.2.6)
74
- activesupport (= 3.2.6)
75
- rack-ssl (~> 1.3.2)
76
- rake (>= 0.8.7)
77
- rdoc (~> 3.4)
78
- thor (>= 0.14.6, < 2.0)
79
- rake (0.9.2.2)
80
- rdoc (3.12)
81
- json (~> 1.4)
82
- shoulda (3.0.1)
83
- shoulda-context (~> 1.0.0)
84
- shoulda-matchers (~> 1.0.0)
85
- shoulda-context (1.0.0)
86
- shoulda-matchers (1.0.0)
87
- sprockets (2.1.3)
88
- hike (~> 1.2)
89
- rack (~> 1.0)
90
- tilt (~> 1.1, != 1.3.0)
91
- test-unit (2.5.1)
92
- thor (0.15.4)
93
- tilt (1.3.3)
94
- treetop (1.4.10)
95
- polyglot
96
- polyglot (>= 0.3.1)
97
- tzinfo (0.3.33)
98
-
99
- PLATFORMS
100
- ruby
101
-
102
- DEPENDENCIES
103
- actionpack (~> 3.2.6)
104
- appraisal
105
- memflash!
106
- mocha (~> 0.11.0)
107
- rails (~> 3.2.6)
108
- rake
109
- shoulda
110
- test-unit (>= 2.5.1)
data/memflash.gemspec DELETED
@@ -1,10 +0,0 @@
1
- Gem::Specification.new "memflash", "1.0.1" do |s|
2
- s.summary = "Memflash is a gem which enables storing really long values in the Rails FlashHash without writing them to the session"
3
- s.description = "Memflash is a gem which enables storing really long values in the Rails FlashHash without writing them to the session. Instead, it transparently uses `Rails.cache`, thus enabling the flash in your actions to contain large values, and still fit in a cookie-based session store"
4
- s.email = "vladimir@zendesk.com"
5
- s.homepage = "http://github.com/zendesk/memflash"
6
- s.authors = ["Vladimir Andrijevik"]
7
- s.files = `git ls-files`.split("\n")
8
- s.license = "MIT"
9
- s.add_dependency "actionpack", ">= 2.3.6", "< 3.3"
10
- end
@@ -1,111 +0,0 @@
1
- require File.expand_path "../test_helper", __FILE__
2
-
3
- class MemflashTest < Test::Unit::TestCase
4
- def setup
5
- base = if ActionPack::VERSION::MAJOR >= 3
6
- ActionDispatch::Flash::FlashHash
7
- else
8
- ActionController::Flash::FlashHash
9
- end
10
- @hash = base.new
11
- end
12
-
13
- context "Flash::FlashHash" do
14
- should "have a caching-enabled []" do
15
- assert @hash.respond_to?("[]_with_caching")
16
- end
17
-
18
- should "have a caching-enabled []=" do
19
- assert @hash.respond_to?("[]_with_caching=")
20
- end
21
- end
22
-
23
- context "storing a value" do
24
- context "that is a String" do
25
- context "shorter than Memflash.threshold" do
26
- should "not affect the cache" do
27
- Rails.cache.expects(:write).never
28
-
29
- @hash[:hello] = "a" * (Memflash.threshold - 1)
30
- end
31
- end
32
-
33
- context "at least as long as Memflash.threshold" do
34
- setup do
35
- @key = "a-sample-key"
36
- @value = "a" * (Memflash.threshold)
37
- end
38
-
39
- should "call memflash_key with the key" do
40
- @hash.expects(:memflash_key).with(@key)
41
-
42
- @hash[@key] = @value
43
- end
44
-
45
- should "write the memflash_key and value to Rails.cache" do
46
- # Stubbing out memflash_key is necessary so we can set a proper expectation below.
47
- # Without it, the key generated when setting the expectation and the one during
48
- # the actual write are different, so the assertion fails
49
- @hash.stubs(:memflash_key).with(@key).returns("a-memflash-key")
50
-
51
- Rails.cache.expects(:write).with("a-memflash-key", @value)
52
-
53
- @hash[@key] = @value
54
- end
55
-
56
- should "store the memflash_key in place of the original value" do
57
- # Stubbing out memflash_key is necessary so we can assert against the value
58
- # in the hash below. Without it, we don't know the memflash key that is generated,
59
- # so we cannot test whether it's in the hash or not.
60
- @hash.stubs(:memflash_key).with(@key).returns("a-memflash-key")
61
- @hash[@key] = @value
62
-
63
- assert_equal "a-memflash-key", @hash[@key]
64
- end
65
- end
66
- end
67
-
68
- context "that is not a String" do
69
- should "not affect the cache" do
70
- Rails.cache.expects(:write).never
71
-
72
- @hash[:time] = Time.now.to_i
73
- end
74
- end
75
- end
76
-
77
- context "reading a key" do
78
- should "check whether the value in the hash was memflashed" do
79
- @hash[:hello] = "world"
80
-
81
- @hash.expects(:memflashed?).with(:hello, "world")
82
-
83
- @hash[:hello]
84
- end
85
-
86
- context "whose value was memflashed" do
87
- setup do
88
- @hash.stubs(:memflashed?).returns(true)
89
- end
90
-
91
- should "retrieve the original value from Rails.cache" do
92
- key = "a-sample-memflashed-key"
93
- @hash[key] = "key-to-look-up-in-rails-cache"
94
- Rails.cache.expects(:read).with("key-to-look-up-in-rails-cache")
95
-
96
- @hash[key]
97
- end
98
- end
99
-
100
- context "whose value was not memflashed" do
101
- setup do
102
- @hash.stubs(:memflashed?).returns(false)
103
- end
104
-
105
- should "not read from Rails.cache" do
106
- Rails.cache.expects(:read).never
107
- @hash["a-non-memflashed-key"]
108
- end
109
- end
110
- end
111
- end
data/test/test_helper.rb DELETED
@@ -1,9 +0,0 @@
1
- require "active_support/test_case"
2
- require "shoulda"
3
- require "memflash"
4
-
5
- module Rails
6
- def self.cache
7
- @cache ||= ActiveSupport::Cache::MemoryStore.new
8
- end
9
- end