marginalia 1.8.0 → 1.10.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 +5 -5
- data/.ruby-version +1 -1
- data/.travis.yml +18 -0
- data/lib/marginalia.rb +21 -10
- data/lib/marginalia/comment.rb +9 -4
- data/marginalia.gemspec +2 -2
- data/test/query_comments_test.rb +22 -1
- metadata +6 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8dba7f58a767008578f36af3a2bedc77139f11b62025e1dcd022c1ebd3658c3c
|
4
|
+
data.tar.gz: 9d4728cbc7b673514cce7076a60c28592646fbc68ac59d8310c7ebe3aa71eac6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35dfdc97e0745484719266a9c616c257072dfbdf0ee8ff6b4c7055d051510a562bf12d863eae670c382f14eda7ba895f4a988baa031ea43904fd9a2a31fd7c0e
|
7
|
+
data.tar.gz: 3fbfdeacc57e3a8e78490e991527610a3249c0b3e748de7410a427e9e085e6b420a12d916b0c15d87a7240743a81e9be14727508743d25d7cc82d850924ad126
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.6
|
data/.travis.yml
CHANGED
@@ -1,10 +1,21 @@
|
|
1
1
|
language: ruby
|
2
2
|
sudo: false
|
3
3
|
|
4
|
+
services:
|
5
|
+
- mysql
|
6
|
+
- postgresql
|
7
|
+
|
4
8
|
rvm:
|
5
9
|
- 2.2
|
6
10
|
- 2.3
|
7
11
|
- 2.4
|
12
|
+
- 2.5
|
13
|
+
- 2.6
|
14
|
+
- 2.7
|
15
|
+
|
16
|
+
services:
|
17
|
+
- mysql
|
18
|
+
- postgresql
|
8
19
|
|
9
20
|
script: "bundle exec rake db:reset test:all"
|
10
21
|
|
@@ -14,3 +25,10 @@ gemfile:
|
|
14
25
|
- gemfiles/5.0.gemfile
|
15
26
|
- gemfiles/5.1.gemfile
|
16
27
|
- gemfiles/5.2.gemfile
|
28
|
+
|
29
|
+
matrix:
|
30
|
+
exclude:
|
31
|
+
- rvm: 2.7
|
32
|
+
gemfile: gemfiles/4.2.gemfile
|
33
|
+
- rvm: 2.7
|
34
|
+
gemfile: gemfiles/4.2.api.gemfile
|
data/lib/marginalia.rb
CHANGED
@@ -67,32 +67,43 @@ module Marginalia
|
|
67
67
|
sql
|
68
68
|
end
|
69
69
|
|
70
|
-
def execute_with_marginalia(sql,
|
71
|
-
execute_without_marginalia(annotate_sql(sql),
|
70
|
+
def execute_with_marginalia(sql, *args)
|
71
|
+
execute_without_marginalia(annotate_sql(sql), *args)
|
72
72
|
end
|
73
|
+
ruby2_keywords :execute_with_marginalia if respond_to?(:ruby2_keywords, true)
|
73
74
|
|
74
|
-
def exec_query_with_marginalia(sql,
|
75
|
-
exec_query_without_marginalia(annotate_sql(sql),
|
75
|
+
def exec_query_with_marginalia(sql, *args)
|
76
|
+
exec_query_without_marginalia(annotate_sql(sql), *args)
|
76
77
|
end
|
78
|
+
ruby2_keywords :exec_query_with_marginalia if respond_to?(:ruby2_keywords, true)
|
77
79
|
|
78
80
|
if ActiveRecord::VERSION::MAJOR >= 5
|
79
|
-
def exec_query_with_marginalia(sql,
|
81
|
+
def exec_query_with_marginalia(sql, *args, **options)
|
80
82
|
options[:prepare] ||= false
|
81
|
-
exec_query_without_marginalia(annotate_sql(sql),
|
83
|
+
exec_query_without_marginalia(annotate_sql(sql), *args, **options)
|
82
84
|
end
|
83
85
|
end
|
84
86
|
|
85
|
-
def exec_delete_with_marginalia(sql,
|
86
|
-
exec_delete_without_marginalia(annotate_sql(sql),
|
87
|
+
def exec_delete_with_marginalia(sql, *args)
|
88
|
+
exec_delete_without_marginalia(annotate_sql(sql), *args)
|
87
89
|
end
|
90
|
+
ruby2_keywords :exec_delete_with_marginalia if respond_to?(:ruby2_keywords, true)
|
88
91
|
|
89
|
-
def exec_update_with_marginalia(sql,
|
90
|
-
exec_update_without_marginalia(annotate_sql(sql),
|
92
|
+
def exec_update_with_marginalia(sql, *args)
|
93
|
+
exec_update_without_marginalia(annotate_sql(sql), *args)
|
91
94
|
end
|
95
|
+
ruby2_keywords :exec_update_with_marginalia if respond_to?(:ruby2_keywords, true)
|
92
96
|
|
97
|
+
if ActiveRecord::VERSION::MAJOR >= 5
|
93
98
|
def execute_and_clear_with_marginalia(sql, *args, &block)
|
94
99
|
execute_and_clear_without_marginalia(annotate_sql(sql), *args, &block)
|
95
100
|
end
|
101
|
+
ruby2_keywords :execute_and_clear_with_marginalia if respond_to?(:ruby2_keywords, true)
|
102
|
+
else
|
103
|
+
def execute_and_clear_with_marginalia(sql, *args, &block)
|
104
|
+
execute_and_clear_without_marginalia(annotate_sql(sql), *args, &block)
|
105
|
+
end
|
106
|
+
end
|
96
107
|
end
|
97
108
|
|
98
109
|
module ActionControllerInstrumentation
|
data/lib/marginalia/comment.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'socket'
|
2
4
|
|
3
5
|
module Marginalia
|
@@ -18,11 +20,11 @@ module Marginalia
|
|
18
20
|
end
|
19
21
|
|
20
22
|
def self.construct_comment
|
21
|
-
ret =
|
23
|
+
ret = String.new
|
22
24
|
self.components.each do |c|
|
23
25
|
component_value = self.send(c)
|
24
26
|
if component_value.present?
|
25
|
-
ret << "#{c
|
27
|
+
ret << "#{c}:#{component_value},"
|
26
28
|
end
|
27
29
|
end
|
28
30
|
ret.chop!
|
@@ -102,11 +104,14 @@ module Marginalia
|
|
102
104
|
end
|
103
105
|
|
104
106
|
def self.sidekiq_job
|
105
|
-
marginalia_job["class"] if marginalia_job
|
107
|
+
marginalia_job["class"] if marginalia_job && marginalia_job.respond_to?(:[])
|
106
108
|
end
|
107
109
|
|
110
|
+
DEFAULT_LINES_TO_IGNORE_REGEX = %r{\.rvm|/ruby/gems/|vendor/|marginalia|rbenv|monitor\.rb.*mon_synchronize}
|
111
|
+
|
108
112
|
def self.line
|
109
|
-
Marginalia::Comment.lines_to_ignore ||=
|
113
|
+
Marginalia::Comment.lines_to_ignore ||= DEFAULT_LINES_TO_IGNORE_REGEX
|
114
|
+
|
110
115
|
last_line = caller.detect do |line|
|
111
116
|
line !~ Marginalia::Comment.lines_to_ignore
|
112
117
|
end
|
data/marginalia.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.authors = ["Noah Lorang", "Nick Quaranto", "Taylor Weibley"]
|
3
|
-
gem.email = ["
|
3
|
+
gem.email = ["arthurnn@github.com"]
|
4
4
|
gem.homepage = "https://github.com/basecamp/marginalia"
|
5
5
|
|
6
6
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.test_files = `git ls-files -- {test}/*`.split("\n")
|
9
9
|
gem.name = "marginalia"
|
10
10
|
gem.require_paths = ["lib"]
|
11
|
-
gem.version = "1.
|
11
|
+
gem.version = "1.10.1"
|
12
12
|
gem.license = "MIT"
|
13
13
|
|
14
14
|
gem.add_runtime_dependency "actionpack", ">= 2.3"
|
data/test/query_comments_test.rb
CHANGED
@@ -121,6 +121,7 @@ class MarginaliaTest < MiniTest::Test
|
|
121
121
|
@queries << args.last[:sql]
|
122
122
|
end
|
123
123
|
@env = Rack::MockRequest.env_for('/')
|
124
|
+
ActiveJob::Base.queue_adapter = :inline
|
124
125
|
end
|
125
126
|
|
126
127
|
def test_double_annotate
|
@@ -215,6 +216,16 @@ class MarginaliaTest < MiniTest::Test
|
|
215
216
|
assert_match %r{/\*line:.*lib/marginalia/comment.rb:[0-9]+}, @queries.first
|
216
217
|
end
|
217
218
|
|
219
|
+
def test_default_lines_to_ignore_regex
|
220
|
+
line = "/gems/a_gem/lib/a_gem.rb:1:in `some_method'"
|
221
|
+
call_stack = [line] + caller
|
222
|
+
|
223
|
+
assert_match(
|
224
|
+
call_stack.detect { |line| line !~ Marginalia::Comment::DEFAULT_LINES_TO_IGNORE_REGEX },
|
225
|
+
line
|
226
|
+
)
|
227
|
+
end
|
228
|
+
|
218
229
|
def test_hostname_and_pid
|
219
230
|
Marginalia::Comment.components = [:hostname, :pid]
|
220
231
|
PostsController.action(:driver_only).call(@env)
|
@@ -282,6 +293,15 @@ class MarginaliaTest < MiniTest::Test
|
|
282
293
|
Post.first
|
283
294
|
refute_match %{job:PostsJob}, @queries.last
|
284
295
|
end
|
296
|
+
|
297
|
+
def test_active_job_with_sidekiq
|
298
|
+
Marginalia::Comment.components = [:job, :sidekiq_job]
|
299
|
+
PostsJob.perform_later
|
300
|
+
assert_match %{job:PostsJob}, @queries.first
|
301
|
+
|
302
|
+
Post.first
|
303
|
+
refute_match %{job:PostsJob}, @queries.last
|
304
|
+
end
|
285
305
|
end
|
286
306
|
|
287
307
|
def test_sidekiq_job
|
@@ -290,13 +310,14 @@ class MarginaliaTest < MiniTest::Test
|
|
290
310
|
|
291
311
|
# Test harness does not run Sidekiq middlewares by default so include testing middleware.
|
292
312
|
Sidekiq::Testing.server_middleware do |chain|
|
293
|
-
|
313
|
+
chain.add Marginalia::SidekiqInstrumentation::Middleware
|
294
314
|
end
|
295
315
|
|
296
316
|
Sidekiq::Testing.fake!
|
297
317
|
PostsSidekiqJob.perform_async
|
298
318
|
PostsSidekiqJob.drain
|
299
319
|
assert_match %{sidekiq_job:PostsSidekiqJob}, @queries.first
|
320
|
+
|
300
321
|
Post.first
|
301
322
|
refute_match %{sidekiq_job:PostsSidekiqJob}, @queries.last
|
302
323
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marginalia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noah Lorang
|
8
8
|
- Nick Quaranto
|
9
9
|
- Taylor Weibley
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-02-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: actionpack
|
@@ -140,7 +140,6 @@ dependencies:
|
|
140
140
|
version: '0'
|
141
141
|
description: Attach comments to your ActiveRecord queries.
|
142
142
|
email:
|
143
|
-
- noah@37signals.com
|
144
143
|
- arthurnn@github.com
|
145
144
|
executables: []
|
146
145
|
extensions: []
|
@@ -169,7 +168,7 @@ homepage: https://github.com/basecamp/marginalia
|
|
169
168
|
licenses:
|
170
169
|
- MIT
|
171
170
|
metadata: {}
|
172
|
-
post_install_message:
|
171
|
+
post_install_message:
|
173
172
|
rdoc_options: []
|
174
173
|
require_paths:
|
175
174
|
- lib
|
@@ -184,9 +183,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
183
|
- !ruby/object:Gem::Version
|
185
184
|
version: '0'
|
186
185
|
requirements: []
|
187
|
-
|
188
|
-
|
189
|
-
signing_key:
|
186
|
+
rubygems_version: 3.0.3
|
187
|
+
signing_key:
|
190
188
|
specification_version: 4
|
191
189
|
summary: Attach comments to your ActiveRecord queries.
|
192
190
|
test_files: []
|