sweet_notifications 0.2.0 → 0.2.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: b10b735828800811baddaaf6234ccde5d4825d0c
4
- data.tar.gz: f4a229a8c82c4fbd5d098cae36c945d32fe78c43
3
+ metadata.gz: 313330fe1e88bea48a41438d6a59bdd87d84a486
4
+ data.tar.gz: c50418d1bff9d94602e99760c7f88758556362ee
5
5
  SHA512:
6
- metadata.gz: 46055d7192e980297c47042fd7c0d72a86e9c97fac56b02befc39055f7cfea05537fe79de7876e52406f03fea4bc309bff5035720a9492b0931ca0b5b12a24c7
7
- data.tar.gz: 9244a85530d1b16dcb7ade6b656986f9a699d70c25d02a3fd2aaefde9b77efb81c64611c637df3f730116286ab8e092f9b255ad823da60a0bf401b5118aeda3f
6
+ metadata.gz: eb9591a334961e3fa5ee4c0a41f5e9992f698a7acb40ea0c3d1806df365d886635325ed0789f765d32da3f211d0940f3da6ad4569416151b87630e03de47ca66
7
+ data.tar.gz: 97b08cdc255d9162edc4f0650129bd5d5d0255d1ac346229cfc73d567d751bcd623c3e10be2414e10dab40187c90ee0a3173f6b85ca8319bf3e984b2eb2ea853
@@ -1,7 +1,10 @@
1
1
  AllCops:
2
+ RunRailsCops: true
2
3
  Exclude:
3
4
  - sweet_notifications.gemspec
4
5
  - lib/sweet_notifications/version.rb
6
+ - "vendor/**/*"
7
+ - "gemfiles/vendor/**/*"
5
8
 
6
9
  ClassAndModuleChildren:
7
10
  Exclude:
@@ -17,3 +20,10 @@ MethodLength:
17
20
 
18
21
  ModuleFunction:
19
22
  Enabled: false
23
+
24
+ Metrics/AbcSize:
25
+ Enabled: false
26
+
27
+ Style/StringLiterals:
28
+ Enabled: true
29
+ EnforcedStyle: single_quotes
@@ -1,12 +1,22 @@
1
1
  language: ruby
2
+ sudo: false
3
+ cache: bundler
2
4
  gemfile:
3
5
  - gemfiles/rails_4.0.gemfile
4
6
  - gemfiles/rails_4.1.gemfile
7
+ - gemfiles/rails_4.2.gemfile
5
8
  rvm:
6
9
  - 2.0.0
7
- - 2.1.2
10
+ - 2.1.7
11
+ - 2.2.3
12
+ - jruby-9.0.1.0
13
+ - rbx-2.5
8
14
  matrix:
9
15
  include:
10
16
  - rvm: jruby
11
- gemfile: gemfiles/rails_4.1.gemfile
17
+ gemfile: gemfiles/rails_4.2.gemfile
12
18
  env: JRUBY_OPTS="--2.0"
19
+ - rvm: 2.2.3
20
+ gemfile: gemfiles/rails_head.gemfile
21
+ allow_failures:
22
+ - gemfile: gemfiles/rails_head.gemfile
data/Appraisals CHANGED
@@ -5,3 +5,13 @@ end
5
5
  appraise "rails-4.1" do
6
6
  gem 'rails', '~> 4.1.0'
7
7
  end
8
+
9
+ appraise "rails-4.2" do
10
+ gem 'rails', '~> 4.2.0'
11
+ end
12
+
13
+ appraise "rails-head" do
14
+ gem 'rails', github: 'rails'
15
+ gem 'arel', github: 'rails/arel'
16
+ gem 'rack', github: 'rack'
17
+ end
@@ -0,0 +1,7 @@
1
+ ## 0.2.1 (3 October 2015)
2
+
3
+ - support Rails 5.0
4
+
5
+ ## 0.2.0 (11 June 2014)
6
+
7
+ - allow overriding label used in logging
data/README.md CHANGED
@@ -3,7 +3,8 @@
3
3
  Syntactic sugar for ActiveSupport::LogSubscriber for easy instrumentation and
4
4
  logging from third-party libraries.
5
5
 
6
- This gem currently requires Ruby 2.0 or JRuby in 2.0 mode.
6
+ This gem requires Ruby 2.0 or newer. Compatible versions of JRuby and Rubinius
7
+ are also supported.
7
8
 
8
9
  ## Installation
9
10
 
@@ -43,7 +44,7 @@ Then, subscribe to these notifications using SweetNotifications in an initialize
43
44
  SweetNotifications.subscribe :candies do
44
45
  color ActiveSupport::LogSubscriber::GREEN
45
46
  event :list, runtime: true do |event|
46
- return unless logger.debug?
47
+ next unless logger.debug? # Use next in blocks
47
48
  debug message(event, 'Candy', "listing candies: #{event.payload[:candies]}")
48
49
  end
49
50
  end
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 4.2.0"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", :github => "rails"
6
+ gem "arel", :github => "rails/arel"
7
+ gem "rack", :github => "rack"
8
+
9
+ gemspec :path => "../"
@@ -39,7 +39,8 @@ module SweetNotifications
39
39
 
40
40
  const_set(:ClassMethods, Module.new do
41
41
  define_method :log_process_action do |payload|
42
- messages, runtime = super(payload), payload[runtime_attr]
42
+ messages = super(payload)
43
+ runtime = payload[runtime_attr]
43
44
  if runtime && runtime != 0
44
45
  messages << format("#{name}: %.1fms", runtime.to_f)
45
46
  end
@@ -52,7 +52,8 @@ module SweetNotifications
52
52
  #
53
53
  # @return Numeric previous runtime value
54
54
  def reset_runtime
55
- rt, self.runtime = runtime, 0
55
+ rt = runtime
56
+ self.runtime = 0
56
57
  rt
57
58
  end
58
59
 
@@ -1,3 +1,3 @@
1
1
  module SweetNotifications
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
@@ -20,15 +20,15 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.required_ruby_version = '~> 2.0'
22
22
 
23
- spec.add_runtime_dependency "activesupport", "~> 4.0"
23
+ spec.add_runtime_dependency "activesupport", ">= 4.0", "< 6"
24
24
  spec.add_runtime_dependency "request_store", "~> 1.0"
25
- spec.add_runtime_dependency "railties", "~> 4.0"
26
- spec.add_development_dependency "actionpack", "~> 4.0"
25
+ spec.add_runtime_dependency "railties", ">= 4.0", "< 6"
26
+ spec.add_development_dependency "actionpack", ">= 4.0", "< 6"
27
27
  spec.add_development_dependency "bundler", "~> 1.6"
28
28
  spec.add_development_dependency "minitest"
29
29
  spec.add_development_dependency "rake", "~> 10.3"
30
30
  spec.add_development_dependency "yard", "~> 0.8.7"
31
- spec.add_development_dependency "appraisal", "~> 1.0"
32
- spec.add_development_dependency "simplecov", "~> 0.8.2"
33
- spec.add_development_dependency "rubocop", "~> 0.23.0"
31
+ spec.add_development_dependency "appraisal", "~> 2.0"
32
+ spec.add_development_dependency "simplecov", "~> 0.10.0"
33
+ spec.add_development_dependency "rubocop", "~> 0.34.0"
34
34
  end
@@ -11,18 +11,28 @@ describe SweetNotifications::ControllerRuntime do
11
11
  class LogSubscribersController < ActionController::Base
12
12
  def create
13
13
  TestLogSubscriber.runtime += 100
14
- render text: '100'
14
+ render_text '100'
15
15
  end
16
16
 
17
17
  def show
18
- render text: '0'
18
+ render_text '0'
19
19
  end
20
20
 
21
21
  def destroy
22
22
  TestLogSubscriber.runtime += 50
23
- render text: 'OK'
23
+ render_text 'OK'
24
24
  TestLogSubscriber.runtime += 5
25
25
  end
26
+
27
+ private
28
+
29
+ def render_text(text)
30
+ if Gem.loaded_specs['rails'].version < Gem::Version.new('4.2')
31
+ render text: text
32
+ else
33
+ render plain: text
34
+ end
35
+ end
26
36
  end
27
37
 
28
38
  include ActiveSupport::LogSubscriber::TestHelper
@@ -53,13 +63,13 @@ describe SweetNotifications::ControllerRuntime do
53
63
 
54
64
  describe 'runtime logging' do
55
65
  it 'does not append runtime when it is 0' do
56
- get :show, id: 1
66
+ get :show, params: { id: 1 }
57
67
  wait
58
68
  assert_no_match(/Test:/, @logger.logged(:info)[2])
59
69
  end
60
70
 
61
71
  it 'appends non-zero runtime' do
62
- post :create, test: 1
72
+ post :create, params: { test: 1 }
63
73
  wait
64
74
  expected_message = /\(Views: [\d.]+ms \| Test: 100.0ms\)/
65
75
  assert_match(expected_message, @logger.logged(:info)[2])
@@ -67,14 +77,14 @@ describe SweetNotifications::ControllerRuntime do
67
77
 
68
78
  it 'resets runtime before request' do
69
79
  TestLogSubscriber.runtime += 1000
70
- post :create, test: 1
80
+ post :create, params: { test: 1 }
71
81
  wait
72
82
  expected_message = /\(Views: [\d.]+ms \| Test: 100.0ms\)/
73
83
  assert_match(expected_message, @logger.logged(:info)[2])
74
84
  end
75
85
 
76
86
  it 'includes runtime after render' do
77
- post :destroy, id: 1
87
+ post :destroy, params: { id: 1 }
78
88
  wait
79
89
  expected_message = /\(Views: [\d.]+ms \| Test: 55.0ms\)/
80
90
  assert_match(expected_message, @logger.logged(:info)[2])
@@ -5,7 +5,7 @@ describe SweetNotifications::LogSubscriber do
5
5
 
6
6
  def event(name: 'Test', duration: 1, transaction_id: SecureRandom.hex,
7
7
  payload: {})
8
- now = Time.now
8
+ now = Time.current
9
9
  ActiveSupport::Notifications::Event.new(name,
10
10
  now,
11
11
  now + duration,
@@ -144,6 +144,5 @@ describe SweetNotifications::LogSubscriber do
144
144
  message = subject.message(event, 'Label', 'body')
145
145
  assert !message.include?(ActiveSupport::LogSubscriber::CYAN)
146
146
  end
147
-
148
147
  end
149
148
  end
@@ -5,7 +5,12 @@ class SweetNotificationsController < ActionController::Base
5
5
  ActiveSupport::Notifications.instrument 'test.controller' do
6
6
  'ok'
7
7
  end
8
- render nothing: true
8
+
9
+ if Gem.loaded_specs['rails'].version < Gem::Version.new('4.2')
10
+ render text: 'ok'
11
+ else
12
+ render plain: 'ok'
13
+ end
9
14
  end
10
15
  end
11
16
 
@@ -15,7 +20,7 @@ describe SweetNotifications do
15
20
 
16
21
  describe '.subscribe' do
17
22
  it 'creates a railtie' do
18
- railtie, _ = SweetNotifications.subscribe 'railtie_create' do
23
+ railtie, = SweetNotifications.subscribe 'railtie_create' do
19
24
  end
20
25
  assert railtie < Rails::Railtie
21
26
  end
@@ -29,7 +34,7 @@ describe SweetNotifications do
29
34
  end
30
35
 
31
36
  it 'binds log subscriber to notifications' do
32
- railtie, _ = SweetNotifications.subscribe 'sweet' do
37
+ railtie, = SweetNotifications.subscribe 'sweet' do
33
38
  event :test do |event|
34
39
  info message(event, 'Test', 'blah blah')
35
40
  end
@@ -49,7 +54,7 @@ describe SweetNotifications do
49
54
  end
50
55
  end
51
56
 
52
- railtie, _ = SweetNotifications.subscribe 'sweet' do
57
+ railtie, = SweetNotifications.subscribe 'sweet' do
53
58
  event :direct do |event|
54
59
  info message(event, 'Direct', 'foo bar')
55
60
  end
@@ -68,7 +73,7 @@ describe SweetNotifications do
68
73
  end
69
74
 
70
75
  it 'logs to Rails logger' do
71
- railtie, _ = SweetNotifications.subscribe 'controller', label: 'Label' do
76
+ railtie, = SweetNotifications.subscribe 'controller', label: 'Label' do
72
77
  event :test, runtime: true do |event|
73
78
  info message(event, 'Test', 'logging')
74
79
  end
@@ -3,7 +3,7 @@ require 'simplecov'
3
3
 
4
4
  SimpleCov.start do
5
5
  add_filter 'test'
6
- command_name 'Mintest'
6
+ command_name 'Minitest'
7
7
  end
8
8
 
9
9
  require 'minitest/autorun'
@@ -13,11 +13,12 @@ require 'sweet_notifications'
13
13
  require 'active_support/test_case'
14
14
  require 'action_controller'
15
15
  require 'active_support/log_subscriber/test_helper'
16
+ require 'active_support/core_ext/string'
16
17
  require 'securerandom'
17
18
 
18
19
  class ActiveSupport::TestCase
19
20
  class << self
20
- remove_method :describe
21
+ remove_method :describe if method_defined? :describe
21
22
  end
22
23
 
23
24
  extend MiniTest::Spec::DSL
@@ -26,6 +27,10 @@ class ActiveSupport::TestCase
26
27
  register_spec_type(self)
27
28
  end
28
29
 
30
+ if ActiveSupport::TestCase.respond_to?(:test_order=)
31
+ ActiveSupport::TestCase.test_order = :random
32
+ end
33
+
29
34
  module ActionController
30
35
  TestRoutes = ActionDispatch::Routing::RouteSet.new
31
36
  TestRoutes.draw do
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sweet_notifications
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ville Lautanala
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-10 00:00:00.000000000 Z
11
+ date: 2015-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '6'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '4.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '6'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: request_store
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -42,30 +48,42 @@ dependencies:
42
48
  name: railties
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - "~>"
51
+ - - ">="
46
52
  - !ruby/object:Gem::Version
47
53
  version: '4.0'
54
+ - - "<"
55
+ - !ruby/object:Gem::Version
56
+ version: '6'
48
57
  type: :runtime
49
58
  prerelease: false
50
59
  version_requirements: !ruby/object:Gem::Requirement
51
60
  requirements:
52
- - - "~>"
61
+ - - ">="
53
62
  - !ruby/object:Gem::Version
54
63
  version: '4.0'
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: '6'
55
67
  - !ruby/object:Gem::Dependency
56
68
  name: actionpack
57
69
  requirement: !ruby/object:Gem::Requirement
58
70
  requirements:
59
- - - "~>"
71
+ - - ">="
60
72
  - !ruby/object:Gem::Version
61
73
  version: '4.0'
74
+ - - "<"
75
+ - !ruby/object:Gem::Version
76
+ version: '6'
62
77
  type: :development
63
78
  prerelease: false
64
79
  version_requirements: !ruby/object:Gem::Requirement
65
80
  requirements:
66
- - - "~>"
81
+ - - ">="
67
82
  - !ruby/object:Gem::Version
68
83
  version: '4.0'
84
+ - - "<"
85
+ - !ruby/object:Gem::Version
86
+ version: '6'
69
87
  - !ruby/object:Gem::Dependency
70
88
  name: bundler
71
89
  requirement: !ruby/object:Gem::Requirement
@@ -128,42 +146,42 @@ dependencies:
128
146
  requirements:
129
147
  - - "~>"
130
148
  - !ruby/object:Gem::Version
131
- version: '1.0'
149
+ version: '2.0'
132
150
  type: :development
133
151
  prerelease: false
134
152
  version_requirements: !ruby/object:Gem::Requirement
135
153
  requirements:
136
154
  - - "~>"
137
155
  - !ruby/object:Gem::Version
138
- version: '1.0'
156
+ version: '2.0'
139
157
  - !ruby/object:Gem::Dependency
140
158
  name: simplecov
141
159
  requirement: !ruby/object:Gem::Requirement
142
160
  requirements:
143
161
  - - "~>"
144
162
  - !ruby/object:Gem::Version
145
- version: 0.8.2
163
+ version: 0.10.0
146
164
  type: :development
147
165
  prerelease: false
148
166
  version_requirements: !ruby/object:Gem::Requirement
149
167
  requirements:
150
168
  - - "~>"
151
169
  - !ruby/object:Gem::Version
152
- version: 0.8.2
170
+ version: 0.10.0
153
171
  - !ruby/object:Gem::Dependency
154
172
  name: rubocop
155
173
  requirement: !ruby/object:Gem::Requirement
156
174
  requirements:
157
175
  - - "~>"
158
176
  - !ruby/object:Gem::Version
159
- version: 0.23.0
177
+ version: 0.34.0
160
178
  type: :development
161
179
  prerelease: false
162
180
  version_requirements: !ruby/object:Gem::Requirement
163
181
  requirements:
164
182
  - - "~>"
165
183
  - !ruby/object:Gem::Version
166
- version: 0.23.0
184
+ version: 0.34.0
167
185
  description: Syntactic sugar for ActiveSupport::LogSubscriber for easy instrumentation
168
186
  and logging from third-party libraries.
169
187
  email:
@@ -176,6 +194,7 @@ files:
176
194
  - ".rubocop.yml"
177
195
  - ".travis.yml"
178
196
  - Appraisals
197
+ - CHANGELOG.md
179
198
  - CONTRIBUTING.md
180
199
  - Gemfile
181
200
  - LICENSE.txt
@@ -183,6 +202,8 @@ files:
183
202
  - Rakefile
184
203
  - gemfiles/rails_4.0.gemfile
185
204
  - gemfiles/rails_4.1.gemfile
205
+ - gemfiles/rails_4.2.gemfile
206
+ - gemfiles/rails_head.gemfile
186
207
  - lib/sweet_notifications.rb
187
208
  - lib/sweet_notifications/controller_runtime.rb
188
209
  - lib/sweet_notifications/log_subscriber.rb
@@ -214,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
235
  version: '0'
215
236
  requirements: []
216
237
  rubyforge_project:
217
- rubygems_version: 2.2.2
238
+ rubygems_version: 2.4.5.1
218
239
  signing_key:
219
240
  specification_version: 4
220
241
  summary: Syntactic sugar for ActiveSupport::LogSubscriber.