deprecation_collector 0.5.0 → 0.5.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
  SHA256:
3
- metadata.gz: 7f62a11c42b2d8d6ee4236c98960b452d5aa2c0ec76d83d6215101de55edf6a8
4
- data.tar.gz: aff231737c13f8e47c63e60706cbee894d50da276caff00ec4898c766da9ee19
3
+ metadata.gz: 60dd6c4c552576ae19c4cb2a84232c5f7e6b83b0d8fb8e11b3a98bc5abf69bdf
4
+ data.tar.gz: f9f638c079489229bed7e525caaed0fb995b19ceff250146644d405462739e39
5
5
  SHA512:
6
- metadata.gz: d053f33b41ca1dd5b20b81069bef9cf178f4f10fe7a00f193d8a5bdb4e1aa30267223df74bfe3abd234dd08ba2ccfaef757b5febbe8546393c808c1b7b68ecc7
7
- data.tar.gz: b4c259673e8b2d4b19de8e3f259563ad19e34381c43b1dfb141e9193bc1f57606eb2b48c81dfb88b699440bbf4f5922a2af92c4ead1c066a90e468bb82a973c0
6
+ metadata.gz: b80b9bcfdbbccaf112b447f3ab04960f042ce98c74b53b35b76e9c4f3740a37fa1cc894ce632e7206c76bcb7eaaf8e13f596bcaa53398eb611fcd245a8b77214
7
+ data.tar.gz: 35992cd452d01b83a5884299873bd2d80c2e5d42f8977d77b72e0635f24d5bda475200eed936e74102181205575d62e511085606af3868b059377780e9efc8e1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- deprecation_collector (0.5.0)
4
+ deprecation_collector (0.5.1)
5
5
  redis (>= 3.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- deprecation_collector (0.5.0)
4
+ deprecation_collector (0.5.1)
5
5
  redis (>= 3.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- deprecation_collector (0.5.0)
4
+ deprecation_collector (0.5.1)
5
5
  redis (>= 3.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- deprecation_collector (0.5.0)
4
+ deprecation_collector (0.5.1)
5
5
  redis (>= 3.0)
6
6
 
7
7
  GEM
@@ -7,6 +7,8 @@ class DeprecationCollector
7
7
  # :nodoc:
8
8
  class Base
9
9
  # rubocop:disable Style/SingleLineMethods
10
+ def initialize(**); end
11
+ def support_disabling?; false; end
10
12
  def enabled?; true; end
11
13
  def enable; end
12
14
  def disable; end
@@ -16,6 +18,7 @@ class DeprecationCollector
16
18
 
17
19
  def delete(digests); end
18
20
  def clear(enable: false); end
21
+ def flush(**); end
19
22
 
20
23
  def store(_deprecation); raise("Not implemented"); end
21
24
  # rubocop:enable Style/SingleLineMethods
@@ -32,9 +35,9 @@ class DeprecationCollector
32
35
  class Redis < Base
33
36
  attr_accessor :write_interval, :write_interval_jitter, :redis, :count
34
37
 
35
- def initialize(redis, mutex: nil, count: false, write_interval: 900, write_interval_jitter: 60,
38
+ def initialize(redis: nil, mutex: nil, count: false, write_interval: 900, write_interval_jitter: 60,
36
39
  key_prefix: nil)
37
- super()
40
+ super
38
41
  @key_prefix = key_prefix || "deprecations"
39
42
  @redis = redis
40
43
  @last_write_time = current_time
@@ -47,6 +50,10 @@ class DeprecationCollector
47
50
  @known_digests = Set.new
48
51
  end
49
52
 
53
+ def support_disabling?
54
+ true
55
+ end
56
+
50
57
  def unsent_deprecations
51
58
  @deprecations
52
59
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class DeprecationCollector
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.1"
5
5
  end
@@ -65,7 +65,10 @@ class DeprecationCollector
65
65
  msg = deprecation[:message]
66
66
  return :kwargs if msg.include?("Using the last argument as keyword parameters is deprecated") ||
67
67
  msg.include?("Passing the keyword argument as the last hash parameter is deprecated")
68
- return :test if msg.include?("trigger_kwargs_error_warning") || msg.include?("trigger_rails_deprecation")
68
+ end
69
+
70
+ def test_deprecation?(deprecation)
71
+ %w[trigger_kwargs_error_warning trigger_rails_deprecation].any? { |method| deprecation[:message]}
69
72
  end
70
73
 
71
74
  def deprecation_tags(deprecation)
@@ -73,6 +76,7 @@ class DeprecationCollector
73
76
  if (detected_tag = detect_tag(deprecation))
74
77
  tags << detected_tag
75
78
  end
79
+ tags << :test if test_deprecation?(deprecation)
76
80
  tags << deprecation[:realm] if deprecation[:realm] && deprecation[:realm] != "rails"
77
81
  tags.merge(deprecation.dig(:notes, :tags) || [])
78
82
 
@@ -6,7 +6,8 @@ _buf = ''; _buf << ("<header class=\"mb-3\"><h1>Deprecations</h1><a class=\"btn
6
6
  ;
7
7
  ;
8
8
  ;
9
- ; if DeprecationCollector.instance.enabled_in_redis?;
9
+ ; if DeprecationCollector.instance.storage.support_disabling?;
10
+ ; if DeprecationCollector.instance.storage.enabled?;
10
11
  ;
11
12
  ;
12
13
  ;
@@ -16,7 +17,7 @@ _buf = ''; _buf << ("<header class=\"mb-3\"><h1>Deprecations</h1><a class=\"btn
16
17
  ;
17
18
  ; _buf << ("<a class=\"btn btn-secondary\" data-method=\"post\"".freeze); _slim_codeattributes4 = enable_deprecations_path; if _slim_codeattributes4; if _slim_codeattributes4 == true; _buf << (" href=\"\"".freeze); else; _buf << (" href=\"".freeze); _buf << ((::Temple::Utils.escape_html((_slim_codeattributes4))).to_s); _buf << ("\"".freeze); end; end; _buf << (" rel=\"nofollow\">Turn on (after workers restart)</a> ".freeze);
18
19
  ;
19
- ; end; _buf << ("</header><main><table class=\"table table-striped\"><tr><th>Count</th><th>Message</th><th>Location</th><th>Ruby/Rails</th></tr>".freeze);
20
+ ; end; end; _buf << ("</header><main><table class=\"table table-striped\"><tr><th>Count</th><th>Message</th><th>Location</th><th>Ruby/Rails</th></tr>".freeze);
20
21
  ;
21
22
  ;
22
23
  ;
@@ -78,35 +78,33 @@ class DeprecationCollector
78
78
  self.count = false
79
79
  self.write_interval = 900 # 15.minutes
80
80
  self.write_interval_jitter = 60
81
+ self.key_prefix = "deprecations"
81
82
  @context_saver = nil
82
83
  end
83
84
 
84
85
  def redis=(val)
85
86
  raise ArgumentError, "redis should not be nil" unless val
86
-
87
- @storage ||= DeprecationCollector::Storage::Redis.new(val, mutex: @instance_mutex, count: count, # rubocop:disable Naming/MemoizedInstanceVariableName
88
- write_interval: write_interval,
89
- write_interval_jitter: write_interval_jitter,
90
- key_prefix: key_prefix)
87
+ self.storage = DeprecationCollector::Storage::Redis unless storage.respond_to?(:redis=)
88
+ storage.redis = val
91
89
  end
92
90
 
93
91
  def count=(val)
94
- storage.count = val if storage.respond_to?(:count)
92
+ storage.count = val if storage.respond_to?(:count=)
95
93
  @count = val
96
94
  end
97
95
 
98
96
  def write_interval=(val)
99
- storage.write_interval = val if storage.respond_to?(:write_interval)
97
+ storage.write_interval = val if storage.respond_to?(:write_interval=)
100
98
  @write_interval = val
101
99
  end
102
100
 
103
101
  def write_interval_jitter=(val)
104
- storage.write_interval_jitter = val if storage.respond_to?(:write_interval_jitter)
102
+ storage.write_interval_jitter = val if storage.respond_to?(:write_interval_jitter=)
105
103
  @write_interval_jitter = val
106
104
  end
107
105
 
108
106
  def key_prefix=(val)
109
- storage.key_prefix = val
107
+ storage.key_prefix = val if storage.respond_to?(:key_prefix=)
110
108
  @key_prefix = val
111
109
  end
112
110
 
@@ -114,6 +112,14 @@ class DeprecationCollector
114
112
  @storage ||= DeprecationCollector::Storage::StdErr.new
115
113
  end
116
114
 
115
+ def storage=(val)
116
+ return @storage = val unless val.is_a?(Class)
117
+
118
+ @storage = val.new(mutex: @instance_mutex, count: count,
119
+ write_interval: write_interval, write_interval_jitter: write_interval_jitter,
120
+ key_prefix: key_prefix)
121
+ end
122
+
117
123
  def ignored_messages=(val)
118
124
  @ignore_message_regexp = (val && Regexp.union(val)) || nil
119
125
  end
@@ -173,6 +179,7 @@ class DeprecationCollector
173
179
  storage.clear(enable: enable)
174
180
  end
175
181
 
182
+ # deprecated, use storage.enabled?
176
183
  def enabled_in_redis?
177
184
  storage.enabled?
178
185
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deprecation_collector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasily Fedoseyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-04 00:00:00.000000000 Z
11
+ date: 2023-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis