nunes 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +9 -0
- data/Changelog.md +6 -0
- data/Gemfile +7 -6
- data/README.md +3 -0
- data/lib/nunes.rb +2 -0
- data/lib/nunes/subscribers/active_job.rb +28 -0
- data/lib/nunes/version.rb +1 -1
- data/test/cache_instrumentation_test.rb +4 -2
- data/test/job_instrumentation_test.rb +30 -0
- data/test/mailer_instrumentation_test.rb +7 -2
- data/test/nunes_test.rb +1 -1
- data/test/rails_app/app/assets/javascripts/application.js +0 -2
- data/test/rails_app/app/jobs/spam_detector_job.rb +9 -0
- data/test/rails_app/config/environments/test.rb +4 -1
- data/test/rails_app/config/secrets.yml +8 -0
- data/test/subscriber_test.rb +2 -1
- metadata +18 -14
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bddc1e5791272becd4a0272db00372b590bb27a6
|
4
|
+
data.tar.gz: 795aac98c9ba8a5194ad8128a0df8401637a0f6f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 778bf582c222528abf705cf0710bf36809b13c9fadf52ca2d9c93c9968b7b25df8f88a32df4785279431e4bdb8c5901ef4da88ef8c42e345cb5e2c60596999b7
|
7
|
+
data.tar.gz: 2938ce75643befd9904221fe48be7a6dc77d88906c7e980d32eb2b2b6466fd385cfca7b41092a20b4f82b68f2e136280dbe0c69f628c7bc4b0ddabd4043a34d4
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Changelog.md
CHANGED
data/Gemfile
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
gemspec
|
3
3
|
|
4
|
-
gem "rails", "~>
|
5
|
-
gem "sqlite3
|
6
|
-
gem "minitest",
|
7
|
-
gem "rake"
|
4
|
+
gem "rails", "~> 4.2.0"
|
5
|
+
gem "sqlite3", "~> 1.3.7"
|
6
|
+
gem "minitest", "~> 5.1"
|
7
|
+
gem "rake", "~> 10.0.4"
|
8
|
+
gem "test-unit", "~> 3.0"
|
8
9
|
|
9
10
|
group :watch do
|
10
|
-
gem "rb-fsevent", require: false
|
11
|
+
gem "rb-fsevent", "~> 0.9.3", require: false
|
11
12
|
end
|
12
13
|
|
13
14
|
group :bench do
|
14
|
-
gem "rblineprof"
|
15
|
+
gem "rblineprof", "~> 0.3.6"
|
15
16
|
end
|
data/README.md
CHANGED
data/lib/nunes.rb
CHANGED
@@ -9,6 +9,7 @@ require "nunes/subscribers/action_view"
|
|
9
9
|
require "nunes/subscribers/action_mailer"
|
10
10
|
require "nunes/subscribers/active_support"
|
11
11
|
require "nunes/subscribers/active_record"
|
12
|
+
require "nunes/subscribers/active_job"
|
12
13
|
require "nunes/subscribers/nunes"
|
13
14
|
|
14
15
|
module Nunes
|
@@ -31,6 +32,7 @@ module Nunes
|
|
31
32
|
subscribers << Subscribers::ActionMailer.subscribe(adapter)
|
32
33
|
subscribers << Subscribers::ActiveSupport.subscribe(adapter)
|
33
34
|
subscribers << Subscribers::ActiveRecord.subscribe(adapter)
|
35
|
+
subscribers << Subscribers::ActiveJob.subscribe(adapter)
|
34
36
|
subscribers << Subscribers::Nunes.subscribe(adapter)
|
35
37
|
|
36
38
|
subscribers
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "nunes/subscriber"
|
2
|
+
|
3
|
+
module Nunes
|
4
|
+
module Subscribers
|
5
|
+
class ActiveJob < ::Nunes::Subscriber
|
6
|
+
# Private
|
7
|
+
Pattern = /\.active_job\Z/
|
8
|
+
|
9
|
+
# Private: The namespace for events to subscribe to.
|
10
|
+
def self.pattern
|
11
|
+
Pattern
|
12
|
+
end
|
13
|
+
|
14
|
+
def perform(start, ending, transaction_id, payload)
|
15
|
+
runtime = ((ending - start) * 1_000).round
|
16
|
+
job = payload[:job].class.to_s.underscore
|
17
|
+
|
18
|
+
timing "active_job.#{job}.perform", runtime
|
19
|
+
end
|
20
|
+
|
21
|
+
def enqueue(start, ending, transaction_id, payload)
|
22
|
+
job = payload[:job].class.to_s.underscore
|
23
|
+
increment "active_job.#{job}.enqueue"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
data/lib/nunes/version.rb
CHANGED
@@ -15,12 +15,14 @@ class CacheInstrumentationTest < ActiveSupport::TestCase
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def setup_cache
|
18
|
-
|
18
|
+
# Deprecated in Rails 4.2
|
19
|
+
# ActiveSupport::Cache::MemoryStore.instrument = true
|
19
20
|
@cache = ActiveSupport::Cache::MemoryStore.new
|
20
21
|
end
|
21
22
|
|
22
23
|
def teardown_cache
|
23
|
-
|
24
|
+
# Deprecated in Rails 4.2
|
25
|
+
# ActiveSupport::Cache::MemoryStore.instrument = nil
|
24
26
|
@cache = nil
|
25
27
|
end
|
26
28
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
class JobInstrumentationTest < ActiveSupport::TestCase
|
4
|
+
setup :setup_subscriber
|
5
|
+
teardown :teardown_subscriber
|
6
|
+
|
7
|
+
def setup_subscriber
|
8
|
+
@subscriber = Nunes::Subscribers::ActiveJob.subscribe(adapter)
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown_subscriber
|
12
|
+
ActiveSupport::Notifications.unsubscribe @subscriber if @subscriber
|
13
|
+
end
|
14
|
+
|
15
|
+
test "perform_now" do
|
16
|
+
p = Post.new(title: 'Testing')
|
17
|
+
SpamDetectorJob.perform_now(p)
|
18
|
+
|
19
|
+
assert_timer "active_job.spam_detector_job.perform"
|
20
|
+
end
|
21
|
+
|
22
|
+
test "perform_later" do
|
23
|
+
p = Post.create!(title: 'Testing')
|
24
|
+
SpamDetectorJob.perform_later(p)
|
25
|
+
|
26
|
+
assert_timer "active_job.spam_detector_job.perform"
|
27
|
+
assert_counter "active_job.spam_detector_job.enqueue"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -14,8 +14,13 @@ class MailerInstrumentationTest < ActionMailer::TestCase
|
|
14
14
|
ActiveSupport::Notifications.unsubscribe @subscriber if @subscriber
|
15
15
|
end
|
16
16
|
|
17
|
-
test "
|
18
|
-
PostMailer.created.
|
17
|
+
test "deliver_now" do
|
18
|
+
PostMailer.created.deliver_now
|
19
|
+
assert_timer "action_mailer.deliver.PostMailer"
|
20
|
+
end
|
21
|
+
|
22
|
+
test "deliver_later" do
|
23
|
+
PostMailer.created.deliver_later
|
19
24
|
assert_timer "action_mailer.deliver.PostMailer"
|
20
25
|
end
|
21
26
|
|
data/test/nunes_test.rb
CHANGED
@@ -8,11 +8,12 @@ RailsApp::Application.configure do
|
|
8
8
|
config.cache_classes = true
|
9
9
|
|
10
10
|
# Configure static asset server for tests with Cache-Control for performance
|
11
|
-
config.
|
11
|
+
config.serve_static_files = true
|
12
12
|
config.static_cache_control = "public, max-age=3600"
|
13
13
|
|
14
14
|
# Log error messages when you accidentally call methods on nil
|
15
15
|
config.whiny_nils = true
|
16
|
+
config.eager_load = false
|
16
17
|
|
17
18
|
# Show full error reports and disable caching
|
18
19
|
config.consider_all_requests_local = true
|
@@ -28,6 +29,8 @@ RailsApp::Application.configure do
|
|
28
29
|
# The :test delivery method accumulates sent emails in the
|
29
30
|
# ActionMailer::Base.deliveries array.
|
30
31
|
config.action_mailer.delivery_method = :test
|
32
|
+
config.active_support.test_order = :random
|
33
|
+
|
31
34
|
|
32
35
|
|
33
36
|
# Print deprecation notices to the stderr
|
@@ -0,0 +1,8 @@
|
|
1
|
+
development:
|
2
|
+
secret_key_base: "55277c259b087b9be1cee9d5c9642c556cda844ee585efb92096c97db51bd4cbe13f3fcdee4f8b0be8488da3e2a754c8"
|
3
|
+
test:
|
4
|
+
secret_key_base: "2e4c45cf5354a05621ffcc695b07c8d86716eb509883a4f1ec84644786b42a43cabbba096c23bf0c103de546d495428e"
|
5
|
+
|
6
|
+
production:
|
7
|
+
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
8
|
+
|
data/test/subscriber_test.rb
CHANGED
@@ -30,7 +30,8 @@ class SubscriberTest < ActiveSupport::TestCase
|
|
30
30
|
instance = subscriber_class.new(client)
|
31
31
|
|
32
32
|
subscriber_class.stub :new, instance do
|
33
|
-
mock =
|
33
|
+
mock = MiniTest::Mock.new
|
34
|
+
|
34
35
|
mock.expect :subscribe, :subscriber, [subscriber_class.pattern, instance]
|
35
36
|
|
36
37
|
assert_equal :subscriber,
|
metadata
CHANGED
@@ -1,30 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nunes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- John Nunemaker
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-02-16 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '1.3'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '1.3'
|
30
27
|
description: The friendly gem that instruments everything for you, like I would if
|
@@ -35,7 +32,8 @@ executables: []
|
|
35
32
|
extensions: []
|
36
33
|
extra_rdoc_files: []
|
37
34
|
files:
|
38
|
-
- .gitignore
|
35
|
+
- ".gitignore"
|
36
|
+
- ".travis.yml"
|
39
37
|
- Changelog.md
|
40
38
|
- Gemfile
|
41
39
|
- LICENSE.txt
|
@@ -49,6 +47,7 @@ files:
|
|
49
47
|
- lib/nunes/subscribers/action_controller.rb
|
50
48
|
- lib/nunes/subscribers/action_mailer.rb
|
51
49
|
- lib/nunes/subscribers/action_view.rb
|
50
|
+
- lib/nunes/subscribers/active_job.rb
|
52
51
|
- lib/nunes/subscribers/active_record.rb
|
53
52
|
- lib/nunes/subscribers/active_support.rb
|
54
53
|
- lib/nunes/subscribers/nunes.rb
|
@@ -66,6 +65,7 @@ files:
|
|
66
65
|
- test/fake_udp_socket_test.rb
|
67
66
|
- test/helper.rb
|
68
67
|
- test/instrumentable_test.rb
|
68
|
+
- test/job_instrumentation_test.rb
|
69
69
|
- test/mailer_instrumentation_test.rb
|
70
70
|
- test/model_instrumentation_test.rb
|
71
71
|
- test/namespaced_controller_instrumentation_test.rb
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- test/rails_app/app/controllers/application_controller.rb
|
80
80
|
- test/rails_app/app/controllers/posts_controller.rb
|
81
81
|
- test/rails_app/app/helpers/application_helper.rb
|
82
|
+
- test/rails_app/app/jobs/spam_detector_job.rb
|
82
83
|
- test/rails_app/app/mailers/.gitkeep
|
83
84
|
- test/rails_app/app/mailers/post_mailer.rb
|
84
85
|
- test/rails_app/app/models/.gitkeep
|
@@ -105,6 +106,7 @@ files:
|
|
105
106
|
- test/rails_app/config/initializers/wrap_parameters.rb
|
106
107
|
- test/rails_app/config/locales/en.yml
|
107
108
|
- test/rails_app/config/routes.rb
|
109
|
+
- test/rails_app/config/secrets.yml
|
108
110
|
- test/rails_app/db/migrate/20130417154459_create_posts.rb
|
109
111
|
- test/rails_app/db/schema.rb
|
110
112
|
- test/rails_app/db/seeds.rb
|
@@ -124,27 +126,26 @@ files:
|
|
124
126
|
homepage: https://github.com/jnunemaker/nunes
|
125
127
|
licenses:
|
126
128
|
- MIT
|
129
|
+
metadata: {}
|
127
130
|
post_install_message:
|
128
131
|
rdoc_options: []
|
129
132
|
require_paths:
|
130
133
|
- lib
|
131
134
|
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
-
none: false
|
133
135
|
requirements:
|
134
|
-
- -
|
136
|
+
- - ">="
|
135
137
|
- !ruby/object:Gem::Version
|
136
138
|
version: '0'
|
137
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
-
none: false
|
139
140
|
requirements:
|
140
|
-
- -
|
141
|
+
- - ">="
|
141
142
|
- !ruby/object:Gem::Version
|
142
143
|
version: '0'
|
143
144
|
requirements: []
|
144
145
|
rubyforge_project:
|
145
|
-
rubygems_version:
|
146
|
+
rubygems_version: 2.4.5.1
|
146
147
|
signing_key:
|
147
|
-
specification_version:
|
148
|
+
specification_version: 4
|
148
149
|
summary: The friendly gem that instruments everything for you, like I would if I could.
|
149
150
|
test_files:
|
150
151
|
- test/adapter_test.rb
|
@@ -154,6 +155,7 @@ test_files:
|
|
154
155
|
- test/fake_udp_socket_test.rb
|
155
156
|
- test/helper.rb
|
156
157
|
- test/instrumentable_test.rb
|
158
|
+
- test/job_instrumentation_test.rb
|
157
159
|
- test/mailer_instrumentation_test.rb
|
158
160
|
- test/model_instrumentation_test.rb
|
159
161
|
- test/namespaced_controller_instrumentation_test.rb
|
@@ -167,6 +169,7 @@ test_files:
|
|
167
169
|
- test/rails_app/app/controllers/application_controller.rb
|
168
170
|
- test/rails_app/app/controllers/posts_controller.rb
|
169
171
|
- test/rails_app/app/helpers/application_helper.rb
|
172
|
+
- test/rails_app/app/jobs/spam_detector_job.rb
|
170
173
|
- test/rails_app/app/mailers/.gitkeep
|
171
174
|
- test/rails_app/app/mailers/post_mailer.rb
|
172
175
|
- test/rails_app/app/models/.gitkeep
|
@@ -193,6 +196,7 @@ test_files:
|
|
193
196
|
- test/rails_app/config/initializers/wrap_parameters.rb
|
194
197
|
- test/rails_app/config/locales/en.yml
|
195
198
|
- test/rails_app/config/routes.rb
|
199
|
+
- test/rails_app/config/secrets.yml
|
196
200
|
- test/rails_app/db/migrate/20130417154459_create_posts.rb
|
197
201
|
- test/rails_app/db/schema.rb
|
198
202
|
- test/rails_app/db/seeds.rb
|