padrino-cookies 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +12 -0
- data/README.md +1 -1
- data/lib/padrino-cookies/jar.rb +7 -7
- data/lib/padrino-cookies/version.rb +1 -1
- data/padrino-cookies.gemspec +3 -1
- data/spec/cookies_spec.rb +15 -9
- data/spec/{spec.rb → spec_helper.rb} +0 -0
- metadata +34 -11
data/.travis.yml
ADDED
data/README.md
CHANGED
data/lib/padrino-cookies/jar.rb
CHANGED
@@ -17,9 +17,9 @@ module Padrino
|
|
17
17
|
end
|
18
18
|
|
19
19
|
@options = {
|
20
|
-
|
21
|
-
httponly
|
22
|
-
|
20
|
+
:path => '/',
|
21
|
+
:httponly => true,
|
22
|
+
:secure => @request.secure?
|
23
23
|
}
|
24
24
|
end
|
25
25
|
|
@@ -77,7 +77,7 @@ module Padrino
|
|
77
77
|
# @api public
|
78
78
|
def []=(name, options)
|
79
79
|
unless options.is_a?(Hash)
|
80
|
-
options = { value
|
80
|
+
options = { :value => options }
|
81
81
|
end
|
82
82
|
|
83
83
|
raise Overflow if options[:value].size > MAX_COOKIE_SIZE
|
@@ -239,7 +239,7 @@ module Padrino
|
|
239
239
|
end
|
240
240
|
|
241
241
|
def []=(name, options)
|
242
|
-
options = { value
|
242
|
+
options = { :value => options } unless options.is_a?(Hash)
|
243
243
|
options[:expires] = 1.year.from_now
|
244
244
|
@parent_jar[name] = options
|
245
245
|
end
|
@@ -272,7 +272,7 @@ module Padrino
|
|
272
272
|
end
|
273
273
|
|
274
274
|
def []=(name, options)
|
275
|
-
options = { value
|
275
|
+
options = { :value => options } unless options.is_a?(Hash)
|
276
276
|
options[:value] = @message_verifier.generate(options[:value])
|
277
277
|
@parent_jar[name] = options
|
278
278
|
end
|
@@ -286,4 +286,4 @@ module Padrino
|
|
286
286
|
end
|
287
287
|
end # SignedJar
|
288
288
|
end # Cookies
|
289
|
-
end # Padrino
|
289
|
+
end # Padrino
|
data/padrino-cookies.gemspec
CHANGED
@@ -20,5 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
s.add_development_dependency 'rspec', '>= 2.0.0'
|
22
22
|
s.add_development_dependency 'rspec-html-matchers'
|
23
|
+
s.add_development_dependency 'rake'
|
24
|
+
s.add_development_dependency 'yard'
|
23
25
|
s.add_development_dependency 'rack-test'
|
24
|
-
end
|
26
|
+
end
|
data/spec/cookies_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Padrino::Cookies do
|
4
4
|
let :cookies do
|
@@ -55,7 +55,7 @@ describe Padrino::Cookies do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'should accept a hash of options' do
|
58
|
-
cookies['test'] = { value
|
58
|
+
cookies['test'] = { :value => 'test', :path => '/' }
|
59
59
|
cookies['test'].should == 'test'
|
60
60
|
end
|
61
61
|
|
@@ -188,6 +188,9 @@ describe Padrino::Cookies do
|
|
188
188
|
|
189
189
|
context :permanent do
|
190
190
|
before { app.set :cookie_secret, ('test' * 16) }
|
191
|
+
let :verifier do
|
192
|
+
ActiveSupport::MessageVerifier.new('test' * 16)
|
193
|
+
end
|
191
194
|
|
192
195
|
it 'should add cookies to the parent jar' do
|
193
196
|
cookies.permanent['baz'] = 'foo'
|
@@ -195,7 +198,7 @@ describe Padrino::Cookies do
|
|
195
198
|
end
|
196
199
|
|
197
200
|
it 'should accept a hash of options' do
|
198
|
-
cookies.permanent['foo'] = { value
|
201
|
+
cookies.permanent['foo'] = { :value => 'baz', :path => '/' }
|
199
202
|
cookies['foo'].should == 'baz'
|
200
203
|
end
|
201
204
|
|
@@ -215,25 +218,28 @@ describe Padrino::Cookies do
|
|
215
218
|
end
|
216
219
|
|
217
220
|
result.should =~ /#{1.year.from_now.year}/
|
218
|
-
result.should =~
|
221
|
+
result.should =~ Regexp.new(verifier.generate('baz').gsub('=', '%3D'))
|
219
222
|
end
|
220
223
|
end
|
221
224
|
|
222
225
|
context :signed do
|
223
226
|
before { app.set :cookie_secret, ('test' * 16) }
|
227
|
+
let :verifier do
|
228
|
+
ActiveSupport::MessageVerifier.new('test' * 16)
|
229
|
+
end
|
224
230
|
|
225
231
|
it 'should read signed values' do
|
226
|
-
cookies['foo'] = '
|
232
|
+
cookies['foo'] = verifier.generate('baz')
|
227
233
|
cookies.signed['foo'].should == 'baz'
|
228
234
|
end
|
229
235
|
|
230
236
|
it 'should write signed values' do
|
231
237
|
cookies.signed['foo'] = 'baz'
|
232
|
-
cookies['foo'].should == '
|
238
|
+
cookies['foo'].should == verifier.generate('baz')
|
233
239
|
end
|
234
240
|
|
235
241
|
it 'should accept a hash of options' do
|
236
|
-
cookies.signed['foo'] = { value
|
242
|
+
cookies.signed['foo'] = { :value => 'baz', :path => '/' }
|
237
243
|
cookies.signed['foo'].should == 'baz'
|
238
244
|
end
|
239
245
|
|
@@ -249,7 +255,7 @@ describe Padrino::Cookies do
|
|
249
255
|
end
|
250
256
|
|
251
257
|
result.should =~ /#{1.year.from_now.year}/
|
252
|
-
result.should =~
|
258
|
+
result.should =~ Regexp.new(verifier.generate('baz').gsub('=', '%3D'))
|
253
259
|
end
|
254
260
|
end
|
255
|
-
end
|
261
|
+
end
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-cookies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: padrino-core
|
16
|
-
requirement: &
|
16
|
+
requirement: &14173716 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *14173716
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &14172624 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *14172624
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec-html-matchers
|
38
|
-
requirement: &
|
38
|
+
requirement: &14155560 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,32 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *14155560
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: &14155284 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *14155284
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: yard
|
60
|
+
requirement: &14154876 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *14154876
|
47
69
|
- !ruby/object:Gem::Dependency
|
48
70
|
name: rack-test
|
49
|
-
requirement: &
|
71
|
+
requirement: &14154516 !ruby/object:Gem::Requirement
|
50
72
|
none: false
|
51
73
|
requirements:
|
52
74
|
- - ! '>='
|
@@ -54,7 +76,7 @@ dependencies:
|
|
54
76
|
version: '0'
|
55
77
|
type: :development
|
56
78
|
prerelease: false
|
57
|
-
version_requirements: *
|
79
|
+
version_requirements: *14154516
|
58
80
|
description: A plugin for the Padrino web framework which adds support for Rails like
|
59
81
|
cookie manipulation
|
60
82
|
email:
|
@@ -65,6 +87,7 @@ extra_rdoc_files: []
|
|
65
87
|
files:
|
66
88
|
- .gitignore
|
67
89
|
- .rspec
|
90
|
+
- .travis.yml
|
68
91
|
- .yardopts
|
69
92
|
- Gemfile
|
70
93
|
- LICENSE
|
@@ -76,7 +99,7 @@ files:
|
|
76
99
|
- lib/padrino-cookies/version.rb
|
77
100
|
- padrino-cookies.gemspec
|
78
101
|
- spec/cookies_spec.rb
|
79
|
-
- spec/
|
102
|
+
- spec/spec_helper.rb
|
80
103
|
homepage: https://github.com/Cirex/padrino-cookies
|
81
104
|
licenses: []
|
82
105
|
post_install_message:
|