ibsciss-middleware 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +6 -6
- data/lib/middleware/builder.rb +6 -11
- data/middleware.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95c0eb4642aeaec6b97dc52005fa57572acb48ee
|
4
|
+
data.tar.gz: 1d1bccc64c0398f96a21bb42f14517fb9bf89ff8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24b5b1b08386e3e5a70d8a8f08d0ce888756105adc43f3d0bee08865e04f07f34141c94a321bd78e44e8f521b260c70eb4ccf2b22218cf00c6f30f94c5f40d32
|
7
|
+
data.tar.gz: 2a0258cd8b3d3e2a313cdd8e1f9be9549071a864781abf760c63a676316ce7146f694c5a0391f745403ac95d899070fa8af73b58ce29647abc4de79e0d7c8637
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -28,7 +28,7 @@ $ gem install ibsciss-middleware
|
|
28
28
|
Or, in your Gemfile:
|
29
29
|
|
30
30
|
```
|
31
|
-
gem 'ibsciss-middleware', '~> 0.
|
31
|
+
gem 'ibsciss-middleware', '~> 0.4.2'
|
32
32
|
```
|
33
33
|
|
34
34
|
Then, you can add it to your project:
|
@@ -169,8 +169,8 @@ lambdas:
|
|
169
169
|
|
170
170
|
```ruby
|
171
171
|
Middleware::Builder.new { |b|
|
172
|
-
b.use
|
173
|
-
b.use
|
172
|
+
b.use -> (env) { env + 3 }
|
173
|
+
b.use -> (env) { env * 2 }
|
174
174
|
}.call(1) #return 8
|
175
175
|
```
|
176
176
|
|
@@ -188,7 +188,7 @@ for building a stack of middlewares:
|
|
188
188
|
```ruby
|
189
189
|
stack = Middleware::Builder.new do |d|
|
190
190
|
d.use Trace
|
191
|
-
d.use
|
191
|
+
d.use ->(env) { puts "LAMBDA!" }
|
192
192
|
end
|
193
193
|
```
|
194
194
|
|
@@ -241,7 +241,7 @@ stack.insert_after(0, SomeOtherMiddleware)
|
|
241
241
|
#### Insert after each
|
242
242
|
|
243
243
|
```ruby
|
244
|
-
logger =
|
244
|
+
logger = -> (env) { p env }
|
245
245
|
|
246
246
|
# Insert the middleware (can be also a middleware object) after each existing middleware
|
247
247
|
stack.insert_after_each logger
|
@@ -250,7 +250,7 @@ stack.insert_after_each logger
|
|
250
250
|
#### Insert before each
|
251
251
|
|
252
252
|
```ruby
|
253
|
-
logger =
|
253
|
+
logger = -> (env) { p env }
|
254
254
|
|
255
255
|
# Insert the middleware (can be also a middleware object) before each existing middleware
|
256
256
|
stack.insert_before_each logger
|
data/lib/middleware/builder.rb
CHANGED
@@ -84,8 +84,7 @@ module Middleware
|
|
84
84
|
self
|
85
85
|
end
|
86
86
|
|
87
|
-
# Inserts a middleware at the given index or directly before the
|
88
|
-
# given middleware object.
|
87
|
+
# Inserts a middleware at the given index or directly before the given middleware object.
|
89
88
|
def insert(index, middleware, *args, &block)
|
90
89
|
index = self.index(index) unless index.is_a?(Integer)
|
91
90
|
fail "no such middleware to insert before: #{index.inspect}" unless index
|
@@ -115,16 +114,12 @@ module Middleware
|
|
115
114
|
end
|
116
115
|
end
|
117
116
|
|
118
|
-
# Replaces the given middleware object or index with the new
|
119
|
-
# middleware.
|
117
|
+
# Replaces the given middleware object or index with the new middleware.
|
120
118
|
def replace(index, middleware, *args, &block)
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
insert_before(index, middleware, *args, &block)
|
126
|
-
delete(index)
|
127
|
-
end
|
119
|
+
index = self.index index unless index.is_a? Integer
|
120
|
+
|
121
|
+
delete(index)
|
122
|
+
insert(index, middleware, *args, &block)
|
128
123
|
end
|
129
124
|
|
130
125
|
# Deletes the given middleware object or index
|
data/middleware.gemspec
CHANGED
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.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mitchell Hashimoto
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-07-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|