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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19c42633d1c333e95219851b18162d3dd8962401
4
- data.tar.gz: 862b2a2464ff93be9ce68f9cc6c48ba215d610cf
3
+ metadata.gz: 2885d91b0fe8a07086ee6e68f40194cce36747c9
4
+ data.tar.gz: d4b6288f7aec993be1640244c6b5d193b27e2ffe
5
5
  SHA512:
6
- metadata.gz: 8b1a8954e9053c362c10b8fe3ad606cdb22a294e8fcbfb8588d37ddeb589763d54af33d0c41e19eb529e6f3ef92840df38f58ec893816c94280bfbe84e37a215
7
- data.tar.gz: b4a05f87ea90f0c1d2051df9057278ad2c54a0ff4a86f0eee57fdcd41535e09992b5ef0cb421879c011a95af015b926f4c8fcc4627a7d0bbb8b33a360c116dd2
6
+ metadata.gz: 8e3fa59de3b97d5f38e0b8a4588a1e3babca6bdb885eecb6351ff960e1e485e7763e3a6803949e98448a7ddbc19e756af64f8f2a6abacfa1329c64f72679c6ae
7
+ data.tar.gz: 57e79ebd22365b169dff558b248fc50bd05b425b2ba609a9bc654b426111ae0822e78ce6dcc51c3cf5194a78c868cbe4518b7995ddd5aa5da6e952a82fb9c0cd
@@ -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}"
@@ -18,5 +18,5 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
19
  gem.name = "ibsciss-middleware"
20
20
  gem.require_paths = ["lib"]
21
- gem.version = '0.3.0'
21
+ gem.version = '0.3.1'
22
22
  end
@@ -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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibsciss-middleware
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mitchell Hashimoto