rack-conditional 0.1.2 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf0565f9bde7c55065bf07130d00df6901b52983
4
- data.tar.gz: bf700b66ee2dd2597f09b85a202dec5faf238a03
3
+ metadata.gz: 9f509bccf9dac2aaca51f511ac524fba7974bcd3
4
+ data.tar.gz: ca8cd8176dabdfd1e27a7bf10871a1c273e88029
5
5
  SHA512:
6
- metadata.gz: 6a7b4418d71d23a9a59003617812d8edc843bb23dcd564b6119c713338be18d19cc69d825af6c6125d389e66fc345e9d1bf6432b89e1fa8951e8c88258bc8a7b
7
- data.tar.gz: 6ca7e8025753070e26463149492588a7d574bcf59763a81f5da4486f1f518a86159569c02b7b620fd1fd7da7b26b2dbed347798e7357acb29375c24673ea2890
6
+ metadata.gz: 404bd39699619d5efcff604488dd8c5543251b8a2c0074030d6a69ed61d72c925cef4ff939eaf8a40409f0404cc73fe6fb5d4c83f0aaa25016c1a52d18c3ad6a
7
+ data.tar.gz: 853e6c5181c7c33e1d9a1b549da1644536ac3288e7df854f80d92ad20f0c032282ee5e7961f7238fd86daae2807ac3705d6dbc6c7d37760e85aea3744868ca3c
data/README.md CHANGED
@@ -34,6 +34,15 @@ require 'rack_conditional'
34
34
  use Rack::Conditional, proc { |env| env['REMOTE_ADDR'] == '127.0.0.1' }, ShowExceptions
35
35
  ```
36
36
 
37
+ Or
38
+
39
+ ```ruby
40
+ # Sinatra
41
+ class YourApp < Sinatra::Base
42
+ use_if proc { |env| env['REMOTE_ADDR'] == '127.0.0.1' }, ShowExceptions
43
+ end
44
+ ```
45
+
37
46
  ## Contributing
38
47
 
39
48
  Bug reports and pull requests are welcome on GitHub at https://github.com/masiuchi/rack-conditional.
@@ -1,11 +1,9 @@
1
- require 'rack/conditional'
1
+ require 'rack/conditionable'
2
2
 
3
3
  module Rack
4
4
  # Add "use_if" method to Rack::Builder.
5
5
  # It's an alias of Rack::Conditional.
6
6
  class Builder
7
- def use_if(condition, middleware, *args, &block)
8
- use Rack::Conditional, condition, middleware, *args, &block
9
- end
7
+ include Conditionable
10
8
  end
11
9
  end
@@ -0,0 +1,10 @@
1
+ require 'rack/conditional'
2
+
3
+ module Rack
4
+ # Add "use_if" method by include.
5
+ module Conditionable
6
+ def use_if(condition, middleware, *args, &block)
7
+ use Rack::Conditional, condition, middleware, *args, &block
8
+ end
9
+ end
10
+ end
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Conditional
3
- VERSION = "0.1.2"
3
+ VERSION = '0.2.1'.freeze
4
4
  end
5
5
  end
@@ -1 +1,2 @@
1
1
  require 'rack/builder/conditional'
2
+ require 'sinatra/base/conditional' if defined? Sinatra::Base
@@ -0,0 +1,11 @@
1
+ require 'rack/conditionable'
2
+
3
+ module Sinatra
4
+ # Add "use_if" method to Sinatra::Base.
5
+ # It's an alias of Rack::Conditional.
6
+ class Base
7
+ class << self
8
+ include Rack::Conditionable
9
+ end
10
+ end
11
+ end
@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'bundler', '~> 1.12'
25
25
  spec.add_development_dependency 'minitest', '~> 5.9'
26
26
  spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'sinatra', '~> 1.4'
27
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-conditional
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Iuchi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-03 00:00:00.000000000 Z
11
+ date: 2016-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sinatra
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.4'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.4'
69
83
  description: Conditional wrapper for Rack middleware. This is a port of Plack::Middleware::Conditional.
70
84
  email:
71
85
  - masahiro.iuchi@gmail.com
@@ -82,9 +96,11 @@ files:
82
96
  - bin/setup
83
97
  - circle.yml
84
98
  - lib/rack/builder/conditional.rb
99
+ - lib/rack/conditionable.rb
85
100
  - lib/rack/conditional.rb
86
101
  - lib/rack/conditional/version.rb
87
102
  - lib/rack_conditional.rb
103
+ - lib/sinatra/base/conditional.rb
88
104
  - rack-conditional.gemspec
89
105
  homepage: https://github.com/masiuchi/rack-conditional
90
106
  licenses: []