bourbon_house 0.1.3 → 0.1.4

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: 36758996945655b54ce39067905c5649df329d73
4
- data.tar.gz: 0af6632f318cccfc7136bd329e94fadd9b2479db
3
+ metadata.gz: a92e2bb9896fe26670a093d0df925c702661d650
4
+ data.tar.gz: 8c62a7013e7f918c5123d06db398af99055a857c
5
5
  SHA512:
6
- metadata.gz: f42ee701a847851fca1d92ff54f58183d828d03b76851a7784d9e31934b4274d88736095b0bf354c76b69f4864275cc790f4d89bd467b54b43dc298c55d3a677
7
- data.tar.gz: 39b97b50c223748cb4871a13a79a7217d5d26099db849600404e2e7b872b3573cf4bff85ed9a7e9ac30cfeb366f53ff1bf2fee6669fb54ff08716927f2503751
6
+ metadata.gz: 277f8ff2d5565771479b0728673b97c82d0737113f7ecc16fe2f628e5ab184857662a1bd963e2cc353134663025eccd695271f16bf11637a1040c989803746bc
7
+ data.tar.gz: 826f7b25f3bca448a1a0cee5c1f8a50bed8825417b12d1ea2ca8676cb8d409dffa3fa9bf855e6ee4db86e16eaed802043552f86e34fe592388182a0dfa2cf5df
data/.travis.yml CHANGED
@@ -1,6 +1,8 @@
1
1
  sudo: false
2
2
  language: ruby
3
- before_install: gem install bundler
3
+ before_install:
4
+ - gem update --system
5
+ - gem install bundler
4
6
  rvm:
5
7
  - 2.3.3
6
8
  - 2.4.0
data/README.md CHANGED
@@ -36,7 +36,41 @@ Or install it yourself as:
36
36
 
37
37
  ## Usage
38
38
 
39
- TODO: Write usage instructions here
39
+ ### Use with bourbon_house only
40
+
41
+ ```sh
42
+ $ bourbon_house
43
+ [2017-02-21 19:54:06] INFO WEBrick 1.3.1
44
+ [2017-02-21 19:54:06] INFO ruby 2.5.0 (2017-01-13) [x86_64-darwin16]
45
+ [2017-02-21 19:54:06] INFO WEBrick::HTTPServer#start: pid=35483 port=9292
46
+
47
+ $ curl localhost:9292
48
+ やあ (´・ω・`)
49
+ ようこそ、バーボンハウスへ。
50
+ このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
51
+
52
+ うん、「また」なんだ。済まない。
53
+ 仏の顔もって言うしね、謝って許してもらおうとも思っていない。
54
+
55
+ でも、このレスポンスを見たとき、君は、きっと言葉では言い表せない
56
+ 「ときめき」みたいなものを感じてくれたと思う。
57
+ 殺伐とした世の中で、そういう気持ちを忘れないで欲しい
58
+ そう思って、このライブラリを作ったんだ。
59
+
60
+ じゃあ、注文を聞こうか。
61
+ ```
62
+
63
+ ### Use with Rails
64
+
65
+ ```sh
66
+ $ echo "gem 'bourbon_house', group: :development" >> Gemfile
67
+ $ bundle install
68
+ $ bin/rails g bourbon_house:config
69
+ create config/initializers/bourbon_house_config.rb
70
+ # Edit bourbon_house_config.rb
71
+ $ bin/rails s
72
+ # Let's bourbon!
73
+ ```
40
74
 
41
75
  ## Development
42
76
 
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency "rack", "~> 2.0"
27
27
 
28
28
  spec.add_development_dependency "bundler", "~> 1.13"
29
- spec.add_development_dependency "otacop", "~> 0.4"
29
+ spec.add_development_dependency "otacop", "~> 0.5"
30
30
  spec.add_development_dependency "rake", "~> 10.0"
31
31
  spec.add_development_dependency "test-unit", "~> 3.0"
32
32
  end
@@ -5,6 +5,8 @@ module BourbonHouse
5
5
  include ActiveSupport::Configurable
6
6
 
7
7
  config.instance_eval do
8
+ self.enabled = true
8
9
  self.force = false
10
+ self.allow_methods = %i(get)
9
11
  end
10
12
  end
@@ -6,15 +6,32 @@ module BourbonHouse
6
6
  end
7
7
 
8
8
  def call(env)
9
- bh_app = BourbonHouse::Application.new
9
+ return @app.call(env) unless enabled?
10
10
 
11
- return bh_app.call(env) if BourbonHouse.config.force
11
+ return bourbon_house_app.call(env) if force?
12
12
 
13
- if rand(10).zero?
14
- bh_app.call(env)
13
+ if rand(10).zero? && allow_method?(env["REQUEST_METHOD"])
14
+ bourbon_house_app.call(env)
15
15
  else
16
16
  @app.call(env)
17
17
  end
18
18
  end
19
+
20
+ private
21
+ def allow_method?(method)
22
+ BourbonHouse.config.allow_methods.include?(method.downcase.to_sym)
23
+ end
24
+
25
+ def bourbon_house_app
26
+ BourbonHouse::Application.new
27
+ end
28
+
29
+ def enabled?
30
+ !!BourbonHouse.config.enabled
31
+ end
32
+
33
+ def force?
34
+ !!BourbonHouse.config.force
35
+ end
19
36
  end
20
37
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module BourbonHouse
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
@@ -1,4 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  BourbonHouse.configure do |config|
3
+ # config.enabled = true
3
4
  # config.force = false
5
+ # config.allow_methods = %i(get)
4
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bourbon_house
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryoji Yoshioka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-18 00:00:00.000000000 Z
11
+ date: 2017-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.4'
61
+ version: '0.5'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.4'
68
+ version: '0.5'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement