ibsciss-middleware 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/middleware/runner.rb +1 -2
- data/middleware.gemspec +1 -1
- data/spec/middleware/builder_spec.rb +3 -3
- data/spec/middleware/runner_spec.rb +9 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2885d91b0fe8a07086ee6e68f40194cce36747c9
|
4
|
+
data.tar.gz: d4b6288f7aec993be1640244c6b5d193b27e2ffe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e3fa59de3b97d5f38e0b8a4588a1e3babca6bdb885eecb6351ff960e1e485e7763e3a6803949e98448a7ddbc19e756af64f8f2a6abacfa1329c64f72679c6ae
|
7
|
+
data.tar.gz: 57e79ebd22365b169dff558b248fc50bd05b425b2ba609a9bc654b426111ae0822e78ce6dcc51c3cf5194a78c868cbe4518b7995ddd5aa5da6e952a82fb9c0cd
|
data/lib/middleware/runner.rb
CHANGED
@@ -57,8 +57,7 @@ module Middleware
|
|
57
57
|
# Make it a lambda which calls the item then forwards up
|
58
58
|
# the chain.
|
59
59
|
lambda do |env|
|
60
|
-
klass.call(env)
|
61
|
-
next_middleware.call(env)
|
60
|
+
next_middleware.call(klass.call(env))
|
62
61
|
end
|
63
62
|
else
|
64
63
|
raise "Invalid middleware, doesn't respond to `call`: #{klass.inspect}"
|
data/middleware.gemspec
CHANGED
@@ -7,7 +7,7 @@ describe Middleware::Builder do
|
|
7
7
|
# This returns a proc that can be used with the builder
|
8
8
|
# that simply appends data to an array in the env.
|
9
9
|
def appender_proc(data)
|
10
|
-
Proc.new { |env| env[:data] << data }
|
10
|
+
Proc.new { |obj| obj.tap { |env| env[:data] << data }}
|
11
11
|
end
|
12
12
|
|
13
13
|
context "initialized with a block" do
|
@@ -55,8 +55,8 @@ describe Middleware::Builder do
|
|
55
55
|
|
56
56
|
it "should be able to add multiple items" do
|
57
57
|
data = {}
|
58
|
-
proc1 = Proc.new { |env| env[:one] = true }
|
59
|
-
proc2 = Proc.new { |env| env[:two] = true }
|
58
|
+
proc1 = Proc.new { |env| env.tap { |obj| obj[:one] = true }}
|
59
|
+
proc2 = Proc.new { |env| env.tap { |obj| obj[:two] = true }}
|
60
60
|
|
61
61
|
instance.use proc1
|
62
62
|
instance.use proc2
|
@@ -48,6 +48,15 @@ describe Middleware::Runner do
|
|
48
48
|
expect(data).to eq ["A", "B"]
|
49
49
|
end
|
50
50
|
|
51
|
+
it "should let lambdas to change the given argument" do
|
52
|
+
data = []
|
53
|
+
a = lambda { |env| env + 1 }
|
54
|
+
b = lambda { |env| env + 2 }
|
55
|
+
|
56
|
+
instance = described_class.new([a, b])
|
57
|
+
expect(instance.call(1)).to eq 4
|
58
|
+
end
|
59
|
+
|
51
60
|
it "passes in arguments if given" do
|
52
61
|
a = Class.new do
|
53
62
|
def initialize(app, value)
|