rails_band 0.5.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -13
  3. data/lib/rails_band/action_view/event/render_collection.rb +1 -1
  4. data/lib/rails_band/action_view/event/render_layout.rb +18 -0
  5. data/lib/rails_band/action_view/event/render_partial.rb +1 -1
  6. data/lib/rails_band/action_view/event/render_template.rb +1 -1
  7. data/lib/rails_band/action_view/log_subscriber.rb +5 -0
  8. data/lib/rails_band/active_job/event/enqueue.rb +8 -0
  9. data/lib/rails_band/active_job/event/enqueue_at.rb +8 -0
  10. data/lib/rails_band/active_job/event/perform.rb +8 -0
  11. data/lib/rails_band/active_storage/event/analyze.rb +14 -0
  12. data/lib/rails_band/active_storage/event/preview.rb +16 -0
  13. data/lib/rails_band/active_storage/event/service_delete.rb +20 -0
  14. data/lib/rails_band/active_storage/event/service_delete_prefixed.rb +18 -0
  15. data/lib/rails_band/active_storage/event/service_download.rb +20 -0
  16. data/lib/rails_band/active_storage/event/service_download_chunk.rb +24 -0
  17. data/lib/rails_band/active_storage/event/service_exist.rb +26 -0
  18. data/lib/rails_band/active_storage/event/service_streaming_download.rb +20 -0
  19. data/lib/rails_band/active_storage/event/service_update_metadata.rb +28 -0
  20. data/lib/rails_band/active_storage/event/service_upload.rb +26 -0
  21. data/lib/rails_band/active_storage/event/service_url.rb +24 -0
  22. data/lib/rails_band/active_storage/event/transform.rb +11 -0
  23. data/lib/rails_band/active_storage/log_subscriber.rb +77 -0
  24. data/lib/rails_band/base_event.rb +2 -3
  25. data/lib/rails_band/deprecation_subscriber.rb +40 -0
  26. data/lib/rails_band/railtie.rb +10 -0
  27. data/lib/rails_band/version.rb +1 -1
  28. data/lib/rails_band.rb +5 -0
  29. metadata +25 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b347e10fae66e28648aca3427b76fe456fbaf21f1f45aaea5b4e3daed74bc44
4
- data.tar.gz: 102f48535f8cbf10db8b670d57cf671c8f0a839ae0e312fd706631b39e1ad55a
3
+ metadata.gz: b9edf37b23613a1499389b5c70ba7c1e80112ab6b8f8879d4983c26ed41092e5
4
+ data.tar.gz: aded5c59846b0f4befa0ad2bca8dd48b63f37af95adedd5bb38ae672bafd001e
5
5
  SHA512:
6
- metadata.gz: be4a7fbb271fd7bca9c47a23f7ee474b57ad06e047278476670d335fa22461a45a13d02e3d79be0578f5bcf40662aa7229e921e23a2919d9d838b9f718e1ff52
7
- data.tar.gz: fe2e8deba94abbd8f44ea0c940dd4f23f132952f668de68aa06a221eb465f9c78e4ba5d69151f192e20491492f9aaca86662801c89a891ac1c3ba4f199cf31bd
6
+ metadata.gz: fecc6a2eca4835e5717e1fbe2aff99f29f585dc091215d1be8a8d2455fc8fec664da2a50f61535d906b68e4429ea5a5acf45a27a7a10840115558302575b0bc8
7
+ data.tar.gz: 1a0986674189d1546bba3988b0271496bf006b83fc86a894a676dd9c97d8f5efa7b7a84d7b6e488efe55fdf0e97d016168c99ff8d47a92b5fa56b3b08a5d8b28
data/README.md CHANGED
@@ -82,7 +82,7 @@ These are Rails Instrumentation API hooks supported by this gem so far.
82
82
  | [`render_template.action_view`](https://guides.rubyonrails.org/active_support_instrumentation.html#render-template-action-view) | ✅ |
83
83
  | [`render_partial.action_view`](https://guides.rubyonrails.org/active_support_instrumentation.html#render-partial-action-view) | ✅ |
84
84
  | [`render_collection.action_view`](https://guides.rubyonrails.org/active_support_instrumentation.html#render-collection-action-view) | ✅ |
85
- | [`render_layout.action_view`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#render-layout-action-view) | |
85
+ | [`render_layout.action_view`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#render-layout-action-view) ||
86
86
 
87
87
  ### Active Record
88
88
 
@@ -139,17 +139,18 @@ These are Rails Instrumentation API hooks supported by this gem so far.
139
139
 
140
140
  | Event name | Supported |
141
141
  | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
142
- | [`service_upload.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-upload-active-storage) | |
143
- | [`service_streaming_download.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-streaming-download-active-storage) | |
144
- | [`service_download_chunk.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-download-chunk-active-storage) | |
145
- | [`service_download.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-download-active-storage) | |
146
- | [`service_delete.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-delete-active-storage) | |
147
- | [`service_delete_prefixed.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-delete-prefixed-active-storage) | |
148
- | [`service_exist.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-exist-active-storage) | |
149
- | [`service_url.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-url-active-storage) | |
150
- | [`service_update_metadata.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-update-metadata-active-storage) | |
151
- | [`preview.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#preview-active-storage) | |
152
- | [`analyze.active_storage`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#analyze-active-storage) | |
142
+ | [`service_upload.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-upload-active-storage) ||
143
+ | [`service_streaming_download.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-streaming-download-active-storage) ||
144
+ | [`service_download_chunk.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-download-chunk-active-storage) ||
145
+ | [`service_download.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-download-active-storage) ||
146
+ | [`service_delete.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-delete-active-storage) ||
147
+ | [`service_delete_prefixed.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-delete-prefixed-active-storage) ||
148
+ | [`service_exist.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-exist-active-storage) ||
149
+ | [`service_url.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-url-active-storage) ||
150
+ | [`service_update_metadata.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-update-metadata-active-storage) ||
151
+ | [`preview.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#preview-active-storage) ||
152
+ | [`transform.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#transform-active-storage) ||
153
+ | [`analyze.active_storage`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#analyze-active-storage) | ✅ |
153
154
 
154
155
  ### Railties
155
156
 
@@ -161,7 +162,7 @@ These are Rails Instrumentation API hooks supported by this gem so far.
161
162
 
162
163
  | Event name | Supported |
163
164
  | ----------------------------------------------------------------------------------------------------------- | --------- |
164
- | [`deprecation.rails`](https://guides.rubyonrails.org/active_support_instrumentation.html#deprecation-rails) | |
165
+ | [`deprecation.rails`](https://guides.rubyonrails.org/active_support_instrumentation.html#deprecation-rails) ||
165
166
 
166
167
  ## Contributing
167
168
 
@@ -16,7 +16,7 @@ module RailsBand
16
16
  def layout
17
17
  return @layout if defined? @layout
18
18
 
19
- @layout = @event.payload[:layout]&.yield_self { |layout| from_views(layout) }
19
+ @layout = @event.payload[:layout]&.then { |layout| from_views(layout) }
20
20
  end
21
21
 
22
22
  def count
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_band/action_view/from_views'
4
+
5
+ module RailsBand
6
+ module ActionView
7
+ module Event
8
+ # A wrapper for the event that is passed to `render_layout.action_view`.
9
+ class RenderLayout < BaseEvent
10
+ include FromViews
11
+
12
+ def identifier
13
+ @identifier ||= from_views(@event.payload.fetch(:identifier))
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -16,7 +16,7 @@ module RailsBand
16
16
  def layout
17
17
  return @layout if defined? @layout
18
18
 
19
- @layout = @event.payload[:layout]&.yield_self { |layout| from_views(layout) }
19
+ @layout = @event.payload[:layout]&.then { |layout| from_views(layout) }
20
20
  end
21
21
 
22
22
  def cache_hit
@@ -16,7 +16,7 @@ module RailsBand
16
16
  def layout
17
17
  return @layout if defined? @layout
18
18
 
19
- @layout = @event.payload[:layout]&.yield_self { |layout| from_views(layout) }
19
+ @layout = @event.payload[:layout]&.then { |layout| from_views(layout) }
20
20
  end
21
21
  end
22
22
  end
@@ -3,6 +3,7 @@
3
3
  require 'rails_band/action_view/event/render_template'
4
4
  require 'rails_band/action_view/event/render_partial'
5
5
  require 'rails_band/action_view/event/render_collection'
6
+ require 'rails_band/action_view/event/render_layout'
6
7
 
7
8
  module RailsBand
8
9
  module ActionView
@@ -22,6 +23,10 @@ module RailsBand
22
23
  consumer_of(__method__)&.call(Event::RenderCollection.new(event))
23
24
  end
24
25
 
26
+ def render_layout(event)
27
+ consumer_of(__method__)&.call(Event::RenderLayout.new(event))
28
+ end
29
+
25
30
  private
26
31
 
27
32
  def consumer_of(sub_event)
@@ -12,6 +12,14 @@ module RailsBand
12
12
  def job
13
13
  @job ||= @event.payload.fetch(:job)
14
14
  end
15
+
16
+ if Gem::Version.new(Rails.version) > Gem::Version.new('7.0')
17
+ define_method(:aborted) do
18
+ return @aborted if defined?(@aborted)
19
+
20
+ @aborted = @event.payload[:aborted]
21
+ end
22
+ end
15
23
  end
16
24
  end
17
25
  end
@@ -12,6 +12,14 @@ module RailsBand
12
12
  def job
13
13
  @job ||= @event.payload.fetch(:job)
14
14
  end
15
+
16
+ if Gem::Version.new(Rails.version) > Gem::Version.new('7.0')
17
+ define_method(:aborted) do
18
+ return @aborted if defined?(@aborted)
19
+
20
+ @aborted = @event.payload[:aborted]
21
+ end
22
+ end
15
23
  end
16
24
  end
17
25
  end
@@ -12,6 +12,14 @@ module RailsBand
12
12
  def job
13
13
  @job ||= @event.payload.fetch(:job)
14
14
  end
15
+
16
+ if Gem::Version.new(Rails.version) > Gem::Version.new('7.0')
17
+ define_method(:aborted) do
18
+ return @aborted if defined?(@aborted)
19
+
20
+ @aborted = @event.payload[:aborted]
21
+ end
22
+ end
15
23
  end
16
24
  end
17
25
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBand
4
+ module ActiveStorage
5
+ module Event
6
+ # A wrapper for the event that is passed to `analyze.active_storage`.
7
+ class Analyze < BaseEvent
8
+ def analyzer
9
+ @analyzer ||= @event.payload.fetch(:analyzer)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBand
4
+ module ActiveStorage
5
+ module Event
6
+ # A wrapper for the event that is passed to `preview.active_storage`.
7
+ class Preview < BaseEvent
8
+ def key
9
+ return @key if defined? @key
10
+
11
+ @key = @event.payload[:key]
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBand
4
+ module ActiveStorage
5
+ module Event
6
+ # A wrapper for the event that is passed to `service_delete.active_storage`.
7
+ class ServiceDelete < BaseEvent
8
+ def key
9
+ return @key if defined? @key
10
+
11
+ @key = @event.payload[:key]
12
+ end
13
+
14
+ def service
15
+ @service ||= @event.payload.fetch(:service)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBand
4
+ module ActiveStorage
5
+ module Event
6
+ # A wrapper for the event that is passed to `service_delete_prefixed.active_storage`.
7
+ class ServiceDeletePrefixed < BaseEvent
8
+ def prefix
9
+ @prefix ||= @event.payload.fetch(:prefix)
10
+ end
11
+
12
+ def service
13
+ @service ||= @event.payload.fetch(:service)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBand
4
+ module ActiveStorage
5
+ module Event
6
+ # A wrapper for the event that is passed to `service_download.active_storage`.
7
+ class ServiceDownload < BaseEvent
8
+ def key
9
+ return @key if defined? @key
10
+
11
+ @key = @event.payload[:key]
12
+ end
13
+
14
+ def service
15
+ @service ||= @event.payload.fetch(:service)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBand
4
+ module ActiveStorage
5
+ module Event
6
+ # A wrapper for the event that is passed to `service_download_chunk.active_storage`.
7
+ class ServiceDownloadChunk < BaseEvent
8
+ def key
9
+ return @key if defined? @key
10
+
11
+ @key = @event.payload[:key]
12
+ end
13
+
14
+ def service
15
+ @service ||= @event.payload.fetch(:service)
16
+ end
17
+
18
+ def range
19
+ @range ||= @event.payload.fetch(:range)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBand
4
+ module ActiveStorage
5
+ module Event
6
+ # A wrapper for the event that is passed to `service_exist.active_storage`.
7
+ class ServiceExist < BaseEvent
8
+ def key
9
+ return @key if defined? @key
10
+
11
+ @key = @event.payload[:key]
12
+ end
13
+
14
+ def service
15
+ @service ||= @event.payload.fetch(:service)
16
+ end
17
+
18
+ def exist
19
+ return @exist if defined? @exist
20
+
21
+ @exist = @event.payload.fetch(:exist)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBand
4
+ module ActiveStorage
5
+ module Event
6
+ # A wrapper for the event that is passed to `service_streaming_download.active_storage`.
7
+ class ServiceStreamingDownload < BaseEvent
8
+ def key
9
+ return @key if defined? @key
10
+
11
+ @key = @event.payload[:key]
12
+ end
13
+
14
+ def service
15
+ @service ||= @event.payload.fetch(:service)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBand
4
+ module ActiveStorage
5
+ module Event
6
+ # A wrapper for the event that is passed to `service_update_metadata.active_storage`.
7
+ class ServiceUpdateMetadata < BaseEvent
8
+ def key
9
+ return @key if defined? @key
10
+
11
+ @key = @event.payload[:key]
12
+ end
13
+
14
+ def service
15
+ @service ||= @event.payload.fetch(:service)
16
+ end
17
+
18
+ def content_type
19
+ @content_type ||= @event.payload.fetch(:content_type)
20
+ end
21
+
22
+ def disposition
23
+ @disposition ||= @event.payload.fetch(:disposition)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBand
4
+ module ActiveStorage
5
+ module Event
6
+ # A wrapper for the event that is passed to `service_upload.active_storage`.
7
+ class ServiceUpload < BaseEvent
8
+ def key
9
+ return @key if defined? @key
10
+
11
+ @key = @event.payload[:key]
12
+ end
13
+
14
+ def checksum
15
+ return @checksum if defined? @checksum
16
+
17
+ @checksum = @event.payload[:checksum]
18
+ end
19
+
20
+ def service
21
+ @service ||= @event.payload.fetch(:service)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBand
4
+ module ActiveStorage
5
+ module Event
6
+ # A wrapper for the event that is passed to `service_url.active_storage`.
7
+ class ServiceUrl < BaseEvent
8
+ def key
9
+ return @key if defined? @key
10
+
11
+ @key = @event.payload[:key]
12
+ end
13
+
14
+ def service
15
+ @service ||= @event.payload.fetch(:service)
16
+ end
17
+
18
+ def url
19
+ @url ||= @event.payload.fetch(:url)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBand
4
+ module ActiveStorage
5
+ module Event
6
+ # A wrapper for the event that is passed to `transform.active_storage`.
7
+ class Transform < BaseEvent
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_band/active_storage/event/service_upload'
4
+ require 'rails_band/active_storage/event/service_streaming_download'
5
+ require 'rails_band/active_storage/event/service_download_chunk'
6
+ require 'rails_band/active_storage/event/service_download'
7
+ require 'rails_band/active_storage/event/service_delete'
8
+ require 'rails_band/active_storage/event/service_delete_prefixed'
9
+ require 'rails_band/active_storage/event/service_exist'
10
+ require 'rails_band/active_storage/event/service_url'
11
+ require 'rails_band/active_storage/event/service_update_metadata'
12
+ require 'rails_band/active_storage/event/preview'
13
+ require 'rails_band/active_storage/event/transform'
14
+ require 'rails_band/active_storage/event/analyze'
15
+
16
+ module RailsBand
17
+ module ActiveStorage
18
+ # The custom LogSubscriber for ActiveStorage.
19
+ class LogSubscriber < ::ActiveSupport::LogSubscriber
20
+ mattr_accessor :consumers
21
+
22
+ def service_upload(event)
23
+ consumer_of(__method__)&.call(Event::ServiceUpload.new(event))
24
+ end
25
+
26
+ def service_streaming_download(event)
27
+ consumer_of(__method__)&.call(Event::ServiceStreamingDownload.new(event))
28
+ end
29
+
30
+ def service_download_chunk(event)
31
+ consumer_of(__method__)&.call(Event::ServiceDownloadChunk.new(event))
32
+ end
33
+
34
+ def service_download(event)
35
+ consumer_of(__method__)&.call(Event::ServiceDownload.new(event))
36
+ end
37
+
38
+ def service_delete(event)
39
+ consumer_of(__method__)&.call(Event::ServiceDelete.new(event))
40
+ end
41
+
42
+ def service_delete_prefixed(event)
43
+ consumer_of(__method__)&.call(Event::ServiceDeletePrefixed.new(event))
44
+ end
45
+
46
+ def service_exist(event)
47
+ consumer_of(__method__)&.call(Event::ServiceExist.new(event))
48
+ end
49
+
50
+ def service_url(event)
51
+ consumer_of(__method__)&.call(Event::ServiceUrl.new(event))
52
+ end
53
+
54
+ def service_update_metadata(event)
55
+ consumer_of(__method__)&.call(Event::ServiceUpdateMetadata.new(event))
56
+ end
57
+
58
+ def preview(event)
59
+ consumer_of(__method__)&.call(Event::Preview.new(event))
60
+ end
61
+
62
+ def transform(event)
63
+ consumer_of(__method__)&.call(Event::Transform.new(event))
64
+ end
65
+
66
+ def analyze(event)
67
+ consumer_of(__method__)&.call(Event::Analyze.new(event))
68
+ end
69
+
70
+ private
71
+
72
+ def consumer_of(sub_event)
73
+ consumers[:"#{sub_event}.active_storage"] || consumers[:active_storage] || consumers[:default]
74
+ end
75
+ end
76
+ end
77
+ end
@@ -3,7 +3,7 @@
3
3
  module RailsBand
4
4
  # The base class of each Event class.
5
5
  class BaseEvent
6
- attr_reader :name, :time, :end, :transaction_id, :children,
6
+ attr_reader :name, :time, :end, :transaction_id,
7
7
  :cpu_time, :idle_time, :allocations, :duration
8
8
 
9
9
  # @param event [ActiveSupport::Notifications::Event]
@@ -13,7 +13,6 @@ module RailsBand
13
13
  @time = event.time
14
14
  @end = event.end
15
15
  @transaction_id = event.transaction_id
16
- @children = event.children
17
16
  @cpu_time = event.cpu_time
18
17
  @idle_time = event.idle_time
19
18
  @allocations = event.allocations
@@ -22,7 +21,7 @@ module RailsBand
22
21
 
23
22
  def to_h
24
23
  @to_h ||= {
25
- name: @name, time: @time, end: @end, transaction_id: @transaction_id, children: @children,
24
+ name: @name, time: @time, end: @end, transaction_id: @transaction_id,
26
25
  cpu_time: @cpu_time, idle_time: @idle_time, allocations: @allocations, duration: @duration
27
26
  }.merge!(
28
27
  public_methods(false).reject { |meth| non_hash_keys.include?(meth) }.each_with_object({}) do |meth, h|
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBand
4
+ # DeprecationSubscriber is responsible for logging deprecation warnings.
5
+ class DeprecationSubscriber < ::ActiveSupport::LogSubscriber
6
+ # DeprecationEvent is a wrapper around a deprecation notification event.
7
+ class DeprecationEvent < BaseEvent
8
+ def message
9
+ @message ||= @event.payload.fetch(:message)
10
+ end
11
+
12
+ def callstack
13
+ @callstack ||= @event.payload.fetch(:callstack)
14
+ end
15
+
16
+ def gem_name
17
+ @gem_name ||= @event.payload.fetch(:gem_name)
18
+ end
19
+
20
+ def deprecation_horizon
21
+ @deprecation_horizon ||= @event.payload.fetch(:deprecation_horizon)
22
+ end
23
+ end
24
+
25
+ mattr_accessor :consumers
26
+
27
+ def deprecation(event)
28
+ consumer&.call(DeprecationEvent.new(event))
29
+ end
30
+
31
+ private
32
+
33
+ def consumer
34
+ # HACK: ActiveSupport::Subscriber has the instance variable @namespace, but it's not documented.
35
+ # This hack might possibly break in the future.
36
+ namespace = self.class.instance_variable_get(:@namespace)
37
+ consumers[:"deprecation.#{namespace}"] || consumers[:deprecation] || consumers[:default]
38
+ end
39
+ end
40
+ end
@@ -31,11 +31,21 @@ module RailsBand
31
31
  end
32
32
 
33
33
  if defined?(::ActionCable)
34
+ RailsBand::ActionCable::LogSubscriber.consumers = consumers
34
35
  RailsBand::ActionCable::LogSubscriber.attach_to :action_cable
35
36
  end
36
37
 
38
+ if defined?(::ActiveStorage)
39
+ RailsBand::ActiveStorage::LogSubscriber.consumers = consumers
40
+ RailsBand::ActiveStorage::LogSubscriber.attach_to :active_storage
41
+ end
42
+
43
+ RailsBand::ActiveSupport::LogSubscriber.consumers = consumers
37
44
  RailsBand::ActiveSupport::LogSubscriber.attach_to :active_support
38
45
 
46
+ RailsBand::DeprecationSubscriber.consumers = consumers
47
+ RailsBand::DeprecationSubscriber.attach_to :rails
48
+
39
49
  if defined?(::ActiveJob)
40
50
  require 'active_job/logging'
41
51
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsBand
4
- VERSION = '0.5.0'
4
+ VERSION = '0.7.0'
5
5
  end
data/lib/rails_band.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require 'rails_band/version'
4
4
  require 'rails_band/configuration'
5
5
  require 'rails_band/base_event'
6
+ require 'rails_band/deprecation_subscriber'
6
7
  require 'rails_band/railtie'
7
8
 
8
9
  # Rails::Band unsubscribes all default LogSubscribers from Rails Instrumentation API,
@@ -35,4 +36,8 @@ module RailsBand
35
36
  module ActionCable
36
37
  autoload :LogSubscriber, 'rails_band/action_cable/log_subscriber'
37
38
  end
39
+
40
+ module ActiveStorage
41
+ autoload :LogSubscriber, 'rails_band/active_storage/log_subscriber'
42
+ end
38
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_band
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yutaka Kamei
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-25 00:00:00.000000000 Z
11
+ date: 2022-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '6.0'
20
+ - - "!="
21
+ - !ruby/object:Gem::Version
22
+ version: 7.0.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +27,9 @@ dependencies:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '6.0'
30
+ - - "!="
31
+ - !ruby/object:Gem::Version
32
+ version: 7.0.0
27
33
  description: A Rails plugin to facilitate the use of Rails Instrumentation API.
28
34
  email:
29
35
  - kamei@yykamei.me
@@ -57,6 +63,7 @@ files:
57
63
  - lib/rails_band/action_mailer/event/process.rb
58
64
  - lib/rails_band/action_mailer/log_subscriber.rb
59
65
  - lib/rails_band/action_view/event/render_collection.rb
66
+ - lib/rails_band/action_view/event/render_layout.rb
60
67
  - lib/rails_band/action_view/event/render_partial.rb
61
68
  - lib/rails_band/action_view/event/render_template.rb
62
69
  - lib/rails_band/action_view/from_views.rb
@@ -73,6 +80,19 @@ files:
73
80
  - lib/rails_band/active_record/event/sql.rb
74
81
  - lib/rails_band/active_record/event/strict_loading_violation.rb
75
82
  - lib/rails_band/active_record/log_subscriber.rb
83
+ - lib/rails_band/active_storage/event/analyze.rb
84
+ - lib/rails_band/active_storage/event/preview.rb
85
+ - lib/rails_band/active_storage/event/service_delete.rb
86
+ - lib/rails_band/active_storage/event/service_delete_prefixed.rb
87
+ - lib/rails_band/active_storage/event/service_download.rb
88
+ - lib/rails_band/active_storage/event/service_download_chunk.rb
89
+ - lib/rails_band/active_storage/event/service_exist.rb
90
+ - lib/rails_band/active_storage/event/service_streaming_download.rb
91
+ - lib/rails_band/active_storage/event/service_update_metadata.rb
92
+ - lib/rails_band/active_storage/event/service_upload.rb
93
+ - lib/rails_band/active_storage/event/service_url.rb
94
+ - lib/rails_band/active_storage/event/transform.rb
95
+ - lib/rails_band/active_storage/log_subscriber.rb
76
96
  - lib/rails_band/active_support/event/cache_delete.rb
77
97
  - lib/rails_band/active_support/event/cache_delete_multi.rb
78
98
  - lib/rails_band/active_support/event/cache_exist.rb
@@ -85,6 +105,7 @@ files:
85
105
  - lib/rails_band/active_support/log_subscriber.rb
86
106
  - lib/rails_band/base_event.rb
87
107
  - lib/rails_band/configuration.rb
108
+ - lib/rails_band/deprecation_subscriber.rb
88
109
  - lib/rails_band/railtie.rb
89
110
  - lib/rails_band/version.rb
90
111
  homepage: https://github.com/yykamei/rails_band
@@ -94,6 +115,7 @@ metadata:
94
115
  homepage_uri: https://github.com/yykamei/rails_band
95
116
  source_code_uri: https://github.com/yykamei/rails_band
96
117
  changelog_uri: https://github.com/yykamei/rails_band/blob/main/CHANGELOG.md
118
+ rubygems_mfa_required: 'true'
97
119
  post_install_message:
98
120
  rdoc_options: []
99
121
  require_paths:
@@ -109,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
131
  - !ruby/object:Gem::Version
110
132
  version: '0'
111
133
  requirements: []
112
- rubygems_version: 3.2.32
134
+ rubygems_version: 3.3.7
113
135
  signing_key:
114
136
  specification_version: 4
115
137
  summary: Easy-to-use Rails Instrumentation API