rack-conditional 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 726281eba451798400ec8723b68c5d685be956d0
4
+ data.tar.gz: 89e8a50b81eec4f7d5b3c7289d9b962e68f63e60
5
+ SHA512:
6
+ metadata.gz: 53a0679ab0d7a2264ff1b875814beaaedb2bad153f479cd72295a0e91d11385330bfa779a5766a695092ca11c9eb9ee98f90bb12a5130445798a5170372fdd08
7
+ data.tar.gz: 96c06bf04bf114902d38d2ab8659b69b0f923b9bc109f341d761cff8ecfcd09b071dfc375ab6e513a7cbc2bfa6f5272c8f3353ac13f7442f53ff039ad2cf9a62
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 2.2.0
5
+ - 2.1.0
6
+ - 2.0.0
7
+ - 1.9.3
8
+ - 1.8.7
9
+ before_install:
10
+ - gem update bundler
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rack-conditional.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # Rack::Conditional
2
+ Conditional wrapper for Rack middleware. This is a port of [Plack::Middleware::Conditional](https://metacpan.org/pod/Plack::Middleware::Conditional).
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ ```ruby
9
+ gem 'rack-conditional'
10
+ ```
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install rack-conditional
19
+
20
+ ## Usage
21
+
22
+
23
+ ```ruby
24
+ # config.ru
25
+ require 'rack_conditional'
26
+ use_if proc { |env| env['REMOTE_ADDR'] == '127.0.0.1' }, ShowExceptions
27
+ ```
28
+
29
+ Or
30
+
31
+ ```ruby
32
+ # config.ru
33
+ require 'rack_conditional'
34
+ use Rack::Conditional, proc { |env| env['REMOTE_ADDR'] == '127.0.0.1' }, ShowExceptions
35
+ ```
36
+
37
+ ## Contributing
38
+
39
+ Bug reports and pull requests are welcome on GitHub at https://github.com/masiuchi/rack-conditional.
40
+
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ # coding: UTF-8
2
+
3
+ require 'rake/testtask'
4
+
5
+ task 'default' => [:test]
6
+
7
+ Rake::TestTask.new do |test|
8
+ test.libs << 'test'
9
+ test.test_files = Dir['test/**/spec_*.rb']
10
+ test.verbose = true
11
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rack/conditional"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/circle.yml ADDED
@@ -0,0 +1,3 @@
1
+ machine:
2
+ ruby:
3
+ version: 2.3.1
@@ -0,0 +1,11 @@
1
+ require 'rack/conditional'
2
+
3
+ module Rack
4
+ # Add "use_if" method to Rack::Builder.
5
+ # It's an alias of Rack::Conditional.
6
+ class Builder
7
+ def use_if(condition, middleware, *args, &block)
8
+ use Rack::Conditional, condition, middleware, *args, &block
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ module Rack
2
+ class Conditional
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ require 'rack/conditional/version'
2
+
3
+ module Rack
4
+ # Conditional wrapper for Rack middleware.
5
+ class Conditional
6
+ def initialize(app, condition, middleware, *args, &block)
7
+ @app = app
8
+ @condition = condition
9
+ @middleware = middleware.new(app, *args, &block)
10
+ end
11
+
12
+ def call(env)
13
+ app = @condition.call(env) ? @middleware : @app
14
+ app.call(env)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1 @@
1
+ require 'rack/builder/conditional'
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rack/conditional/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'rack-conditional'
8
+ spec.version = Rack::Conditional::VERSION
9
+ spec.authors = ['Masahiro Iuchi']
10
+ spec.email = ['masahiro.iuchi@gmail.com']
11
+
12
+ spec.summary = 'Conditional wrapper for Rack middleware.'
13
+ spec.description = 'Conditional wrapper for Rack middleware. '\
14
+ + 'This is a port of Plack::Middleware::Conditional.'
15
+ spec.homepage = 'https://github.com/masiuchi/rack-conditional'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^test/}) }
18
+ spec.require_paths = ['lib']
19
+
20
+ if RUBY_VERSION >= '2.2.2'
21
+ spec.add_dependency 'rack', '~> 0'
22
+ else
23
+ spec.add_dependency 'rack', '~> 1.6.4'
24
+ end
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.12'
27
+ spec.add_development_dependency 'minitest', '~> 0'
28
+ spec.add_development_dependency 'rake', '~> 10.0'
29
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-conditional
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Masahiro Iuchi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: Conditional wrapper for Rack middleware. This is a port of Plack::Middleware::Conditional.
70
+ email:
71
+ - masahiro.iuchi@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - Gemfile
79
+ - README.md
80
+ - Rakefile
81
+ - bin/console
82
+ - bin/setup
83
+ - circle.yml
84
+ - lib/rack/builder/conditional.rb
85
+ - lib/rack/conditional.rb
86
+ - lib/rack/conditional/version.rb
87
+ - lib/rack_conditional.rb
88
+ - rack-conditional.gemspec
89
+ homepage: https://github.com/masiuchi/rack-conditional
90
+ licenses: []
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.5.1
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Conditional wrapper for Rack middleware.
112
+ test_files: []