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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2eb499fee5169418408b644b1a18045800e5d81
4
- data.tar.gz: c799c9fd1234decb3d112cc8adc6852fadb65744
3
+ metadata.gz: 6d991b914291bb371442ba8031c64548acd0ed2f
4
+ data.tar.gz: 87caaefbed03e5ad9b760fe37e9a855dd7b2f728
5
5
  SHA512:
6
- metadata.gz: 9dd1cbc8a9c822e433fd5f2e55940483f3ef0f157aa13a9671d13f6a3ac0ece73926923fa9da11f2757868548900970bbea751a9207b28c7c0ffcab28dc8e2ef
7
- data.tar.gz: b590b7b27c2c15cb4797dad68c8e86abd8b1052f21b7604d1ff1aefbe0f36c0e4d4245de6a9c61d9ffb004776ed2bde2d81ae835d0dbd0837f54923e0cef4f71
6
+ metadata.gz: 187c5077d865228cef464aab890399b53c2c9f299b0c91710f64d74342307ddefcb0c20e03cf72cedd831243535d199b327cb92245345cf6e5dff7a0caaa897d
7
+ data.tar.gz: 021b1a649f15e0eb78a92fe70b9a88e771103e6b4736baf62ba2da088b14c1dcc1fc87448b18e9c3dbf06c7dc2d44fb2a0f9d3f06cfbde7562dacef5502ce138
@@ -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
- $stderr.puts "loading config file '#{file}'" if logging?
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
@@ -179,7 +179,7 @@ module Sinatra
179
179
  private
180
180
 
181
181
  def content_blocks
182
- @content_blocks ||= Hash.new {|h,k| h[k] = [] }
182
+ @content_blocks ||= Hash.new { |h, k| h[k] = [] }
183
183
  end
184
184
  end
185
185
 
@@ -86,7 +86,7 @@ module Sinatra
86
86
  end
87
87
 
88
88
  def []=(key, value)
89
- @response.set_cookie key.to_s, @options.merge(:value => value)
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)
@@ -206,6 +206,8 @@ module Sinatra
206
206
  end
207
207
 
208
208
  def respond_to(*formats)
209
+ @respond_to ||= nil
210
+
209
211
  if formats.any?
210
212
  @respond_to ||= []
211
213
  @respond_to.concat formats
@@ -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]] }
@@ -1,6 +1,10 @@
1
1
  require 'sinatra/base'
2
- require 'rack/test'
3
2
  require 'rack'
3
+ begin
4
+ require 'rack/test'
5
+ rescue LoadError
6
+ abort 'Add rack-test to your Gemfile to use this module!'
7
+ end
4
8
  require 'forwardable'
5
9
 
6
10
  module Sinatra
@@ -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.beta2"
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
@@ -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.should == "bar"
28
- settings.something.should == 42
29
- settings.nested['a'].should == 1
30
- settings.nested[:a].should == 1
31
- settings.nested['b'].should == 2
32
- settings.nested[:b].should == 2
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.beta2
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: 2016-08-22 00:00:00.000000000 Z
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.beta2
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.beta2
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.beta2
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.beta2
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.beta2
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.beta2
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: