memflash 1.0.0 → 1.0.1

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.
@@ -0,0 +1,8 @@
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
@@ -0,0 +1,15 @@
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 ADDED
@@ -0,0 +1,9 @@
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"
@@ -0,0 +1,48 @@
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/Rakefile CHANGED
@@ -1,32 +1,13 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "memflash"
8
- gem.summary = "Memflash is a gem which enables storing really long values in the Rails FlashHash without writing them to the session"
9
- gem.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"
10
- gem.email = "vladimir@zendesk.com"
11
- gem.homepage = "http://github.com/zendesk/memflash"
12
- gem.authors = ["Vladimir Andrijevik"]
13
- gem.version = "1.0.0"
14
- gem.add_dependency "actionpack", "~> 2.3.5"
15
- gem.add_development_dependency "rails", "~> 2.3.5"
16
- gem.add_development_dependency "shoulda", "~> 2.11.0"
17
-
18
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
19
- end
20
- Jeweler::GemcutterTasks.new
21
- rescue LoadError
22
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
23
- end
1
+ require 'bundler/gem_tasks'
2
+ require 'appraisal'
24
3
 
25
4
  require 'rake/testtask'
26
- Rake::TestTask.new(:test) do |test|
27
- test.libs << 'lib' << 'test'
5
+ Rake::TestTask.new do |test|
6
+ test.libs << 'lib'
28
7
  test.pattern = 'test/**/*_test.rb'
29
8
  test.verbose = true
30
9
  end
31
10
 
32
- task :default => :test
11
+ task :default do
12
+ sh "bundle exec rake appraisal:install && bundle exec rake appraisal test"
13
+ end
@@ -43,11 +43,11 @@ On the flip side, reading from the flash, `flash[:error]` is conceptually equiva
43
43
  # return the value stored in the flash, as usual
44
44
  end
45
45
 
46
- Anything else?
47
- ==============
48
-
49
- We'd love to hear from you!
46
+ Author
47
+ ======
50
48
 
51
49
  Authored by [Vladimir Andrijevik](mailto:vladimir@zendesk.com)
52
50
 
53
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)
@@ -0,0 +1,13 @@
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=>"../"
@@ -0,0 +1,53 @@
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)
@@ -0,0 +1,13 @@
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=>"../"
@@ -0,0 +1,101 @@
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)
@@ -0,0 +1,13 @@
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=>"../"
@@ -0,0 +1,110 @@
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)
@@ -1,16 +1,17 @@
1
1
  module Memflash
2
- mattr_accessor :threshold
2
+ class << self
3
+ attr_accessor :threshold
4
+ end
3
5
  self.threshold = 300 # Messages longer than this will be stored in Rails.cache
4
6
 
5
- def self.included(base)
6
- base.class_eval do
7
- include InstanceMethods
8
- alias_method_chain :[]=, :caching
9
- alias_method_chain :[], :caching
7
+ module CachingLayer
8
+ def self.included(base)
9
+ base.class_eval do
10
+ alias_method_chain :[]=, :caching
11
+ alias_method_chain :[], :caching
12
+ end
10
13
  end
11
- end
12
14
 
13
- module InstanceMethods
14
15
  define_method "[]_with_caching=" do |key, value|
15
16
  value_for_hash = value
16
17
 
@@ -28,16 +29,23 @@ module Memflash
28
29
  end
29
30
 
30
31
  private
31
- def memflash_key(hash_key)
32
- "Memflash-#{hash_key}-#{Time.now.to_f}-#{Kernel.rand}"
33
- end
34
32
 
35
- def memflashed?(key, value)
36
- !!(value =~ /^Memflash-#{key}/)
37
- end
38
- end # InstanceMethods
39
- end # Memflash
33
+ def memflash_key(hash_key)
34
+ "Memflash-#{hash_key}-#{Time.now.to_f}-#{Kernel.rand}"
35
+ end
40
36
 
41
- require 'action_pack'
42
- require 'action_controller'
43
- ActionController::Flash::FlashHash.class_eval { include Memflash }
37
+ def memflashed?(key, value)
38
+ !!(value =~ /^Memflash-#{key}/)
39
+ end
40
+ end
41
+ end
42
+
43
+ require 'action_pack/version'
44
+ base = if ActionPack::VERSION::MAJOR >= 3
45
+ require 'action_dispatch'
46
+ ActionDispatch::Flash::FlashHash
47
+ else
48
+ require 'action_controller'
49
+ ActionController::Flash::FlashHash
50
+ end
51
+ base.send :include, Memflash::CachingLayer
@@ -1,67 +1,10 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{memflash}
8
- s.version = "1.0.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
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"
11
6
  s.authors = ["Vladimir Andrijevik"]
12
- s.date = %q{2010-09-14}
13
- s.description = %q{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}
14
- s.email = %q{vladimir@zendesk.com}
15
- s.extra_rdoc_files = [
16
- "README.markdown"
17
- ]
18
- s.files = [
19
- ".gitignore",
20
- "MIT-LICENSE",
21
- "README.markdown",
22
- "Rakefile",
23
- "lib/memflash.rb",
24
- "memflash.gemspec",
25
- "test/memflash_test.rb",
26
- "test/rails/app/controllers/application.rb",
27
- "test/rails/config/boot.rb",
28
- "test/rails/config/environment.rb",
29
- "test/rails/config/environments/test.rb",
30
- "test/rails/config/routes.rb",
31
- "test/test_helper.rb"
32
- ]
33
- s.homepage = %q{http://github.com/zendesk/memflash}
34
- s.rdoc_options = ["--charset=UTF-8"]
35
- s.require_paths = ["lib"]
36
- s.rubygems_version = %q{1.3.7}
37
- s.summary = %q{Memflash is a gem which enables storing really long values in the Rails FlashHash without writing them to the session}
38
- s.test_files = [
39
- "test/memflash_test.rb",
40
- "test/rails/app/controllers/application.rb",
41
- "test/rails/config/boot.rb",
42
- "test/rails/config/environment.rb",
43
- "test/rails/config/environments/test.rb",
44
- "test/rails/config/routes.rb",
45
- "test/test_helper.rb"
46
- ]
47
-
48
- if s.respond_to? :specification_version then
49
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
50
- s.specification_version = 3
51
-
52
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
- s.add_runtime_dependency(%q<actionpack>, ["~> 2.3.5"])
54
- s.add_development_dependency(%q<rails>, ["~> 2.3.5"])
55
- s.add_development_dependency(%q<shoulda>, ["~> 2.11.0"])
56
- else
57
- s.add_dependency(%q<actionpack>, ["~> 2.3.5"])
58
- s.add_dependency(%q<rails>, ["~> 2.3.5"])
59
- s.add_dependency(%q<shoulda>, ["~> 2.11.0"])
60
- end
61
- else
62
- s.add_dependency(%q<actionpack>, ["~> 2.3.5"])
63
- s.add_dependency(%q<rails>, ["~> 2.3.5"])
64
- s.add_dependency(%q<shoulda>, ["~> 2.11.0"])
65
- end
7
+ s.files = `git ls-files`.split("\n")
8
+ s.license = "MIT"
9
+ s.add_dependency "actionpack", ">= 2.3.6", "< 3.3"
66
10
  end
67
-
@@ -1,33 +1,34 @@
1
- require "test_helper"
1
+ require File.expand_path "../test_helper", __FILE__
2
2
 
3
3
  class MemflashTest < Test::Unit::TestCase
4
- class EnhancedHash < Hash
5
- include Memflash
6
- end
7
-
8
4
  def setup
9
- @hash = EnhancedHash.new
5
+ base = if ActionPack::VERSION::MAJOR >= 3
6
+ ActionDispatch::Flash::FlashHash
7
+ else
8
+ ActionController::Flash::FlashHash
9
+ end
10
+ @hash = base.new
10
11
  end
11
12
 
12
- context "A memflash-enhanced Hash" do
13
+ context "Flash::FlashHash" do
13
14
  should "have a caching-enabled []" do
14
15
  assert @hash.respond_to?("[]_with_caching")
15
16
  end
16
-
17
+
17
18
  should "have a caching-enabled []=" do
18
19
  assert @hash.respond_to?("[]_with_caching=")
19
20
  end
20
- end # A memflash-enhanced Hash
21
-
22
- context "In a memflash-enhanced Hash, storing a value" do
21
+ end
22
+
23
+ context "storing a value" do
23
24
  context "that is a String" do
24
25
  context "shorter than Memflash.threshold" do
25
26
  should "not affect the cache" do
26
27
  Rails.cache.expects(:write).never
27
28
 
28
29
  @hash[:hello] = "a" * (Memflash.threshold - 1)
29
- end # not affect the cache
30
- end # shorter than Memflash.threshold
30
+ end
31
+ end
31
32
 
32
33
  context "at least as long as Memflash.threshold" do
33
34
  setup do
@@ -39,7 +40,7 @@ class MemflashTest < Test::Unit::TestCase
39
40
  @hash.expects(:memflash_key).with(@key)
40
41
 
41
42
  @hash[@key] = @value
42
- end # call memflash_key with the key
43
+ end
43
44
 
44
45
  should "write the memflash_key and value to Rails.cache" do
45
46
  # Stubbing out memflash_key is necessary so we can set a proper expectation below.
@@ -50,7 +51,7 @@ class MemflashTest < Test::Unit::TestCase
50
51
  Rails.cache.expects(:write).with("a-memflash-key", @value)
51
52
 
52
53
  @hash[@key] = @value
53
- end # write the memflash_key and value to Rails.cache
54
+ end
54
55
 
55
56
  should "store the memflash_key in place of the original value" do
56
57
  # Stubbing out memflash_key is necessary so we can assert against the value
@@ -60,20 +61,20 @@ class MemflashTest < Test::Unit::TestCase
60
61
  @hash[@key] = @value
61
62
 
62
63
  assert_equal "a-memflash-key", @hash[@key]
63
- end # store the memflash_key in place of the original value
64
- end # at least as long as Memflash.threshold
65
- end # that is a String
64
+ end
65
+ end
66
+ end
66
67
 
67
68
  context "that is not a String" do
68
69
  should "not affect the cache" do
69
70
  Rails.cache.expects(:write).never
70
71
 
71
72
  @hash[:time] = Time.now.to_i
72
- end # not affect the cache
73
- end # that is not a String
74
- end # In a memflash-enhanced Hash, storing a value
73
+ end
74
+ end
75
+ end
75
76
 
76
- context "From a memflash-enhanced Hash, reading by a key" do
77
+ context "reading a key" do
77
78
  should "check whether the value in the hash was memflashed" do
78
79
  @hash[:hello] = "world"
79
80
 
@@ -93,8 +94,8 @@ class MemflashTest < Test::Unit::TestCase
93
94
  Rails.cache.expects(:read).with("key-to-look-up-in-rails-cache")
94
95
 
95
96
  @hash[key]
96
- end # retrieve the original value from Rails.cache
97
- end # whose value was memflashed
97
+ end
98
+ end
98
99
 
99
100
  context "whose value was not memflashed" do
100
101
  setup do
@@ -103,15 +104,8 @@ class MemflashTest < Test::Unit::TestCase
103
104
 
104
105
  should "not read from Rails.cache" do
105
106
  Rails.cache.expects(:read).never
106
-
107
107
  @hash["a-non-memflashed-key"]
108
- end # not read from Rails.cache
109
- end # whose value was not memflashed
110
- end # From a memflash-enhanced Hash, reading a value
111
-
112
- context "ActionController::Flash::FlashHash" do
113
- should "be automatically cache-enhanced" do
114
- assert ActionController::Flash::FlashHash.ancestors.include?(Memflash)
108
+ end
115
109
  end
116
- end # ActionController::Flash::FlashHash
110
+ end
117
111
  end
@@ -1,6 +1,9 @@
1
- ENV["RAILS_ENV"] = "test"
2
- require File.expand_path(File.join(File.dirname(__FILE__), "rails", "config", "environment"))
3
-
4
- require 'rubygems'
5
- require 'active_support/test_case'
1
+ require "active_support/test_case"
2
+ require "shoulda"
6
3
  require "memflash"
4
+
5
+ module Rails
6
+ def self.cache
7
+ @cache ||= ActiveSupport::Cache::MemoryStore.new
8
+ end
9
+ end
metadata CHANGED
@@ -1,132 +1,95 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: memflash
3
- version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease: false
6
- segments:
7
- - 1
8
- - 0
9
- - 0
10
- version: 1.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Vladimir Andrijevik
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-09-14 00:00:00 -07:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2012-07-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: actionpack
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 9
30
- segments:
31
- - 2
32
- - 3
33
- - 5
34
- version: 2.3.5
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.3.6
22
+ - - <
23
+ - !ruby/object:Gem::Version
24
+ version: '3.3'
35
25
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: rails
39
- prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- hash: 9
46
- segments:
47
- - 2
48
- - 3
49
- - 5
50
- version: 2.3.5
51
- type: :development
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: shoulda
55
26
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
27
+ version_requirements: !ruby/object:Gem::Requirement
57
28
  none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- hash: 35
62
- segments:
63
- - 2
64
- - 11
65
- - 0
66
- version: 2.11.0
67
- type: :development
68
- version_requirements: *id003
69
- 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
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 2.3.6
33
+ - - <
34
+ - !ruby/object:Gem::Version
35
+ version: '3.3'
36
+ description: Memflash is a gem which enables storing really long values in the Rails
37
+ FlashHash without writing them to the session. Instead, it transparently uses `Rails.cache`,
38
+ thus enabling the flash in your actions to contain large values, and still fit in
39
+ a cookie-based session store
70
40
  email: vladimir@zendesk.com
71
41
  executables: []
72
-
73
42
  extensions: []
74
-
75
- extra_rdoc_files:
76
- - README.markdown
77
- files:
43
+ extra_rdoc_files: []
44
+ files:
78
45
  - .gitignore
46
+ - .travis.yml
47
+ - Appraisals
48
+ - Gemfile
49
+ - Gemfile.lock
79
50
  - MIT-LICENSE
80
- - README.markdown
81
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
82
59
  - lib/memflash.rb
83
60
  - memflash.gemspec
84
61
  - test/memflash_test.rb
85
- - test/rails/app/controllers/application.rb
86
- - test/rails/config/boot.rb
87
- - test/rails/config/environment.rb
88
- - test/rails/config/environments/test.rb
89
- - test/rails/config/routes.rb
90
62
  - test/test_helper.rb
91
- has_rdoc: true
92
63
  homepage: http://github.com/zendesk/memflash
93
- licenses: []
94
-
64
+ licenses:
65
+ - MIT
95
66
  post_install_message:
96
- rdoc_options:
97
- - --charset=UTF-8
98
- require_paths:
67
+ rdoc_options: []
68
+ require_paths:
99
69
  - lib
100
- required_ruby_version: !ruby/object:Gem::Requirement
70
+ required_ruby_version: !ruby/object:Gem::Requirement
101
71
  none: false
102
- requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- hash: 3
106
- segments:
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ segments:
107
77
  - 0
108
- version: "0"
109
- required_rubygems_version: !ruby/object:Gem::Requirement
78
+ hash: 4171930608334764832
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
80
  none: false
111
- requirements:
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- hash: 3
115
- segments:
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ segments:
116
86
  - 0
117
- version: "0"
87
+ hash: 4171930608334764832
118
88
  requirements: []
119
-
120
89
  rubyforge_project:
121
- rubygems_version: 1.3.7
90
+ rubygems_version: 1.8.24
122
91
  signing_key:
123
92
  specification_version: 3
124
- summary: Memflash is a gem which enables storing really long values in the Rails FlashHash without writing them to the session
125
- test_files:
126
- - test/memflash_test.rb
127
- - test/rails/app/controllers/application.rb
128
- - test/rails/config/boot.rb
129
- - test/rails/config/environment.rb
130
- - test/rails/config/environments/test.rb
131
- - test/rails/config/routes.rb
132
- - test/test_helper.rb
93
+ summary: Memflash is a gem which enables storing really long values in the Rails FlashHash
94
+ without writing them to the session
95
+ test_files: []
File without changes
@@ -1,109 +0,0 @@
1
- # Don't change this file!
2
- # Configure your app in config/environment.rb and config/environments/*.rb
3
-
4
- RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
-
6
- module Rails
7
- class << self
8
- def boot!
9
- unless booted?
10
- preinitialize
11
- pick_boot.run
12
- end
13
- end
14
-
15
- def booted?
16
- defined? Rails::Initializer
17
- end
18
-
19
- def pick_boot
20
- (vendor_rails? ? VendorBoot : GemBoot).new
21
- end
22
-
23
- def vendor_rails?
24
- File.exist?("#{RAILS_ROOT}/vendor/rails")
25
- end
26
-
27
- def preinitialize
28
- load(preinitializer_path) if File.exist?(preinitializer_path)
29
- end
30
-
31
- def preinitializer_path
32
- "#{RAILS_ROOT}/config/preinitializer.rb"
33
- end
34
- end
35
-
36
- class Boot
37
- def run
38
- load_initializer
39
- Rails::Initializer.run(:set_load_path)
40
- end
41
- end
42
-
43
- class VendorBoot < Boot
44
- def load_initializer
45
- require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
- Rails::Initializer.run(:install_gem_spec_stubs)
47
- end
48
- end
49
-
50
- class GemBoot < Boot
51
- def load_initializer
52
- self.class.load_rubygems
53
- load_rails_gem
54
- require 'initializer'
55
- end
56
-
57
- def load_rails_gem
58
- if version = self.class.gem_version
59
- gem 'rails', version
60
- else
61
- gem 'rails'
62
- end
63
- rescue Gem::LoadError => load_error
64
- $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
65
- exit 1
66
- end
67
-
68
- class << self
69
- def rubygems_version
70
- Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
71
- end
72
-
73
- def gem_version
74
- if defined? RAILS_GEM_VERSION
75
- RAILS_GEM_VERSION
76
- elsif ENV.include?('RAILS_GEM_VERSION')
77
- ENV['RAILS_GEM_VERSION']
78
- else
79
- parse_gem_version(read_environment_rb)
80
- end
81
- end
82
-
83
- def load_rubygems
84
- require 'rubygems'
85
-
86
- unless rubygems_version >= '0.9.4'
87
- $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
88
- exit 1
89
- end
90
-
91
- rescue LoadError
92
- $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org)
93
- exit 1
94
- end
95
-
96
- def parse_gem_version(text)
97
- $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
98
- end
99
-
100
- private
101
- def read_environment_rb
102
- File.read("#{RAILS_ROOT}/config/environment.rb")
103
- end
104
- end
105
- end
106
- end
107
-
108
- # All that for this:
109
- Rails.boot!
@@ -1,9 +0,0 @@
1
- # Bootstrap the Rails environment, frameworks, and default configuration
2
- require File.join(File.dirname(__FILE__), 'boot')
3
-
4
- Rails::Initializer.run do |config|
5
- config.frameworks -= [ :active_record ]
6
- config.action_controller.session = { :key => "_memflash_session", :secret => "ac0dcc5b4d9eef497e671126a845c3c5" }
7
-
8
- config.gem 'shoulda', :lib => 'shoulda/rails'
9
- end
@@ -1,19 +0,0 @@
1
- # Settings specified here will take precedence over those in config/environment.rb
2
-
3
- # The test environment is used exclusively to run your application's
4
- # test suite. You never need to work with it otherwise. Remember that
5
- # your test database is "scratch space" for the test suite and is wiped
6
- # and recreated between test runs. Don't rely on the data there!
7
- config.cache_classes = true
8
-
9
- # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
11
-
12
- # Show full error reports and disable caching
13
- config.action_controller.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
15
-
16
- # Tell ActionMailer not to deliver emails to the real world.
17
- # The :test delivery method accumulates sent emails in the
18
- # ActionMailer::Base.deliveries array.
19
- config.action_mailer.delivery_method = :test
File without changes