rack-content-hash 0.0.1 → 0.0.2
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.
- data/.gitignore +1 -0
- data/.travis.yml +4 -0
- data/Gemfile.lock +2 -8
- data/Rakefile +5 -0
- data/lib/rack/contrib/content_hash.rb +4 -3
- data/rack-content-hash.gemspec +1 -0
- data/spec/rack/contrib/content_hash_spec.rb +14 -2
- data/spec/spec_helper.rb +0 -6
- metadata +20 -5
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg/
|
data/.travis.yml
ADDED
data/Gemfile.lock
CHANGED
@@ -25,11 +25,11 @@ GEM
|
|
25
25
|
rb-kqueue (>= 0.2)
|
26
26
|
lumberjack (1.0.4)
|
27
27
|
method_source (0.8.1)
|
28
|
-
multi_json (1.7.7)
|
29
28
|
pry (0.9.12.2)
|
30
29
|
coderay (~> 1.0.5)
|
31
30
|
method_source (~> 0.8)
|
32
31
|
slop (~> 3.4)
|
32
|
+
rake (10.0.4)
|
33
33
|
rb-fsevent (0.9.3)
|
34
34
|
rb-inotify (0.9.0)
|
35
35
|
ffi (>= 0.5.0)
|
@@ -43,10 +43,6 @@ GEM
|
|
43
43
|
rspec-expectations (2.14.0)
|
44
44
|
diff-lcs (>= 1.1.3, < 2.0)
|
45
45
|
rspec-mocks (2.14.1)
|
46
|
-
simplecov (0.7.1)
|
47
|
-
multi_json (~> 1.0)
|
48
|
-
simplecov-html (~> 0.7.1)
|
49
|
-
simplecov-html (0.7.1)
|
50
46
|
slop (3.4.5)
|
51
47
|
thor (0.18.1)
|
52
48
|
|
@@ -57,7 +53,5 @@ DEPENDENCIES
|
|
57
53
|
guard
|
58
54
|
guard-rspec
|
59
55
|
rack-content-hash!
|
60
|
-
|
61
|
-
rb-inotify (~> 0.9)
|
56
|
+
rake
|
62
57
|
rspec
|
63
|
-
simplecov
|
data/Rakefile
CHANGED
@@ -15,7 +15,7 @@ module Rack
|
|
15
15
|
# use Rack::Contrib::ContentHash, md5: true, sha1: true
|
16
16
|
#
|
17
17
|
class ContentHash
|
18
|
-
VERSION = '0.0.
|
18
|
+
VERSION = '0.0.2'
|
19
19
|
|
20
20
|
# Initialize the middleware, pass a Hash of algorithms in the second
|
21
21
|
# parameter. Ex: .new app, md5: true, sha1: false
|
@@ -28,8 +28,9 @@ module Rack
|
|
28
28
|
def call env
|
29
29
|
status, headers, body = @app.call env
|
30
30
|
|
31
|
-
|
32
|
-
headers['Content-
|
31
|
+
hashbody = body.join ""
|
32
|
+
headers['Content-MD5'] = Digest::MD5.hexdigest(hashbody) if @algo[:md5]
|
33
|
+
headers['Content-SHA1'] = Digest::SHA1.hexdigest(hashbody) if @algo[:sha1]
|
33
34
|
|
34
35
|
[status, headers, body]
|
35
36
|
end
|
data/rack-content-hash.gemspec
CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ['lib']
|
19
19
|
|
20
|
+
gem.add_development_dependency('rake')
|
20
21
|
gem.add_development_dependency('rspec')
|
21
22
|
gem.add_development_dependency('guard')
|
22
23
|
gem.add_development_dependency('guard-rspec')
|
@@ -1,7 +1,8 @@
|
|
1
|
+
require 'spec_helper'
|
1
2
|
|
2
3
|
describe Rack::Contrib::ContentHash do
|
3
|
-
let (:response) { [200, {'Location' => 'lolwhat'}, 'foobar-body'] }
|
4
|
-
let (:response_clone) { [200, {'Location' => 'lolwhat'}, 'foobar-body'] }
|
4
|
+
let (:response) { [200, {'Location' => 'lolwhat'}, ['foobar', '-body']] }
|
5
|
+
let (:response_clone) { [200, {'Location' => 'lolwhat'}, ['foobar', '-body']] }
|
5
6
|
describe "#initialize" do
|
6
7
|
it "accepts an app" do
|
7
8
|
expect { ware = Rack::Contrib::ContentHash.new nil }.not_to raise_error
|
@@ -40,6 +41,17 @@ describe Rack::Contrib::ContentHash do
|
|
40
41
|
ware = Rack::Contrib::ContentHash.new app
|
41
42
|
ware.call(env).should eq(response_clone)
|
42
43
|
end
|
44
|
+
|
45
|
+
it "joins the body internally, but returns the array" do
|
46
|
+
body = response[2]
|
47
|
+
body.stub(join: "foobar-body")
|
48
|
+
|
49
|
+
app = double(nil, call: response)
|
50
|
+
env = {}
|
51
|
+
ware = Rack::Contrib::ContentHash.new app
|
52
|
+
ware.call(env).should eq(response_clone)
|
53
|
+
body.should have_received(:join).with ""
|
54
|
+
end
|
43
55
|
end
|
44
56
|
|
45
57
|
context "MD5 hashing is enabled" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Graham Christensen
|
@@ -18,7 +18,7 @@ date: 2013-07-17 00:00:00 -05:00
|
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
21
|
+
name: rake
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
type: :development
|
32
32
|
version_requirements: *id001
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
34
|
+
name: rspec
|
35
35
|
prerelease: false
|
36
36
|
requirement: &id002 !ruby/object:Gem::Requirement
|
37
37
|
none: false
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
type: :development
|
45
45
|
version_requirements: *id002
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
|
-
name: guard
|
47
|
+
name: guard
|
48
48
|
prerelease: false
|
49
49
|
requirement: &id003 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
@@ -56,6 +56,19 @@ dependencies:
|
|
56
56
|
version: "0"
|
57
57
|
type: :development
|
58
58
|
version_requirements: *id003
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: guard-rspec
|
61
|
+
prerelease: false
|
62
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
version: "0"
|
70
|
+
type: :development
|
71
|
+
version_requirements: *id004
|
59
72
|
description:
|
60
73
|
email:
|
61
74
|
- info@zippykid.com
|
@@ -66,6 +79,8 @@ extensions: []
|
|
66
79
|
extra_rdoc_files: []
|
67
80
|
|
68
81
|
files:
|
82
|
+
- .gitignore
|
83
|
+
- .travis.yml
|
69
84
|
- Gemfile
|
70
85
|
- Gemfile.lock
|
71
86
|
- Guardfile
|