cookie_monster 0.1.3 → 0.1.4
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.
- checksums.yaml +8 -8
- data/Gemfile.lock +1 -1
- data/lib/cookie_monster/jar.rb +6 -13
- data/lib/cookie_monster/rails.rb +1 -1
- data/lib/cookie_monster/version.rb +1 -1
- data/test/cookie_monster/test_jar.rb +10 -20
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjQ1OThkM2MxYTM3YzA2YWI0NzljYjRjNjgwZjljNzM5N2MwNjRiZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZWNjYWJkYWQzZGNjYWE2ZDBmZDQ4ZWFlZGYxMWE2OThiYjdjNjUzNg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzRiZmU2NTY4NDJhNTQzNTRmMTJmMzgxYWE2YmJmOTkwY2QyNGE5NmI4YWY5
|
10
|
+
YjkzNGI5ZDNlNmY2NmQ5MDM0OTc2NGQzZjlmZTY2MWY3ZjY5NTk0MjA5ZjBj
|
11
|
+
NmUzMTc1Mjk4MWU1YjUxY2RjYmRjNTZlZWUyNGJjNDc5MDU1MzQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjFjNTg0NGM2MjRiOTBhM2IzNmQwZWZkYTVjNzQ5NGNmYTYxYzI0MzgxMzA2
|
14
|
+
MWQwZDM1YWVmNDI1MjFjMzAwZTQyNWY0NzllMDNlMTg0NzQ4NWVmZmRhMmYz
|
15
|
+
MGQ3NDBjMWJkY2JjMDU2OTRkNzM3MTllMjMwNTQxZGJlYzAxZmY=
|
data/Gemfile.lock
CHANGED
data/lib/cookie_monster/jar.rb
CHANGED
@@ -1,21 +1,14 @@
|
|
1
1
|
module CookieMonster
|
2
2
|
class Jar < Base
|
3
|
-
attr_reader :
|
3
|
+
attr_reader :cookies
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
@
|
7
|
-
@response = options.delete(:response)
|
8
|
-
@options = options
|
5
|
+
def initialize(cookies)
|
6
|
+
@cookies = cookies
|
9
7
|
end
|
10
8
|
|
11
9
|
def [](key)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
if response_cookies[key]
|
16
|
-
cookie = response_cookies[key]
|
17
|
-
elsif request_cookies[key]
|
18
|
-
cookie = request_cookies[key]
|
10
|
+
if @cookies[key]
|
11
|
+
cookie = @cookies[key]
|
19
12
|
else
|
20
13
|
return nil
|
21
14
|
end
|
@@ -34,7 +27,7 @@ module CookieMonster
|
|
34
27
|
|
35
28
|
encrypted_value = Encryption.new(value).encrypt
|
36
29
|
|
37
|
-
@
|
30
|
+
@cookies[key] = {
|
38
31
|
:value => encrypted_value,
|
39
32
|
:httponly => options[:httponly],
|
40
33
|
:expires => options[:expires],
|
data/lib/cookie_monster/rails.rb
CHANGED
@@ -1,12 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class
|
4
|
-
def cookies
|
5
|
-
{ foo: 'a cookie' }
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
class FakeResponse
|
3
|
+
class FakeCookies
|
10
4
|
attr_reader :cookies
|
11
5
|
def initialize
|
12
6
|
@cookies = {
|
@@ -14,25 +8,25 @@ class FakeResponse
|
|
14
8
|
}
|
15
9
|
end
|
16
10
|
|
17
|
-
def
|
11
|
+
def [](key)
|
12
|
+
@cookies[key]
|
13
|
+
end
|
14
|
+
|
15
|
+
def []=(key, options)
|
18
16
|
@cookies[key] = options
|
19
17
|
end
|
20
18
|
end
|
21
19
|
|
22
20
|
class JarTest < Test::Unit::TestCase
|
23
21
|
def setup
|
24
|
-
@
|
25
|
-
request: FakeRequest.new,
|
26
|
-
response: FakeResponse.new
|
27
|
-
}
|
28
|
-
@jar = CookieMonster::Jar.new(@options)
|
22
|
+
@jar = CookieMonster::Jar.new(FakeCookies.new)
|
29
23
|
end
|
30
24
|
|
31
25
|
def test_setting_a_cookie
|
32
26
|
CookieMonster.configuration.expects(:iv).at_least_once.returns('x' * 16)
|
33
27
|
@jar[:hello] = 'testing a cookie'
|
34
28
|
assert_equal CookieMonster::Encryption.new('testing a cookie').encrypt,
|
35
|
-
@jar.
|
29
|
+
@jar.cookies[:hello][:value]
|
36
30
|
end
|
37
31
|
|
38
32
|
def test_reading_a_cookie_set_in_response_first
|
@@ -41,11 +35,7 @@ class JarTest < Test::Unit::TestCase
|
|
41
35
|
end
|
42
36
|
|
43
37
|
def test_reading_a_cookie_from_request
|
44
|
-
assert_equal 'already set', @jar[
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_indifferent_access
|
48
|
-
assert_equal @jar[:a_cookie], @jar['a_cookie']
|
38
|
+
assert_equal 'already set', @jar['a_cookie']
|
49
39
|
end
|
50
40
|
|
51
41
|
def test_setting_a_more_complicated_data_type
|
@@ -56,6 +46,6 @@ class JarTest < Test::Unit::TestCase
|
|
56
46
|
|
57
47
|
def test_including_other_options
|
58
48
|
@jar[:cookie] = 'something', { expires: 'some point in the future' }
|
59
|
-
assert_equal 'some point in the future', @jar.
|
49
|
+
assert_equal 'some point in the future', @jar.cookies[:cookie][:expires]
|
60
50
|
end
|
61
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cookie_monster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dylan Griffin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|