napa-ext 0.0.1

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: 315778e8ec7ba76708a3da0b0a9a9aea809215fc
4
+ data.tar.gz: 4239a2d86967a8d4b94fde9dd3a4c3d97f979b3b
5
+ SHA512:
6
+ metadata.gz: 5ae83e312455c6e6faf5bc9a655e69866e038995f605357ab22ba901876875aeaf65352a365b0edd9b4e76bbb6be789986667b52562c8cc052ee57714c3eb9ae
7
+ data.tar.gz: 5f9a38bb2550762539c8bb4712899fb656e0f1365ddeaac00c948683e4537786987ff07c0c43c0954aa58d2d7ad0f6cd413055a4525630f63ea49faba6bfb508
data/.gitignore ADDED
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
35
+ .ruby-version
data/.rubocop.yml ADDED
@@ -0,0 +1,26 @@
1
+ AllCops:
2
+ Include:
3
+ - '**/Rakefile'
4
+ - '**/*.gemspec'
5
+
6
+ Style/Documentation:
7
+ Enabled: false
8
+
9
+ Style/Blocks:
10
+ Enabled: true
11
+ Exclude:
12
+ - spec/**/*_spec.rb
13
+
14
+ Style/WordArray:
15
+ Enabled: true
16
+ Exclude:
17
+ - spec/**/*_spec.rb
18
+
19
+ Style/Encoding:
20
+ Enabled: false
21
+
22
+ Style/MethodDefParentheses:
23
+ Enabled: false
24
+
25
+ Metrics/LineLength:
26
+ Max: 120
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in napa-ext.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,50 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ napa-ext (0.0.1)
5
+ rack (~> 1.5)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.0.0)
11
+ astrolabe (1.3.0)
12
+ parser (>= 2.2.0.pre.3, < 3.0)
13
+ diff-lcs (1.2.5)
14
+ parser (2.2.0.pre.8)
15
+ ast (>= 1.1, < 3.0)
16
+ slop (~> 3.4, >= 3.4.5)
17
+ powerpack (0.0.9)
18
+ rack (1.5.2)
19
+ rainbow (2.0.0)
20
+ rake (10.4.0)
21
+ rspec (3.1.0)
22
+ rspec-core (~> 3.1.0)
23
+ rspec-expectations (~> 3.1.0)
24
+ rspec-mocks (~> 3.1.0)
25
+ rspec-core (3.1.7)
26
+ rspec-support (~> 3.1.0)
27
+ rspec-expectations (3.1.2)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.1.0)
30
+ rspec-mocks (3.1.3)
31
+ rspec-support (~> 3.1.0)
32
+ rspec-support (3.1.2)
33
+ rubocop (0.27.1)
34
+ astrolabe (~> 1.3)
35
+ parser (>= 2.2.0.pre.7, < 3.0)
36
+ powerpack (~> 0.0.6)
37
+ rainbow (>= 1.99.1, < 3.0)
38
+ ruby-progressbar (~> 1.4)
39
+ ruby-progressbar (1.7.0)
40
+ slop (3.6.0)
41
+
42
+ PLATFORMS
43
+ ruby
44
+
45
+ DEPENDENCIES
46
+ bundler (~> 1.7)
47
+ napa-ext!
48
+ rake (~> 10.0)
49
+ rspec (~> 3.1)
50
+ rubocop (~> 0.27)
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Soloman Weng
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 soloman
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ napa-ext
2
+ ========
3
+
4
+ Napa Middleware Extensions
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new :spec do |spec|
6
+ spec.rspec_opts = '--format documentation --color'
7
+ end
8
+
9
+ RuboCop::RakeTask.new
@@ -0,0 +1,61 @@
1
+ class Poison
2
+ MATCHER = %r{\A/poison/(?<pill>normal|nohandle|messy_contagion)\z}
3
+
4
+ def initialize app
5
+ @app = app
6
+ end
7
+
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
16
+
17
+ private
18
+
19
+ attr_reader :app
20
+
21
+ def pill_from env
22
+ result = MATCHER.match env['PATH_INFO']
23
+
24
+ result[:pill] if result
25
+ end
26
+
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
33
+
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+/, ' ')
41
+
42
+ def initialize pill
43
+ @pill = pill.to_sym
44
+ end
45
+
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
56
+
57
+ private
58
+
59
+ attr_reader :pill
60
+ end
61
+ end
@@ -0,0 +1,5 @@
1
+ module Napa
2
+ module Ext
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
data/lib/napa/ext.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'napa/ext/version'
2
+ require 'napa/ext/poison'
data/napa-ext.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'napa/ext/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'napa-ext'
8
+ spec.version = Napa::Ext::VERSION
9
+ spec.authors = ['soloman']
10
+ spec.email = ['soloman1124@gmail.com']
11
+ spec.summary = 'Some additional Napa middlewares'
12
+ spec.description = 'Some additional Napa middlewares'
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_runtime_dependency 'rack', '~> 1.5'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.7'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rspec', '~> 3.1'
26
+ spec.add_development_dependency 'rubocop', '~> 0.27'
27
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: napa-ext
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - soloman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-30 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: '1.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
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.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.27'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.27'
83
+ description: Some additional Napa middlewares
84
+ email:
85
+ - soloman1124@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rubocop.yml"
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENSE
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - lib/napa/ext.rb
99
+ - lib/napa/ext/poison.rb
100
+ - lib/napa/ext/version.rb
101
+ - napa-ext.gemspec
102
+ homepage: ''
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.4.2
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Some additional Napa middlewares
126
+ test_files: []