Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Using symbol options as everywhere else in Rack.

  • Loading branch information...
commit 8f41f3ce79667a9103c9e7c88cd466a68c04c6cf 1 parent 8004fc1
@jakubpawlowicz authored
Showing with 15 additions and 15 deletions.
  1. +6 −6 lib/rack/deflater.rb
  2. +9 −9 test/spec_deflater.rb
View
12 lib/rack/deflater.rb
@@ -8,10 +8,10 @@ class Deflater
def initialize(app, options = {})
@app = app
- @min_content_length = options[:min_content_length] || options['min_content_length']
- @skip_if = options[:skip_if] || options['skip_if']
- @include = options[:include] || options['include']
- @exclude = options[:exclude] || options['exclude']
+ @min_length = options[:min_length]
+ @skip_if = options[:skip_if]
+ @include = options[:include]
+ @exclude = options[:exclude]
end
def call(env)
@@ -114,8 +114,8 @@ def should_deflate?(env, status, headers, body)
end
# Skip if response body is too short
- if @min_content_length &&
- @min_content_length > headers['Content-Length'].to_i
+ if @min_length &&
+ @min_length > headers['Content-Length'].to_i
return false
end
View
18 test/spec_deflater.rb
@@ -266,7 +266,7 @@ class << body; def each; yield("foo"); yield("bar"); end; end
'Content-Length' => body.length.to_s
},
'deflater_options' => {
- 'min_content_length' => body.length + 1
+ :min_length => body.length + 1
}
}
verify(200, 'Hello World!', { 'gzip' => nil }, options)
@@ -279,7 +279,7 @@ class << body; def each; yield("foo"); yield("bar"); end; end
'Content-Type' => 'text/plain'
},
'deflater_options' => {
- 'min_content_length' => body.length + 1
+ :min_length => body.length + 1
}
}
verify(200, 'Hello World!', { 'gzip' => nil }, options)
@@ -293,7 +293,7 @@ class << body; def each; yield("foo"); yield("bar"); end; end
'Content-Length' => body.length.to_s
},
'deflater_options' => {
- 'min_content_length' => body.length
+ :min_length => body.length
}
}
verify(200, 'Hello World!', 'gzip', options)
@@ -302,7 +302,7 @@ class << body; def each; yield("foo"); yield("bar"); end; end
should "process if path matches :include" do
options = {
'deflater_options' => {
- 'include' => /^\/$/
+ :include => /^\/$/
}
}
verify(200, 'Hello World!', 'gzip', options)
@@ -311,7 +311,7 @@ class << body; def each; yield("foo"); yield("bar"); end; end
should "do nothing if path do not match :include" do
options = {
'deflater_options' => {
- 'include' => /^\/foo\/bar$/
+ :include => /^\/foo\/bar$/
}
}
verify(200, 'Hello World!', { 'gzip' => nil }, options)
@@ -320,7 +320,7 @@ class << body; def each; yield("foo"); yield("bar"); end; end
should "do nothing if path matches :exclude" do
options = {
'deflater_options' => {
- 'exclude' => /^\/$/
+ :exclude => /^\/$/
}
}
verify(200, 'Hello World!', { 'gzip' => nil }, options)
@@ -329,7 +329,7 @@ class << body; def each; yield("foo"); yield("bar"); end; end
should "gzip response if path do not match :exclude" do
options = {
'deflater_options' => {
- 'exclude' => /^sth$/
+ :exclude => /^sth$/
}
}
verify(200, 'Hello World!', 'gzip', options)
@@ -338,7 +338,7 @@ class << body; def each; yield("foo"); yield("bar"); end; end
should "do nothing if :skip_if lambda evaluates to true" do
options = {
'deflater_options' => {
- 'skip_if' => lambda { |env, status, header, body| true }
+ :skip_if => lambda { |env, status, header, body| true }
}
}
verify(200, 'Hello World!', { 'gzip' => nil }, options)
@@ -347,7 +347,7 @@ class << body; def each; yield("foo"); yield("bar"); end; end
should "deflate response if :skip_if lambda evaluates to false" do
options = {
'deflater_options' => {
- 'skip_if' => lambda { |env, status, header, body| false }
+ :skip_if => lambda { |env, status, header, body| false }
}
}
verify(200, 'Hello World!', 'deflate', options)
Please sign in to comment.
Something went wrong with that request. Please try again.