sinatra-contrib 2.0.0.beta2 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sinatra/config_file.rb +2 -2
- data/lib/sinatra/content_for.rb +1 -1
- data/lib/sinatra/cookies.rb +5 -1
- data/lib/sinatra/respond_with.rb +2 -0
- data/lib/sinatra/streaming.rb +4 -0
- data/lib/sinatra/test_helpers.rb +5 -1
- data/sinatra-contrib.gemspec +2 -2
- data/spec/config_file_spec.rb +6 -6
- data/spec/cookies_spec.rb +23 -0
- metadata +22 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d991b914291bb371442ba8031c64548acd0ed2f
|
4
|
+
data.tar.gz: 87caaefbed03e5ad9b760fe37e9a855dd7b2f728
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 187c5077d865228cef464aab890399b53c2c9f299b0c91710f64d74342307ddefcb0c20e03cf72cedd831243535d199b327cb92245345cf6e5dff7a0caaa897d
|
7
|
+
data.tar.gz: 021b1a649f15e0eb78a92fe70b9a88e771103e6b4736baf62ba2da088b14c1dcc1fc87448b18e9c3dbf06c7dc2d44fb2a0f9d3f06cfbde7562dacef5502ce138
|
data/lib/sinatra/config_file.rb
CHANGED
@@ -129,7 +129,7 @@ module Sinatra
|
|
129
129
|
paths.each do |pattern|
|
130
130
|
Dir.glob(pattern) do |file|
|
131
131
|
raise UnsupportedConfigType unless ['.yml', '.erb'].include?(File.extname(file))
|
132
|
-
|
132
|
+
logger.info "loading config file '#{file}'" if logging? && respond_to?(:logger)
|
133
133
|
document = ERB.new(IO.read(file)).result
|
134
134
|
yaml = config_for_env(YAML.load(document)) || {}
|
135
135
|
yaml.each_pair do |key, value|
|
@@ -161,7 +161,7 @@ module Sinatra
|
|
161
161
|
end
|
162
162
|
|
163
163
|
if hash.respond_to? :to_hash
|
164
|
-
indifferent_hash = Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
|
164
|
+
indifferent_hash = Hash.new { |hash, key| hash[key.to_s] if Symbol === key }
|
165
165
|
indifferent_hash.merge hash.to_hash
|
166
166
|
else
|
167
167
|
hash
|
data/lib/sinatra/content_for.rb
CHANGED
data/lib/sinatra/cookies.rb
CHANGED
@@ -86,7 +86,7 @@ module Sinatra
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def []=(key, value)
|
89
|
-
|
89
|
+
set(key, value: value)
|
90
90
|
end
|
91
91
|
|
92
92
|
def assoc(key)
|
@@ -240,6 +240,10 @@ module Sinatra
|
|
240
240
|
|
241
241
|
alias select! keep_if if Hash.method_defined? :select!
|
242
242
|
|
243
|
+
def set(key, options = {})
|
244
|
+
@response.set_cookie key.to_s, @options.merge(options)
|
245
|
+
end
|
246
|
+
|
243
247
|
def shift
|
244
248
|
key, value = to_hash.shift
|
245
249
|
delete(key)
|
data/lib/sinatra/respond_with.rb
CHANGED
data/lib/sinatra/streaming.rb
CHANGED
@@ -98,6 +98,8 @@ module Sinatra
|
|
98
98
|
|
99
99
|
def <<(data)
|
100
100
|
raise IOError, 'not opened for writing' if closed?
|
101
|
+
|
102
|
+
@transformer ||= nil
|
101
103
|
data = data.to_s
|
102
104
|
data = @transformer[data] if @transformer
|
103
105
|
@pos += data.bytesize
|
@@ -116,6 +118,8 @@ module Sinatra
|
|
116
118
|
end
|
117
119
|
|
118
120
|
def map!(&block)
|
121
|
+
@transformer ||= nil
|
122
|
+
|
119
123
|
if @transformer
|
120
124
|
inner, outer = @transformer, block
|
121
125
|
block = proc { |value| outer[inner[value]] }
|
data/lib/sinatra/test_helpers.rb
CHANGED
data/sinatra-contrib.gemspec
CHANGED
@@ -217,10 +217,9 @@ Gem::Specification.new do |s|
|
|
217
217
|
s.required_ruby_version = '>= 2.2.0'
|
218
218
|
|
219
219
|
s.add_dependency "sinatra", Sinatra::VERSION
|
220
|
-
s.add_dependency "mustermann", "1.0.0
|
220
|
+
s.add_dependency "mustermann", "1.0.0"
|
221
221
|
s.add_dependency "backports", ">= 2.0"
|
222
222
|
s.add_dependency "tilt", ">= 1.3", "< 3"
|
223
|
-
s.add_dependency "rack-test"
|
224
223
|
s.add_dependency "rack-protection", Sinatra::VERSION
|
225
224
|
s.add_dependency "multi_json"
|
226
225
|
|
@@ -242,4 +241,5 @@ Gem::Specification.new do |s|
|
|
242
241
|
s.add_development_dependency "wikicloth"
|
243
242
|
s.add_development_dependency "markaby"
|
244
243
|
s.add_development_dependency "rake", "< 11"
|
244
|
+
s.add_development_dependency "rack-test"
|
245
245
|
end
|
data/spec/config_file_spec.rb
CHANGED
@@ -24,12 +24,12 @@ describe Sinatra::ConfigFile do
|
|
24
24
|
|
25
25
|
it 'should render options in ERB tags when using .yml files' do
|
26
26
|
config_file 'key_value.yml'
|
27
|
-
settings.bar.
|
28
|
-
settings.something.
|
29
|
-
settings.nested['a'].
|
30
|
-
settings.nested[:a].
|
31
|
-
settings.nested['b'].
|
32
|
-
settings.nested[:b].
|
27
|
+
expect(settings.bar).to eq "bar"
|
28
|
+
expect(settings.something).to eq 42
|
29
|
+
expect(settings.nested['a']).to eq 1
|
30
|
+
expect(settings.nested[:a]).to eq 1
|
31
|
+
expect(settings.nested['b']).to eq 2
|
32
|
+
expect(settings.nested[:b]).to eq 2
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'should render options in ERB tags when using .yml.erb files' do
|
data/spec/cookies_spec.rb
CHANGED
@@ -719,6 +719,29 @@ describe Sinatra::Cookies do
|
|
719
719
|
end
|
720
720
|
end
|
721
721
|
|
722
|
+
describe :set do
|
723
|
+
it 'sets a cookie' do
|
724
|
+
cookie_route { cookies.set('foo', value: 'bar') }
|
725
|
+
expect(cookie_jar['foo']).to eq('bar')
|
726
|
+
end
|
727
|
+
|
728
|
+
it 'sets a cookie with HttpOnly' do
|
729
|
+
expect(cookie_route do
|
730
|
+
request.script_name = '/foo'
|
731
|
+
cookies.set('foo', value: 'bar', httponly: true)
|
732
|
+
response['Set-Cookie'].lines.detect { |l| l.start_with? 'foo=' }
|
733
|
+
end).to include('HttpOnly')
|
734
|
+
end
|
735
|
+
|
736
|
+
it 'sets a cookie without HttpOnly' do
|
737
|
+
expect(cookie_route do
|
738
|
+
request.script_name = '/foo'
|
739
|
+
cookies.set('foo', value: 'bar', httponly: false)
|
740
|
+
response['Set-Cookie'].lines.detect { |l| l.start_with? 'foo=' }
|
741
|
+
end).not_to include('HttpOnly')
|
742
|
+
end
|
743
|
+
end
|
744
|
+
|
722
745
|
describe :select do
|
723
746
|
it 'removes entries from new hash' do
|
724
747
|
jar = cookies('foo=bar', 'bar=baz')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-contrib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Haase
|
@@ -57,7 +57,7 @@ authors:
|
|
57
57
|
autorequire:
|
58
58
|
bindir: bin
|
59
59
|
cert_chain: []
|
60
|
-
date:
|
60
|
+
date: 2017-03-04 00:00:00.000000000 Z
|
61
61
|
dependencies:
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: sinatra
|
@@ -65,28 +65,28 @@ dependencies:
|
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.0.0.
|
68
|
+
version: 2.0.0.rc1
|
69
69
|
type: :runtime
|
70
70
|
prerelease: false
|
71
71
|
version_requirements: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 2.0.0.
|
75
|
+
version: 2.0.0.rc1
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
77
|
name: mustermann
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.0.0
|
82
|
+
version: 1.0.0
|
83
83
|
type: :runtime
|
84
84
|
prerelease: false
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - '='
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.0.0
|
89
|
+
version: 1.0.0
|
90
90
|
- !ruby/object:Gem::Dependency
|
91
91
|
name: backports
|
92
92
|
requirement: !ruby/object:Gem::Requirement
|
@@ -121,34 +121,20 @@ dependencies:
|
|
121
121
|
- - "<"
|
122
122
|
- !ruby/object:Gem::Version
|
123
123
|
version: '3'
|
124
|
-
- !ruby/object:Gem::Dependency
|
125
|
-
name: rack-test
|
126
|
-
requirement: !ruby/object:Gem::Requirement
|
127
|
-
requirements:
|
128
|
-
- - ">="
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
version: '0'
|
131
|
-
type: :runtime
|
132
|
-
prerelease: false
|
133
|
-
version_requirements: !ruby/object:Gem::Requirement
|
134
|
-
requirements:
|
135
|
-
- - ">="
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
version: '0'
|
138
124
|
- !ruby/object:Gem::Dependency
|
139
125
|
name: rack-protection
|
140
126
|
requirement: !ruby/object:Gem::Requirement
|
141
127
|
requirements:
|
142
128
|
- - '='
|
143
129
|
- !ruby/object:Gem::Version
|
144
|
-
version: 2.0.0.
|
130
|
+
version: 2.0.0.rc1
|
145
131
|
type: :runtime
|
146
132
|
prerelease: false
|
147
133
|
version_requirements: !ruby/object:Gem::Requirement
|
148
134
|
requirements:
|
149
135
|
- - '='
|
150
136
|
- !ruby/object:Gem::Version
|
151
|
-
version: 2.0.0.
|
137
|
+
version: 2.0.0.rc1
|
152
138
|
- !ruby/object:Gem::Dependency
|
153
139
|
name: multi_json
|
154
140
|
requirement: !ruby/object:Gem::Requirement
|
@@ -415,6 +401,20 @@ dependencies:
|
|
415
401
|
- - "<"
|
416
402
|
- !ruby/object:Gem::Version
|
417
403
|
version: '11'
|
404
|
+
- !ruby/object:Gem::Dependency
|
405
|
+
name: rack-test
|
406
|
+
requirement: !ruby/object:Gem::Requirement
|
407
|
+
requirements:
|
408
|
+
- - ">="
|
409
|
+
- !ruby/object:Gem::Version
|
410
|
+
version: '0'
|
411
|
+
type: :development
|
412
|
+
prerelease: false
|
413
|
+
version_requirements: !ruby/object:Gem::Requirement
|
414
|
+
requirements:
|
415
|
+
- - ">="
|
416
|
+
- !ruby/object:Gem::Version
|
417
|
+
version: '0'
|
418
418
|
description: Collection of useful Sinatra extensions
|
419
419
|
email:
|
420
420
|
- konstantin.mailinglists@googlemail.com
|
@@ -587,4 +587,3 @@ signing_key:
|
|
587
587
|
specification_version: 4
|
588
588
|
summary: Collection of useful Sinatra extensions
|
589
589
|
test_files: []
|
590
|
-
has_rdoc:
|