middleman-as-middleware 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d1b62a5ba558c03a78a32950541ed71872d2b8a3
4
+ data.tar.gz: e1614fe57d4f0cf56f603e0b73974bec52719498
5
+ SHA512:
6
+ metadata.gz: 99c8df7d600e1526670123c9e1f65cac5992bb7c2c580e3689db9ceac570834f47633447b92024c86d45a309222b8c63cf08f12086cb3a48fe6767ab6ce2bf57
7
+ data.tar.gz: 5a02a0e8c7d1b1f65348c41a521d3e3623e9de11b58dd943d5746cd4c1bf88a7f1a468d1e262bd11790c3ae0aa8600d9542c4e9a7cbb5a6fd2330991e8e528a8
Binary file
Binary file
@@ -0,0 +1,12 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ _yardoc
7
+ coverage
8
+ doc/
9
+ Gemfile.lock
10
+ pkg
11
+ rdoc
12
+ spec/reports
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in middleman-as_middleware.gemspec
4
+ gemspec
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Jon Rowe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Middleman::AsMiddleware
2
+
3
+ A quick helper to use middleman as middleware (useful for api deployment scenarios)
4
+
5
+ ## Usage
6
+
7
+ TODO: Write usage instructions here
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'middleman-as_middleware'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install middleman-as_middleware
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ require 'middleman/as_middleware'
@@ -0,0 +1,20 @@
1
+ require "middleman/as_middleware/version"
2
+
3
+ module Middleman
4
+ class AsMiddleware
5
+
6
+ def initialize app, server = Middleman.server
7
+ @app, @server = app, server
8
+ end
9
+
10
+ def call env
11
+ status, headers, body = *(response = @server.call env.dup)
12
+ if status == 404
13
+ @app.call env
14
+ else
15
+ response
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ module Middleman
2
+ class AsMiddleware
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'middleman/as_middleware/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "middleman-as-middleware"
8
+ spec.version = Middleman::AsMiddleware::VERSION
9
+ spec.authors = ["Jon Rowe"]
10
+ spec.email = ["hello@jonrowe.co.uk"]
11
+ spec.description = %q{Simple hander to bind middleman as middleware}
12
+ spec.summary = %q{Simple hander to bind middleman as middleware}
13
+ spec.homepage = "https://github.com/JonRowe/middleman-asmiddleware"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.test_files = spec.files.grep(%r{^(spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_runtime_dependency "middleman"
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec"
25
+ end
@@ -0,0 +1,61 @@
1
+ require 'middleman/as_middleware'
2
+
3
+ describe 'mounting middleman as middleware' do
4
+ let(:response) { [200,{},['OK']] }
5
+
6
+ it 'takes a rack app and a middleman server' do
7
+ app, server = double, double
8
+ Middleman::AsMiddleware.new app, server
9
+ end
10
+
11
+ it 'defaults the server to being Middleman.server' do
12
+ app, server = double, double
13
+ Middleman.should receive(:server).and_return server
14
+ Middleman::AsMiddleware.new app
15
+ end
16
+
17
+ shared_examples_for "calls the middleman server" do
18
+ it 'calls the server' do
19
+ expect(server).to have_received(:call).with(env)
20
+ end
21
+
22
+ it 'calls the server with a duplicate of the environment' do
23
+ expect(server).to have_received(:call) do |provided_env|
24
+ expect(provided_env).to eq env
25
+ provided_env.delete(:key)
26
+ expect(provided_env).to_not eq env
27
+ end
28
+ end
29
+ end
30
+
31
+ context 'middleman can handle the request' do
32
+ let(:server) { double "middleman", call: response }
33
+ let(:app) { double "rack app" }
34
+ let(:env) { { key: :value, more: :data } }
35
+
36
+ let!(:middleware_response) { Middleman::AsMiddleware.new(app,server).call env }
37
+
38
+ it_should_behave_like "calls the middleman server"
39
+
40
+ it 'returns the middleman response' do
41
+ expect(middleware_response).to eq response
42
+ end
43
+ end
44
+
45
+ context 'middleman cant handle the request' do
46
+ let(:server) { double "middleman", call: [404,{},[]] }
47
+ let(:app) { double "rack app", call: response }
48
+ let(:env) { { key: :value, more: :data } }
49
+
50
+ let!(:middleware_response) { Middleman::AsMiddleware.new(app,server).call env }
51
+
52
+ it_should_behave_like "calls the middleman server"
53
+
54
+ it 'calls the app' do
55
+ expect(app).to have_received(:call).with(env)
56
+ end
57
+ it 'returns the apps response' do
58
+ expect(middleware_response).to eq response
59
+ end
60
+ end
61
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: middleman-as-middleware
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jon Rowe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDVjCCAj6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBRMQ4wDAYDVQQDDAVoZWxs
14
+ bzEXMBUGCgmSJomT8ixkARkWB2pvbnJvd2UxEjAQBgoJkiaJk/IsZAEZFgJjbzES
15
+ MBAGCgmSJomT8ixkARkWAnVrMB4XDTEzMDIwMzA4MTgwNloXDTE0MDIwMzA4MTgw
16
+ NlowUTEOMAwGA1UEAwwFaGVsbG8xFzAVBgoJkiaJk/IsZAEZFgdqb25yb3dlMRIw
17
+ EAYKCZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJ1azCCASIwDQYJKoZI
18
+ hvcNAQEBBQADggEPADCCAQoCggEBAMhs6ng/SRrYfG7RtQx8liJTZs8tpz7PBnlH
19
+ qyOwuU0weJc7nh6C9C8LGyJzpkbjJJo1rfTMg7huDyL14Py82dfMDomApif8jNNI
20
+ 8KtviAgB1DrWq0fCDLtu/M77+yuVV3OhDdrAFaBkT/euvdJ8cAKrLxbJ+klgvrcB
21
+ FK+c4PUV3/zBKghe0l7FuDhyQCsuLNDbWyFvDS97tPjeN6yWuszwg22vZMDdsuzN
22
+ Cj3M4LLSkbrt+AOUcysEJxI4t6uv2U1bRzHsDfAF0RI/Q7OMtUr+Dtz/2YJ47KKs
23
+ 51ZRjLLGHd10XrIfFSfGyJj1dMbDgLsEBj1sFH4e6dy7gau8TaUCAwEAAaM5MDcw
24
+ CQYDVR0TBAIwADAdBgNVHQ4EFgQULu5JH2g7RAjoXaZt+fbrfNDI9IkwCwYDVR0P
25
+ BAQDAgSwMA0GCSqGSIb3DQEBBQUAA4IBAQAf5A4kB769DPKGjPZ++v42FwVi7X7v
26
+ RpufPs6R4YHyzHXaJmAqnhleZhVJijBgsdb2SigNRbg+IK8XYHg7jkonMgO8OS3D
27
+ C6w8VB5bI0PqyDOwCGcQkYHYlZZWCghAyBTSBowHAekMb9V3QjJtJ8XkizjshETO
28
+ ZCVI2AObjlJi8I10aK2tSo9sv2riCKZ92BVSM13zYWn+C/eCP/m9BDiw37UQtuQq
29
+ 2feWfO4gCNmvfFjULOAYHq9JHEjN5SLSXvj5HdSnDcCyIfJKn5Ya3JahWQaWIsXf
30
+ /NPE/mB57TOwj+d7XUa2NC4HUadF8R51IYEcIB0PpIEzJlKtfXFcOZxO
31
+ -----END CERTIFICATE-----
32
+ date: 2013-07-17 00:00:00.000000000 Z
33
+ dependencies:
34
+ - !ruby/object:Gem::Dependency
35
+ name: middleman
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ type: :runtime
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ - !ruby/object:Gem::Dependency
49
+ name: bundler
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ type: :development
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ - !ruby/object:Gem::Dependency
77
+ name: rspec
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ description: Simple hander to bind middleman as middleware
91
+ email:
92
+ - hello@jonrowe.co.uk
93
+ executables: []
94
+ extensions: []
95
+ extra_rdoc_files: []
96
+ files:
97
+ - .gitignore
98
+ - Gemfile
99
+ - LICENSE.txt
100
+ - README.md
101
+ - Rakefile
102
+ - lib/middleman/as-middleware.rb
103
+ - lib/middleman/as_middleware.rb
104
+ - lib/middleman/as_middleware/version.rb
105
+ - middleman-as-middleware.gemspec
106
+ - spec/middleman/as_middleware_spec.rb
107
+ homepage: https://github.com/JonRowe/middleman-asmiddleware
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.0.3
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Simple hander to bind middleman as middleware
131
+ test_files:
132
+ - spec/middleman/as_middleware_spec.rb
@@ -0,0 +1,3 @@
1
+ ?a2��b��c�^: h��"�g�T�q��{�GES��7:�m~�������f�{&E*�����_�G-�qw���(xx T�Fn6P��$����R���
2
+ �{��|�)� QRw��<����n2�=�K��+�O�S��Ç�3㕟��o�;�v�
3
+ ���O��&���6��뫟H�֪��?&���2��%ӌh�V�Cꈡ�A:���Q��N���x��������.��H�QΈ