napa-ext 0.0.1 → 0.0.2

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: 315778e8ec7ba76708a3da0b0a9a9aea809215fc
4
- data.tar.gz: 4239a2d86967a8d4b94fde9dd3a4c3d97f979b3b
3
+ metadata.gz: 2971fd9c274c0b30b900d2aebb221bc23c253a87
4
+ data.tar.gz: eeea6facc5acb6f92e9cc12594e60c5627c73615
5
5
  SHA512:
6
- metadata.gz: 5ae83e312455c6e6faf5bc9a655e69866e038995f605357ab22ba901876875aeaf65352a365b0edd9b4e76bbb6be789986667b52562c8cc052ee57714c3eb9ae
7
- data.tar.gz: 5f9a38bb2550762539c8bb4712899fb656e0f1365ddeaac00c948683e4537786987ff07c0c43c0954aa58d2d7ad0f6cd413055a4525630f63ea49faba6bfb508
6
+ metadata.gz: 9c60d7adfbf07a840b1970619ef8f30d8e9cded4a91d3810fe23e37c6a6535c5b078618b316bb52582f981bc3da674aa9ffadc7df4ea5f213880ddf49bba6f04
7
+ data.tar.gz: 0c14bcb4c00cbcb7f013fe925feab6ce2797b7bcb5dc0d8a44abd445f5498cba7d7ada4d616611f1489b0c6a1c172d69d71c638923e614cc0ee4e15606fda98d
@@ -1,61 +1,65 @@
1
- class Poison
2
- MATCHER = %r{\A/poison/(?<pill>normal|nohandle|messy_contagion)\z}
1
+ module Napa
2
+ module Ext
3
+ class Poison
4
+ MATCHER = %r{\A/poison/(?<pill>normal|nohandle|messy_contagion)\z}
3
5
 
4
- def initialize app
5
- @app = app
6
- end
6
+ def initialize app
7
+ @app = app
8
+ end
7
9
 
8
- def call env
9
- pill = pill_from env
10
- if pill
11
- handler_for(pill).call env
12
- else
13
- app.call env
14
- end
15
- end
10
+ def call env
11
+ pill = pill_from env
12
+ if pill
13
+ handler_for(pill).call env
14
+ else
15
+ app.call env
16
+ end
17
+ end
16
18
 
17
- private
19
+ private
18
20
 
19
- attr_reader :app
21
+ attr_reader :app
20
22
 
21
- def pill_from env
22
- result = MATCHER.match env['PATH_INFO']
23
+ def pill_from env
24
+ result = MATCHER.match env['PATH_INFO']
23
25
 
24
- result[:pill] if result
25
- end
26
+ result[:pill] if result
27
+ end
26
28
 
27
- def handler_for pill
28
- Rack::Auth::Basic.new PoisonHandler.new(pill) do |username, password|
29
- ENV['POISON_CREDENTIAL'] &&
30
- [username, password] == ENV['POISON_CREDENTIAL'].split(':')
31
- end
32
- end
29
+ def handler_for pill
30
+ Rack::Auth::Basic.new PoisonHandler.new(pill) do |username, password|
31
+ ENV['POISON_CREDENTIAL'] &&
32
+ [username, password] == ENV['POISON_CREDENTIAL'].split(':')
33
+ end
34
+ end
33
35
 
34
- class PoisonHandler < Rack::Auth::Basic
35
- MESSY_CONTAGION_CMD = %(
36
- for i in
37
- `ps aux | grep unicorn | grep -v grep | tr -s ' ' | cut -d' ' -f2`;
38
- do kill -15 $i;
39
- done
40
- ).gsub(/\s+/, ' ')
36
+ class PoisonHandler < Rack::Auth::Basic
37
+ MESSY_CONTAGION_CMD = %(
38
+ for i in
39
+ `ps aux | grep unicorn | grep -v grep | tr -s ' ' | cut -d' ' -f2`;
40
+ do kill -15 $i;
41
+ done
42
+ ).gsub(/\s+/, ' ')
41
43
 
42
- def initialize pill
43
- @pill = pill.to_sym
44
- end
44
+ def initialize pill
45
+ @pill = pill.to_sym
46
+ end
45
47
 
46
- def call _
47
- case pill
48
- when :normal
49
- exit 0
50
- when :nohandle
51
- exit! 1
52
- when :messy_contagion
53
- system MESSY_CONTAGION_CMD
54
- end
55
- end
48
+ def call _
49
+ case pill
50
+ when :normal
51
+ exit 0
52
+ when :nohandle
53
+ exit! 1
54
+ when :messy_contagion
55
+ system MESSY_CONTAGION_CMD
56
+ end
57
+ end
56
58
 
57
- private
59
+ private
58
60
 
59
- attr_reader :pill
61
+ attr_reader :pill
62
+ end
63
+ end
60
64
  end
61
65
  end
@@ -1,5 +1,5 @@
1
1
  module Napa
2
2
  module Ext
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: napa-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - soloman