shut_up_assets 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -5
- data/README.md +1 -1
- data/lib/shut_up_assets.rb +25 -9
- data/shut_up_assets.gemspec +1 -1
- data/test/integration_test.rb +14 -8
- data/test/test_helper.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4326c7c5389cda01fd84579e6996319ce2e591f1
|
4
|
+
data.tar.gz: 26469a1f1c7d7217798f1acbcd751ddf665c70b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b6eb26d5d60a2af9b4023f4bad78a4dddedd0537e4ec6b779d3edbc6d1bf554fe2c0fadb28665c0e98bdc94dc4a475c292c4b396783c6c1719b70c842b12f6d
|
7
|
+
data.tar.gz: 2430e6122cfeb7484ec60ee4f0b41a9c38d0b7cefdcf089a205973464cb54f94fcea5f53232ddbfe67fede312b7f334f297a1ffc1d73b34cfe0a5ec155664c3f
|
data/Gemfile
CHANGED
data/README.md
CHANGED
data/lib/shut_up_assets.rb
CHANGED
@@ -3,20 +3,36 @@ require 'rails/rack/logger'
|
|
3
3
|
require 'active_support/configurable'
|
4
4
|
|
5
5
|
class ShutUpAssets < Rails::Railtie # :nodoc-all:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
6
|
+
def self.enabled?
|
7
|
+
config.quiet_assets
|
8
|
+
end
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
end
|
10
|
+
def self.suppress_on?(request)
|
11
|
+
enabled? && request.get? && request.filtered_path =~ config.shut_up_assets.pattern
|
14
12
|
end
|
15
13
|
|
16
14
|
class RackLogger < Rails::Rack::Logger
|
15
|
+
EMPTY_LINE = "\n".freeze
|
16
|
+
|
17
17
|
def call_app(request, env)
|
18
|
-
|
19
|
-
|
18
|
+
suppressed = ShutUpAssets.suppress_on?(request)
|
19
|
+
|
20
|
+
# Put some space between requests in development logs.
|
21
|
+
logger.debug { EMPTY_LINE } if development? && !suppressed
|
22
|
+
|
23
|
+
instrumenter = ActiveSupport::Notifications.instrumenter
|
24
|
+
instrumenter.start 'request.action_dispatch', request: request
|
25
|
+
|
26
|
+
logger.info { started_request_message(request) } unless suppressed
|
27
|
+
|
28
|
+
resp = @app.call(env)
|
29
|
+
resp[2] = ::Rack::BodyProxy.new(resp[2]) { finish(request) }
|
30
|
+
resp
|
31
|
+
rescue Exception
|
32
|
+
finish(request)
|
33
|
+
raise
|
34
|
+
ensure
|
35
|
+
ActiveSupport::LogSubscriber.flush_all!
|
20
36
|
end
|
21
37
|
end
|
22
38
|
|
data/shut_up_assets.gemspec
CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = 'shut_up_assets'
|
6
|
-
spec.version = '2.0.
|
6
|
+
spec.version = '2.0.1'
|
7
7
|
spec.authors = ['Dmitry Karpunin', 'Dmitry Vorotilin', 'Anton Semenov']
|
8
8
|
spec.email = %w(koderfunk@gmail.com d.vorotilin@gmail.com anton.estum@gmail.com)
|
9
9
|
spec.homepage = 'https://github.com/estum/shut_up_assets'
|
data/test/integration_test.rb
CHANGED
@@ -4,9 +4,15 @@ class HomeController < ActionController::Base
|
|
4
4
|
def index
|
5
5
|
render :text => 'Hi there!'
|
6
6
|
end
|
7
|
+
|
8
|
+
def error
|
9
|
+
raise "Breaking"
|
10
|
+
render :text => 'Hi there!'
|
11
|
+
end
|
7
12
|
end
|
8
13
|
|
9
14
|
class IntegrationTest < ActionController::TestCase
|
15
|
+
EMPTY_LINE = ""
|
10
16
|
attr_accessor :app, :output
|
11
17
|
|
12
18
|
def initialize!(&block)
|
@@ -15,7 +21,7 @@ class IntegrationTest < ActionController::TestCase
|
|
15
21
|
app.initialize!
|
16
22
|
|
17
23
|
Rails.logger = ActiveSupport::Logger.new(output)
|
18
|
-
|
24
|
+
Rails.logger.formatter = lambda { |s, d, p, m| "#{m}\n" }
|
19
25
|
end
|
20
26
|
|
21
27
|
def request(uri)
|
@@ -31,7 +37,7 @@ class IntegrationTest < ActionController::TestCase
|
|
31
37
|
|
32
38
|
app.call request('/assets/picture')
|
33
39
|
|
34
|
-
assert_equal
|
40
|
+
assert_equal EMPTY_LINE, output.string
|
35
41
|
end
|
36
42
|
|
37
43
|
def test_assets_url_with_turned_on_option
|
@@ -39,7 +45,7 @@ class IntegrationTest < ActionController::TestCase
|
|
39
45
|
|
40
46
|
app.call request('/assets/picture')
|
41
47
|
|
42
|
-
assert_equal
|
48
|
+
assert_equal EMPTY_LINE, output.string
|
43
49
|
end
|
44
50
|
|
45
51
|
def test_in_multi_thread_env
|
@@ -64,7 +70,7 @@ class IntegrationTest < ActionController::TestCase
|
|
64
70
|
|
65
71
|
n = output.string.lines.select{|i| i.match(/Started GET "\/"/) }
|
66
72
|
|
67
|
-
assert_equal n.size
|
73
|
+
assert_equal 1, n.size
|
68
74
|
end
|
69
75
|
|
70
76
|
def test_assets_url_with_turned_off_option
|
@@ -88,7 +94,7 @@ class IntegrationTest < ActionController::TestCase
|
|
88
94
|
|
89
95
|
app.call request('http://some-url.com//assets/picture')
|
90
96
|
|
91
|
-
assert_equal
|
97
|
+
assert_equal EMPTY_LINE, output.string
|
92
98
|
end
|
93
99
|
|
94
100
|
def test_quiet_url
|
@@ -104,7 +110,7 @@ class IntegrationTest < ActionController::TestCase
|
|
104
110
|
|
105
111
|
app.call request('/quiet/this')
|
106
112
|
|
107
|
-
assert_equal
|
113
|
+
assert_equal EMPTY_LINE, output.string
|
108
114
|
end
|
109
115
|
|
110
116
|
def test_quiet_url_with_paths_option_as_string_appending
|
@@ -112,7 +118,7 @@ class IntegrationTest < ActionController::TestCase
|
|
112
118
|
|
113
119
|
app.call request('/quiet/this')
|
114
120
|
|
115
|
-
assert_equal
|
121
|
+
assert_equal EMPTY_LINE, output.string
|
116
122
|
end
|
117
123
|
|
118
124
|
def test_quiet_url_with_paths_option_as_array
|
@@ -120,7 +126,7 @@ class IntegrationTest < ActionController::TestCase
|
|
120
126
|
|
121
127
|
app.call request('/quiet/this')
|
122
128
|
|
123
|
-
assert_equal
|
129
|
+
assert_equal EMPTY_LINE, output.string
|
124
130
|
end
|
125
131
|
end
|
126
132
|
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shut_up_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Karpunin
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-09-
|
13
|
+
date: 2015-09-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: railties
|