quiet_routes 0.0.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 +7 -0
- data/.gitignore +23 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +32 -0
- data/Rakefile +10 -0
- data/lib/quiet_routes/version.rb +3 -0
- data/lib/quiet_routes.rb +31 -0
- data/quiet_routes.gemspec +23 -0
- data/test/test_quiet_routes.rb +108 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e2d81fd857f34eab10ccf08cd7bcd04daeec3690
|
4
|
+
data.tar.gz: fc996cb6c05bac6debabdde2908e9c23fbff0231
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2ebb852fc965e46e9f87f41e995c11fec83302f6584c365813f3fcefca02e542f44e5c9f173ad8fcef1ae0805cdd21cc214f0c6a4446885c83400aabd896cd6d
|
7
|
+
data.tar.gz: dd17a21ed9287907ca22a69323ab8e0d9dffd8266ff1030875a51f076e54f6b8223f77a9dd516564cb339860d821a4a57bd51319ef9c3a0eabf1f21d5ce30506
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
log/
|
12
|
+
lib/bundler/man
|
13
|
+
pkg
|
14
|
+
rdoc
|
15
|
+
spec/reports
|
16
|
+
test/tmp
|
17
|
+
test/version_tmp
|
18
|
+
tmp
|
19
|
+
*.bundle
|
20
|
+
*.so
|
21
|
+
*.o
|
22
|
+
*.a
|
23
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Yusuke Tanaka
|
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,32 @@
|
|
1
|
+
# Quiet Assets
|
2
|
+
[](http://travis-ci.org/evrone/quiet_assets)
|
3
|
+
|
4
|
+
Quiet Routes has been made in referrence to [quiet_assets](https://github.com/evrone/quiet_assets).
|
5
|
+
This is turns off the Rails particular log.
|
6
|
+
For example, this can suppress the access log of ping target from the load balancer.
|
7
|
+
|
8
|
+
Support Ruby on Rails = 4.1
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
To install, add this line to development group in your Gemfile:
|
13
|
+
|
14
|
+
gem 'quiet_routes'
|
15
|
+
|
16
|
+
Then, from the command line, run:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
After installation, place the following in your `config/application.rb` file:
|
23
|
+
|
24
|
+
config.quiet_assets = %w(pass_to_silent_route_list)
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
1. Fork it ( https://github.com/yusuket/quiet_routes/fork )
|
29
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
30
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
31
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
32
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/lib/quiet_routes.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "quiet_routes/version"
|
2
|
+
require "logger"
|
3
|
+
|
4
|
+
module QuietRoutes
|
5
|
+
class Engine < ::Rails::Engine
|
6
|
+
# Set as empty array but user can override it
|
7
|
+
config.quiet_routes = []
|
8
|
+
|
9
|
+
initializer 'quiet_routes' do |app|
|
10
|
+
next unless app.config.quiet_routes
|
11
|
+
QUIET_PATHS = app.config.quiet_routes
|
12
|
+
KEY = 'quiet_assets.old_level'
|
13
|
+
app.config.assets.logger = false
|
14
|
+
|
15
|
+
Rails::Rack::Logger.class_eval do
|
16
|
+
def call_with_quiet_routes(env)
|
17
|
+
begin
|
18
|
+
if QUIET_PATHS.find { |path| env['PATH_INFO'].start_with?(path) }
|
19
|
+
env[KEY] = Rails.logger.level
|
20
|
+
Rails.logger.level = Logger::ERROR
|
21
|
+
end
|
22
|
+
call_without_quiet_routes(env)
|
23
|
+
ensure
|
24
|
+
Rails.logger.level = env[KEY] if env[KEY]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
alias_method_chain :call, :quiet_routes
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'quiet_routes/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "quiet_routes"
|
8
|
+
spec.version = QuietRoutes::VERSION
|
9
|
+
spec.authors = ["Yusuke Tanaka"]
|
10
|
+
spec.email = ["y.tanaka@aktsk.jp"]
|
11
|
+
spec.summary = %q{Turns off Rails particular log.}
|
12
|
+
spec.description = %q{Quiet Assets turns off Rails particular log.}
|
13
|
+
spec.homepage = "https://github.com/yusuket/quiet_routes"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
require 'rails'
|
4
|
+
require 'rails/all'
|
5
|
+
|
6
|
+
require 'minitest/autorun'
|
7
|
+
require 'minitest/unit'
|
8
|
+
require 'minitest/pride'
|
9
|
+
require 'active_support/testing/isolation'
|
10
|
+
|
11
|
+
require File.expand_path('../../lib/quiet_routes', __FILE__)
|
12
|
+
|
13
|
+
class HomeController < ActionController::Base
|
14
|
+
def index
|
15
|
+
render text: 'Hi there!'
|
16
|
+
end
|
17
|
+
|
18
|
+
def status
|
19
|
+
head 200
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class HelperTest < Minitest::Unit::TestCase
|
24
|
+
include ActiveSupport::Testing::Isolation
|
25
|
+
|
26
|
+
attr_reader :app, :output
|
27
|
+
|
28
|
+
def setup
|
29
|
+
@output = StringIO.new
|
30
|
+
|
31
|
+
# Ruby 1.8 doesn't call self.inherited inside Class.new
|
32
|
+
# Config and routes are unreacheable inside the block here.
|
33
|
+
@app = Class.new(Rails::Application)
|
34
|
+
|
35
|
+
app.configure do
|
36
|
+
config.active_support.deprecation = :notify
|
37
|
+
config.secret_token = '685e1a60792fa0d036a82a52c0f97e42'
|
38
|
+
config.eager_load = false
|
39
|
+
|
40
|
+
routes {
|
41
|
+
root to: 'home#index'
|
42
|
+
get '/status', to: 'home#status'
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def initialize!(&block)
|
48
|
+
app.configure(&block) if block_given?
|
49
|
+
|
50
|
+
app.initialize!
|
51
|
+
|
52
|
+
Rails.logger = Logger.new(output)
|
53
|
+
Rails.logger.formatter = lambda { |s, d, p, m| "#{m}\n" }
|
54
|
+
end
|
55
|
+
|
56
|
+
def request(uri)
|
57
|
+
Rack::MockRequest.env_for(uri)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_status_url_with_option_by_default
|
61
|
+
initialize!
|
62
|
+
|
63
|
+
app.call request('/status')
|
64
|
+
|
65
|
+
assert_match(/Started GET \"\/status\" for at/, output.string)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_status_url_with_quiet_routes_option
|
69
|
+
initialize! { config.quiet_routes = ['/status'] }
|
70
|
+
|
71
|
+
app.call request('/status')
|
72
|
+
|
73
|
+
assert_equal '', output.string
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_in_multi_thread_env
|
77
|
+
initialize! { config.quiet_routes = ['/status'] }
|
78
|
+
|
79
|
+
th1 = Thread.new do
|
80
|
+
sleep 0.1
|
81
|
+
app.call request('/status')
|
82
|
+
end
|
83
|
+
|
84
|
+
th2 = Thread.new do
|
85
|
+
sleep 0.1
|
86
|
+
app.call request('/')
|
87
|
+
end
|
88
|
+
|
89
|
+
th3 = Thread.new do
|
90
|
+
sleep 0.1
|
91
|
+
app.call request('/status')
|
92
|
+
end
|
93
|
+
|
94
|
+
[th1, th2, th3].map{|i| i.join }
|
95
|
+
|
96
|
+
n = output.string.lines.select{|i| i.match(/Started GET "\/"/) }
|
97
|
+
|
98
|
+
assert_equal n.size, 1
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_regular_url
|
102
|
+
initialize!
|
103
|
+
|
104
|
+
app.call request('/')
|
105
|
+
|
106
|
+
assert_match(/Started GET \"\/\" for at/, output.string)
|
107
|
+
end
|
108
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: quiet_routes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yusuke Tanaka
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Quiet Assets turns off Rails particular log.
|
42
|
+
email:
|
43
|
+
- y.tanaka@aktsk.jp
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/quiet_routes.rb
|
54
|
+
- lib/quiet_routes/version.rb
|
55
|
+
- quiet_routes.gemspec
|
56
|
+
- test/test_quiet_routes.rb
|
57
|
+
homepage: https://github.com/yusuket/quiet_routes
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.2.2
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Turns off Rails particular log.
|
81
|
+
test_files:
|
82
|
+
- test/test_quiet_routes.rb
|
83
|
+
has_rdoc:
|