underware 1.0.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/underware.rb +43 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4cc31a9731736d87c127839ea1523193657ebfef
4
+ data.tar.gz: 47404a848f30b4d49293daf3580fb48b9099813e
5
+ SHA512:
6
+ metadata.gz: 264e6b263c4bedf16e819aad071860a678c84f291bd83a12bfe6c9ddf4b2b9ab43f0df43fbe7789cc2982693b7dc5a3fd7818f3d63384cfec5c52f7a92605830
7
+ data.tar.gz: 973074309cf28cc21e0cbd41a51846f32b60288e144b535bebe443752f320698a6d49b54487b50b12a9ed7b45e55feb9728a6a01f69118e8db14a176ce78dcb2
data/lib/underware.rb ADDED
@@ -0,0 +1,43 @@
1
+
2
+ module Underware
3
+
4
+ # Base class for middleware. Basically, it
5
+ # just demonstrates the interface that you
6
+ # need to support.
7
+ class BaseMW
8
+ def call(*args)
9
+ raise NotImplementedError
10
+ end
11
+ end
12
+
13
+
14
+ class Folded < BaseMW
15
+ attr_reader :left, :right
16
+
17
+ def initialize(left, right)
18
+ @left = left
19
+ @right = right
20
+ end
21
+
22
+ def call(*args)
23
+ left.call(*args) do |*result|
24
+ right.call(*args)
25
+ end
26
+ end
27
+ end
28
+
29
+ def fold_underware(*args, &block)
30
+ return fold_underware(*args, block) if block_given?
31
+
32
+ args.reverse_each.inject do |folded, mw|
33
+ Folded.new(mw, folded)
34
+ end
35
+ end
36
+ module_function :fold_underware
37
+
38
+
39
+ class << self
40
+ alias_method :fold, :fold_underware
41
+ end
42
+
43
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: underware
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.alpha.1
5
+ platform: ruby
6
+ authors:
7
+ - Brian Lauber
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-28 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Middleware for Ruby
14
+ email: constructible.truth@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/underware.rb
20
+ homepage:
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">"
36
+ - !ruby/object:Gem::Version
37
+ version: 1.3.1
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.2.2
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Middleware for Ruby
44
+ test_files: []