rack-conditional 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f509bccf9dac2aaca51f511ac524fba7974bcd3
4
- data.tar.gz: ca8cd8176dabdfd1e27a7bf10871a1c273e88029
3
+ metadata.gz: c5a4ba796db93c8600010d9401626fd22823082d
4
+ data.tar.gz: 3c503f7d08d4dcc6817a927bae98dfdb1306fbe0
5
5
  SHA512:
6
- metadata.gz: 404bd39699619d5efcff604488dd8c5543251b8a2c0074030d6a69ed61d72c925cef4ff939eaf8a40409f0404cc73fe6fb5d4c83f0aaa25016c1a52d18c3ad6a
7
- data.tar.gz: 853e6c5181c7c33e1d9a1b549da1644536ac3288e7df854f80d92ad20f0c032282ee5e7961f7238fd86daae2807ac3705d6dbc6c7d37760e85aea3744868ca3c
6
+ metadata.gz: d08fdd90c03461c43b0a470a2ec25cee70603a12eb608a58409c0e8a702f1a6a65ff3305efe633fd12c4a1df3fde281477bfbe0150169a596684cd2ce835b424
7
+ data.tar.gz: b110dd04768361eef93cf34aa00a8038d4f4c76806a6ec4c6d64f20afdeb3c42ea8acb63231799676cffef74b0537c8cb77ffdfa53f0dd3f6b5edf96c95f7fe4
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ Style/FrozenStringLiteralComment:
2
+ Enabled: false
data/Gemfile CHANGED
@@ -6,3 +6,14 @@ gemspec
6
6
  if Gem::Version.create(RUBY_VERSION) < Gem::Version.create('2.2.2')
7
7
  gem 'rack', '>= 1.6.4', '< 2.0.0'
8
8
  end
9
+
10
+ group :development do
11
+ if Gem::Version.create(RUBY_VERSION) < Gem::Version.create('1.9.2')
12
+ gem 'mime-types', '< 2.0'
13
+ elsif Gem::Version.create(RUBY_VERSION) < Gem::Version.create('2.0.0')
14
+ gem 'mime-types', '< 3.0'
15
+ end
16
+ if Gem::Version.create(RUBY_VERSION) < Gem::Version.create('1.9.3')
17
+ gem 'i18n', '< 0.7.0'
18
+ end
19
+ end
data/README.md CHANGED
@@ -38,11 +38,25 @@ Or
38
38
 
39
39
  ```ruby
40
40
  # Sinatra
41
+ require 'rack_conditional'
41
42
  class YourApp < Sinatra::Base
42
43
  use_if proc { |env| env['REMOTE_ADDR'] == '127.0.0.1' }, ShowExceptions
43
44
  end
44
45
  ```
45
46
 
47
+ Or
48
+
49
+ ```ruby
50
+ # Rails
51
+ # config/application.rb
52
+ require 'rack_conditional'
53
+ module YourApp
54
+ class Application < Rails::Application
55
+ config.middleware.use_if proc { |env| env['REMOTE_ADDR'] == '127.0.0.1' }, ShowExceptions
56
+ end
57
+ end
58
+ ```
59
+
46
60
  ## Contributing
47
61
 
48
62
  Bug reports and pull requests are welcome on GitHub at https://github.com/masiuchi/rack-conditional.
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "rack/conditional"
3
+ require 'bundler/setup'
4
+ require 'rack/conditional'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "rack/conditional"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start
data/bin/deploy.sh ADDED
@@ -0,0 +1,24 @@
1
+ #!/bin/bash
2
+
3
+ version_file=lib/rack/conditional/version.rb
4
+ rubygems_username=masiuchi
5
+ github_username="Masahiro Iuchi"
6
+ github_email=masahiro.iuchi+circleci@gmail.com
7
+
8
+ if [ -z "$CIRCLECI" ]; then
9
+ echo "This script runs only on CircleCI"
10
+ exit
11
+ fi
12
+
13
+ changed_files=`git diff --name-only HEAD~`
14
+ has_version_file=`echo $changed_files | grep $version_file`
15
+ if [ -z "$has_version_file" ]; then
16
+ echo "This commit does not change $version_file"
17
+ exit
18
+ fi
19
+
20
+ curl -u $rubygems_username:$RUBYGEMS_PASSWORD https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials; chmod 0600 ~/.gem/credentials
21
+ git config user.name $github_username
22
+ git config user.email $github_email
23
+ bundle exec rake build
24
+ bundle exec rake release
data/circle.yml CHANGED
@@ -1,3 +1,18 @@
1
1
  machine:
2
2
  ruby:
3
3
  version: 2.3.1
4
+
5
+ test:
6
+ pre:
7
+ - gem install reek rubocop
8
+ override:
9
+ - bundle exec rake
10
+ - rubocop
11
+ - reek ./lib/
12
+
13
+ # http://leko.jp/archives/871
14
+ deployment:
15
+ rubygems:
16
+ branch: master
17
+ commands:
18
+ - bash bin/deploy.sh
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Conditional
3
- VERSION = '0.2.1'.freeze
3
+ VERSION = '0.3.0'.freeze
4
4
  end
5
5
  end
@@ -1,2 +1,4 @@
1
1
  require 'rack/builder/conditional'
2
2
  require 'sinatra/base/conditional' if defined? Sinatra::Base
3
+ require 'rails/configuration/conditional' \
4
+ if defined? Rails::Configuration::MiddlewareStackProxy
@@ -0,0 +1,11 @@
1
+ require 'rack/conditionable'
2
+
3
+ module Rails
4
+ module Configuration
5
+ # Add "use_if" method to Rails.
6
+ # It's an alias of Rack::Conditional.
7
+ class MiddlewareStackProxy
8
+ include ::Rack::Conditionable
9
+ end
10
+ end
11
+ end
@@ -14,7 +14,9 @@ Gem::Specification.new do |spec|
14
14
  + 'This is a port of Plack::Middleware::Conditional.'
15
15
  spec.homepage = 'https://github.com/masiuchi/rack-conditional'
16
16
 
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^test/}) }
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^test/})
19
+ end
18
20
  spec.require_paths = ['lib']
19
21
 
20
22
  spec.required_ruby_version = '>= 1.8.7'
@@ -23,6 +25,7 @@ Gem::Specification.new do |spec|
23
25
 
24
26
  spec.add_development_dependency 'bundler', '~> 1.12'
25
27
  spec.add_development_dependency 'minitest', '~> 5.9'
28
+ spec.add_development_dependency 'rails'
26
29
  spec.add_development_dependency 'rake', '~> 10.0'
27
30
  spec.add_development_dependency 'sinatra', '~> 1.4'
28
31
  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.2.1
4
+ version: 0.3.0
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-04 00:00:00.000000000 Z
11
+ date: 2016-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.9'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -88,11 +102,13 @@ extensions: []
88
102
  extra_rdoc_files: []
89
103
  files:
90
104
  - ".gitignore"
105
+ - ".rubocop.yml"
91
106
  - ".travis.yml"
92
107
  - Gemfile
93
108
  - README.md
94
109
  - Rakefile
95
110
  - bin/console
111
+ - bin/deploy.sh
96
112
  - bin/setup
97
113
  - circle.yml
98
114
  - lib/rack/builder/conditional.rb
@@ -100,6 +116,7 @@ files:
100
116
  - lib/rack/conditional.rb
101
117
  - lib/rack/conditional/version.rb
102
118
  - lib/rack_conditional.rb
119
+ - lib/rails/configuration/conditional.rb
103
120
  - lib/sinatra/base/conditional.rb
104
121
  - rack-conditional.gemspec
105
122
  homepage: https://github.com/masiuchi/rack-conditional
@@ -121,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
138
  version: '0'
122
139
  requirements: []
123
140
  rubyforge_project:
124
- rubygems_version: 2.2.0
141
+ rubygems_version: 2.5.1
125
142
  signing_key:
126
143
  specification_version: 4
127
144
  summary: Conditional wrapper for Rack middleware.