rails_band 0.4.0 → 0.5.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2068455c0eab607cbdc32392362c6a181b0789d8bd41e77201c7bb06e3eb8ba8
4
- data.tar.gz: c27bcf5e8dcd06c7f87f164ca1a7f58e537b5910bba7b0a98a7ea3a003649fad
3
+ metadata.gz: 3b347e10fae66e28648aca3427b76fe456fbaf21f1f45aaea5b4e3daed74bc44
4
+ data.tar.gz: 102f48535f8cbf10db8b670d57cf671c8f0a839ae0e312fd706631b39e1ad55a
5
5
  SHA512:
6
- metadata.gz: 936e787242f04a6d7d81bf29993d87bba1187cf27d3e706cb0de672dd27100e99ab029da802871bd044ad722801a4fa6f4f6f22b33e3f1c160935dce10c9b369
7
- data.tar.gz: 549f64623c4374c3067d0e82a853eace86c14873a89c5e894118ca8e4c1122377d89d55c10c7816b86db391d0130df423c68db25d9d898e4de769947554c1e54
6
+ metadata.gz: be4a7fbb271fd7bca9c47a23f7ee474b57ad06e047278476670d335fa22461a45a13d02e3d79be0578f5bcf40662aa7229e921e23a2919d9d838b9f718e1ff52
7
+ data.tar.gz: fe2e8deba94abbd8f44ea0c940dd4f23f132952f668de68aa06a221eb465f9c78e4ba5d69151f192e20491492f9aaca86662801c89a891ac1c3ba4f199cf31bd
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # rails_band
2
2
 
3
3
  <a href="https://github.com/yykamei/rails_band/actions/workflows/ci.yml"><img alt="GitHub Actions workflow status" src="https://github.com/yykamei/rails_band/actions/workflows/ci.yml/badge.svg"></a>
4
- <a href="https://rubygems.org/gems/rails_band"><img alt="Gem" src="https://img.shields.io/gem/v/rails_band"></a>
4
+ <a href="https://rubygems.org/gems/rails_band"><img alt="rails_band" src="https://img.shields.io/gem/v/rails_band"></a>
5
5
 
6
6
  Easy-to-use Rails Instrumentation API.
7
7
 
@@ -82,6 +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
86
 
86
87
  ### Active Record
87
88
 
@@ -128,11 +129,11 @@ These are Rails Instrumentation API hooks supported by this gem so far.
128
129
 
129
130
  | Event name | Supported |
130
131
  | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
131
- | [`perform_action.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#perform-action-action-cable) | |
132
- | [`transmit.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#transmit-action-cable) | |
133
- | [`transmit_subscription_confirmation.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#transmit-subscription-confirmation-action-cable) | |
134
- | [`transmit_subscription_rejection.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#transmit-subscription-rejection-action-cable) | |
135
- | [`broadcast.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#broadcast-action-cable) | |
132
+ | [`perform_action.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#perform-action-action-cable) ||
133
+ | [`transmit.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#transmit-action-cable) ||
134
+ | [`transmit_subscription_confirmation.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#transmit-subscription-confirmation-action-cable) ||
135
+ | [`transmit_subscription_rejection.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#transmit-subscription-rejection-action-cable) ||
136
+ | [`broadcast.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#broadcast-action-cable) ||
136
137
 
137
138
  ### Active Storage
138
139
 
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBand
4
+ module ActionCable
5
+ module Event
6
+ # A wrapper for the event that is passed to `broadcast.action_cable`.
7
+ class Broadcast < BaseEvent
8
+ def broadcasting
9
+ @broadcasting ||= @event.payload.fetch(:broadcasting)
10
+ end
11
+
12
+ def message
13
+ @message ||= @event.payload.fetch(:message)
14
+ end
15
+
16
+ def coder
17
+ @coder ||= @event.payload.fetch(:coder)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBand
4
+ module ActionCable
5
+ module Event
6
+ # A wrapper for the event that is passed to `perform_action.action_cable`.
7
+ class PerformAction < BaseEvent
8
+ def channel_class
9
+ @channel_class ||= @event.payload.fetch(:channel_class)
10
+ end
11
+
12
+ def action
13
+ @action ||= @event.payload.fetch(:action)
14
+ end
15
+
16
+ def data
17
+ @data ||= @event.payload.fetch(:data)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBand
4
+ module ActionCable
5
+ module Event
6
+ # A wrapper for the event that is passed to `transmit.action_cable`.
7
+ class Transmit < BaseEvent
8
+ def channel_class
9
+ @channel_class ||= @event.payload.fetch(:channel_class)
10
+ end
11
+
12
+ def data
13
+ @data ||= @event.payload.fetch(:data)
14
+ end
15
+
16
+ def via
17
+ @via ||= @event.payload.fetch(:via)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBand
4
+ module ActionCable
5
+ module Event
6
+ # A wrapper for the event that is passed to `transmit_subscription_confirmation.action_cable`.
7
+ class TransmitSubscriptionConfirmation < BaseEvent
8
+ def channel_class
9
+ @channel_class ||= @event.payload.fetch(:channel_class)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBand
4
+ module ActionCable
5
+ module Event
6
+ # A wrapper for the event that is passed to `transmit_subscription_rejection.action_cable`.
7
+ class TransmitSubscriptionRejection < BaseEvent
8
+ def channel_class
9
+ @channel_class ||= @event.payload.fetch(:channel_class)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_band/action_cable/event/perform_action'
4
+ require 'rails_band/action_cable/event/transmit'
5
+ require 'rails_band/action_cable/event/transmit_subscription_confirmation'
6
+ require 'rails_band/action_cable/event/transmit_subscription_rejection'
7
+ require 'rails_band/action_cable/event/broadcast'
8
+
9
+ module RailsBand
10
+ module ActionCable
11
+ # The custom LogSubscriber for ActionCable.
12
+ class LogSubscriber < ::ActiveSupport::LogSubscriber
13
+ mattr_accessor :consumers
14
+
15
+ def perform_action(event)
16
+ consumer_of(__method__)&.call(Event::PerformAction.new(event))
17
+ end
18
+
19
+ def transmit(event)
20
+ consumer_of(__method__)&.call(Event::Transmit.new(event))
21
+ end
22
+
23
+ def transmit_subscription_confirmation(event)
24
+ consumer_of(__method__)&.call(Event::TransmitSubscriptionConfirmation.new(event))
25
+ end
26
+
27
+ def transmit_subscription_rejection(event)
28
+ consumer_of(__method__)&.call(Event::TransmitSubscriptionRejection.new(event))
29
+ end
30
+
31
+ def broadcast(event)
32
+ consumer_of(__method__)&.call(Event::Broadcast.new(event))
33
+ end
34
+
35
+ private
36
+
37
+ def consumer_of(sub_event)
38
+ consumers[:"#{sub_event}.action_cable"] || consumers[:action_cable] || consumers[:default]
39
+ end
40
+ end
41
+ end
42
+ end
@@ -30,6 +30,10 @@ module RailsBand
30
30
  swap.call(::ActionMailer::LogSubscriber, RailsBand::ActionMailer::LogSubscriber, :action_mailer)
31
31
  end
32
32
 
33
+ if defined?(::ActionCable)
34
+ RailsBand::ActionCable::LogSubscriber.attach_to :action_cable
35
+ end
36
+
33
37
  RailsBand::ActiveSupport::LogSubscriber.attach_to :active_support
34
38
 
35
39
  if defined?(::ActiveJob)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsBand
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
data/lib/rails_band.rb CHANGED
@@ -31,4 +31,8 @@ module RailsBand
31
31
  module ActiveJob
32
32
  autoload :LogSubscriber, 'rails_band/active_job/log_subscriber'
33
33
  end
34
+
35
+ module ActionCable
36
+ autoload :LogSubscriber, 'rails_band/action_cable/log_subscriber'
37
+ end
34
38
  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.4.0
4
+ version: 0.5.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-11-19 00:00:00.000000000 Z
11
+ date: 2021-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -35,6 +35,12 @@ files:
35
35
  - README.md
36
36
  - Rakefile
37
37
  - lib/rails_band.rb
38
+ - lib/rails_band/action_cable/event/broadcast.rb
39
+ - lib/rails_band/action_cable/event/perform_action.rb
40
+ - lib/rails_band/action_cable/event/transmit.rb
41
+ - lib/rails_band/action_cable/event/transmit_subscription_confirmation.rb
42
+ - lib/rails_band/action_cable/event/transmit_subscription_rejection.rb
43
+ - lib/rails_band/action_cable/log_subscriber.rb
38
44
  - lib/rails_band/action_controller/event/exist_fragment.rb
39
45
  - lib/rails_band/action_controller/event/expire_fragment.rb
40
46
  - lib/rails_band/action_controller/event/halted_callback.rb
@@ -103,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
109
  - !ruby/object:Gem::Version
104
110
  version: '0'
105
111
  requirements: []
106
- rubygems_version: 3.2.22
112
+ rubygems_version: 3.2.32
107
113
  signing_key:
108
114
  specification_version: 4
109
115
  summary: Easy-to-use Rails Instrumentation API