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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dcdbbf1627dfe985fc25972091cbe62f422406c5
4
- data.tar.gz: 25829a4b001ef53509ade664e8889700698f6a8f
3
+ metadata.gz: 4326c7c5389cda01fd84579e6996319ce2e591f1
4
+ data.tar.gz: 26469a1f1c7d7217798f1acbcd751ddf665c70b1
5
5
  SHA512:
6
- metadata.gz: b6112d1cac18e632c5cf9a40a829b8ee1be40bf5c65a67f9192fea727925dbc7816b1038eb8e7f15e46f3c01a7a63bb21bdce98a1185180c45d37c8bb186541a
7
- data.tar.gz: d44c6281d225d2b78a3f735212c1336b7be0bc2b94fa7c3290dd907a955673b890f51921c46ae3883f526c15bda5a8509fc27bd465422c4d222370c7ab1b9538
6
+ metadata.gz: 2b6eb26d5d60a2af9b4023f4bad78a4dddedd0537e4ec6b779d3edbc6d1bf554fe2c0fadb28665c0e98bdc94dc4a475c292c4b396783c6c1719b70c842b12f6d
7
+ data.tar.gz: 2430e6122cfeb7484ec60ee4f0b41a9c38d0b7cefdcf089a205973464cb54f94fcea5f53232ddbfe67fede312b7f334f297a1ffc1d73b34cfe0a5ec155664c3f
data/Gemfile CHANGED
@@ -2,12 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- group :development, :test do
6
- gem 'rails', '~> 4.2'
7
- end
8
-
9
5
  group :test do
10
6
  gem 'minitest'
11
- gem 'minitest-spec-rails'
12
7
  gem 'minitest-reporters'
13
8
  end
data/README.md CHANGED
@@ -28,7 +28,7 @@ place the following in your `config/application.rb` file:
28
28
 
29
29
  If you need to supress output for other paths you can do so by specifying:
30
30
 
31
- config.quiet_assets_paths << '/silent/'
31
+ config.shut_up_assets.paths << '/silent/'
32
32
 
33
33
  ## License
34
34
 
@@ -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
- class << self
7
- def enabled?
8
- config.quiet_assets
9
- end
6
+ def self.enabled?
7
+ config.quiet_assets
8
+ end
10
9
 
11
- def suppress_on?(request)
12
- enabled? && request.get? && request.filtered_path =~ config.shut_up_assets.pattern
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
- return super unless ShutUpAssets.suppress_on?(request)
19
- logger.silence(::Logger::WARN) { super }
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
 
@@ -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.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'
@@ -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
- # Rails.logger.formatter = lambda { |s, d, p, m| "#{m}\n" }
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 '', output.string
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 '', output.string
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, 1
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 '', output.string
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 '', output.string
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 '', output.string
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 '', output.string
129
+ assert_equal EMPTY_LINE, output.string
124
130
  end
125
131
  end
126
132
 
data/test/test_helper.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'bundler/setup'
2
2
  require 'minitest/autorun'
3
3
  require 'rails'
4
+ require 'action_pack'
4
5
  require 'action_controller'
5
6
  require 'shut_up_assets'
6
7
 
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.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-14 00:00:00.000000000 Z
13
+ date: 2015-09-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: railties