rails_band 0.5.0 → 0.6.0

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: 3b347e10fae66e28648aca3427b76fe456fbaf21f1f45aaea5b4e3daed74bc44
4
- data.tar.gz: 102f48535f8cbf10db8b670d57cf671c8f0a839ae0e312fd706631b39e1ad55a
3
+ metadata.gz: 3d8062da3d8ef85024e23c439e5d3eea7daca6d1a02b67e8182ba7ca570f3b22
4
+ data.tar.gz: dff4f9a0b08ef4c09dde608ad7e00855859014059cbc7c6e430725d6cc51548a
5
5
  SHA512:
6
- metadata.gz: be4a7fbb271fd7bca9c47a23f7ee474b57ad06e047278476670d335fa22461a45a13d02e3d79be0578f5bcf40662aa7229e921e23a2919d9d838b9f718e1ff52
7
- data.tar.gz: fe2e8deba94abbd8f44ea0c940dd4f23f132952f668de68aa06a221eb465f9c78e4ba5d69151f192e20491492f9aaca86662801c89a891ac1c3ba4f199cf31bd
6
+ metadata.gz: ab91a63e9c231a7c92731c276749753b8ef862854192cb5cc9e10cfc2d0d96c56d293ba2fcbbc6d307cf6894d33ce71e82b86ab00e170a8314c6fd090414f362
7
+ data.tar.gz: 592ec597dfcdf32bbf1be74a962b4763c6b9c60903a2788fc44bf40d44ee5be379fbd3da9e70837d14c996cfe3f860cde368f8b02e4b01a537f9775819857ad0
data/README.md CHANGED
@@ -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
 
@@ -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
@@ -34,6 +34,10 @@ module RailsBand
34
34
  RailsBand::ActionCable::LogSubscriber.attach_to :action_cable
35
35
  end
36
36
 
37
+ if defined?(::ActiveStorage)
38
+ RailsBand::ActiveStorage::LogSubscriber.attach_to :active_storage
39
+ end
40
+
37
41
  RailsBand::ActiveSupport::LogSubscriber.attach_to :active_support
38
42
 
39
43
  if defined?(::ActiveJob)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsBand
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.0'
5
5
  end
data/lib/rails_band.rb CHANGED
@@ -35,4 +35,8 @@ module RailsBand
35
35
  module ActionCable
36
36
  autoload :LogSubscriber, 'rails_band/action_cable/log_subscriber'
37
37
  end
38
+
39
+ module ActiveStorage
40
+ autoload :LogSubscriber, 'rails_band/active_storage/log_subscriber'
41
+ end
38
42
  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.6.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-03-04 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
@@ -73,6 +79,19 @@ files:
73
79
  - lib/rails_band/active_record/event/sql.rb
74
80
  - lib/rails_band/active_record/event/strict_loading_violation.rb
75
81
  - lib/rails_band/active_record/log_subscriber.rb
82
+ - lib/rails_band/active_storage/event/analyze.rb
83
+ - lib/rails_band/active_storage/event/preview.rb
84
+ - lib/rails_band/active_storage/event/service_delete.rb
85
+ - lib/rails_band/active_storage/event/service_delete_prefixed.rb
86
+ - lib/rails_band/active_storage/event/service_download.rb
87
+ - lib/rails_band/active_storage/event/service_download_chunk.rb
88
+ - lib/rails_band/active_storage/event/service_exist.rb
89
+ - lib/rails_band/active_storage/event/service_streaming_download.rb
90
+ - lib/rails_band/active_storage/event/service_update_metadata.rb
91
+ - lib/rails_band/active_storage/event/service_upload.rb
92
+ - lib/rails_band/active_storage/event/service_url.rb
93
+ - lib/rails_band/active_storage/event/transform.rb
94
+ - lib/rails_band/active_storage/log_subscriber.rb
76
95
  - lib/rails_band/active_support/event/cache_delete.rb
77
96
  - lib/rails_band/active_support/event/cache_delete_multi.rb
78
97
  - lib/rails_band/active_support/event/cache_exist.rb
@@ -109,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
128
  - !ruby/object:Gem::Version
110
129
  version: '0'
111
130
  requirements: []
112
- rubygems_version: 3.2.32
131
+ rubygems_version: 3.3.7
113
132
  signing_key:
114
133
  specification_version: 4
115
134
  summary: Easy-to-use Rails Instrumentation API