is_this_used 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gemfiles/rails_5.2.gemfile.lock +1 -1
- data/gemfiles/rails_6.0.gemfile.lock +1 -1
- data/gemfiles/rails_6.1.gemfile.lock +1 -1
- data/lib/is_this_used/cruft_tracker.rb +23 -18
- data/lib/is_this_used/util/log_suppressor.rb +14 -0
- data/lib/is_this_used/version.rb +1 -1
- data/lib/is_this_used.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1ec2b933a1f12af4ad52b177d002da0836fdec563fa7745d601ab98f2fbecf3
|
4
|
+
data.tar.gz: 6bb9f7d494a1c0419ef76b8a97f19a47d6b65387063ba712a58fe6e42940ef1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc6580e73c52a2550f49ef9c89f9fa12903ed5bf12c5a69d1bbf2ce71d50ce48f90463243be3397cdedc0f17aa8a4143117c504cafa21e472f5ffc1efc0bc01f
|
7
|
+
data.tar.gz: 46ec1e8ad793378629ac0276351631a277e383e80933b6a869d416d5f964fa37893f1a1fb843067e902031b996278b7879e04161e55e1b18ad0df0da5c07f1f0
|
@@ -39,7 +39,9 @@ module IsThisUsed
|
|
39
39
|
|
40
40
|
def self.filtered_stack
|
41
41
|
caller_locations.reject do |location|
|
42
|
-
location.path.match?(
|
42
|
+
location.path.match?(
|
43
|
+
%r{\/lib\/is_this_used\/(cruft_tracker.rb|util\/log_suppressor.rb)$}
|
44
|
+
)
|
43
45
|
end.map do |location|
|
44
46
|
{
|
45
47
|
path: location.path,
|
@@ -53,23 +55,26 @@ module IsThisUsed
|
|
53
55
|
|
54
56
|
class_methods do
|
55
57
|
def is_this_used?(method_name, method_type: nil)
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
58
|
+
IsThisUsed::Util::LogSuppressor.suppress_logging do
|
59
|
+
method_type ||= determine_method_type(method_name)
|
60
|
+
target_method = target_method(method_name, method_type)
|
61
|
+
|
62
|
+
potential_cruft =
|
63
|
+
PotentialCruft.find_or_create_by(
|
64
|
+
owner_name: self.name,
|
65
|
+
method_name: method_name,
|
66
|
+
method_type: method_type
|
67
|
+
)
|
68
|
+
|
69
|
+
target_method.owner.define_method target_method.name do |*args|
|
70
|
+
IsThisUsed::Util::LogSuppressor.suppress_logging do
|
71
|
+
CruftTracker::Recorder.record_invocation(potential_cruft)
|
72
|
+
end
|
73
|
+
if method_type == INSTANCE_METHOD
|
74
|
+
target_method.bind(self).call(*args)
|
75
|
+
else
|
76
|
+
target_method.call(*args)
|
77
|
+
end
|
73
78
|
end
|
74
79
|
end
|
75
80
|
rescue ActiveRecord::StatementInvalid => e
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module IsThisUsed
|
4
|
+
module Util
|
5
|
+
class LogSuppressor
|
6
|
+
def self.suppress_logging
|
7
|
+
initial_log_level = ActiveRecord::Base.logger.level
|
8
|
+
ActiveRecord::Base.logger.level = :error
|
9
|
+
yield
|
10
|
+
ActiveRecord::Base.logger.level = initial_log_level
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/is_this_used/version.rb
CHANGED
data/lib/is_this_used.rb
CHANGED
@@ -2,6 +2,7 @@ require 'is_this_used/version'
|
|
2
2
|
require 'is_this_used/cruft_tracker'
|
3
3
|
require 'is_this_used/models/potential_cruft'
|
4
4
|
require 'is_this_used/models/potential_cruft_stack'
|
5
|
+
require 'is_this_used/util/log_suppressor'
|
5
6
|
|
6
7
|
module IsThisUsed
|
7
8
|
class Error < StandardError; end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: is_this_used
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doug Hughes
|
@@ -238,6 +238,7 @@ files:
|
|
238
238
|
- lib/is_this_used/cruft_tracker.rb
|
239
239
|
- lib/is_this_used/models/potential_cruft.rb
|
240
240
|
- lib/is_this_used/models/potential_cruft_stack.rb
|
241
|
+
- lib/is_this_used/util/log_suppressor.rb
|
241
242
|
- lib/is_this_used/version.rb
|
242
243
|
- log/test.log
|
243
244
|
homepage: https://github.com/dhughes/is_this_used
|