action_tracer 0.2.2 → 0.2.3

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: 571e846122caa7adaac3bf172d8554d39bfc78c8227a6dbcc5ec02e7c675c000
4
- data.tar.gz: 88caafd405cfe90801a6ed65fe61a8b464fb8467c4ed8bd012edf7ac7ebb4dbc
3
+ metadata.gz: 421d6789ec680cc762a0844c9182d4dd8b03a5c6371c1a1852cb1fd0e2c0746a
4
+ data.tar.gz: b13b98ed44e0cb98df31709135170e6764eb11df43ba528d696cfa253835cec8
5
5
  SHA512:
6
- metadata.gz: c553fc5f4b408233ad1883899f2cfee9f5c38f19499c7312c023a5774d6a483c2250d57a6a9d8ab99772f2ca02f95a34d98594dc8216e79bffaad560c4781959
7
- data.tar.gz: ea31f4fe2bdb38abc5a8607eaf4ea90269507f19430c024730fa98655da6c589c49f07163b120818c24d92e602c2e26ab36ebf95a57c97ef8dc60110110572cb
6
+ metadata.gz: a97e4728b5ca7f02f7ee5c2bb384edeba87bf5eaac370bdf2dbfdc6833ccc7607595618234df5ac7c7e76c1701fcb18e90ffe4ff886528c75ca0a279432b8562
7
+ data.tar.gz: 1c81fe333dd9815b5dbcd93689d5443e17e39e2bdf4876639e432e66282b5f1f64d993f2f84d9232e065f862ef13c651aacfc58e4fc48b3ad9a19ed07191f0ce
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.2.3
2
+
3
+ * Deal with Rails7.x.
4
+
1
5
  ## 0.2.2
2
6
 
3
7
  * Log filters even when controllers raise error.
@@ -51,15 +51,23 @@ module ActionTracer
51
51
  @action = action
52
52
  end
53
53
 
54
- def self.build(controller)
55
- filters = { before: [], after: [], around: [] }
56
- raw_filters = controller.__callbacks[:process_action].send(:chain).group_by(&:kind)
57
- raw_filters.each do |kind, filter|
58
- filters[kind] = filter.map(&:raw_filter).map do |f|
59
- Filter.new(f, method: f.is_a?(Symbol) ? controller.method(f) : f)
54
+ class << self
55
+ def build(controller)
56
+ filters = { before: [], after: [], around: [] }
57
+ raw_filters = controller.__callbacks[:process_action].send(:chain).group_by(&:kind)
58
+ raw_filters.each do |kind, filter|
59
+ filters[kind] = filter.map { |f| f.__send__(filter_method) }.map do |f|
60
+ Filter.new(f, method: f.is_a?(Symbol) ? controller.method(f) : f)
61
+ end
60
62
  end
63
+ new(filters[:before], filters[:after], filters[:around], action: Action.build(controller))
64
+ end
65
+
66
+ private
67
+
68
+ def filter_method
69
+ @filter_method ||= Rails::VERSION::MAJOR > 6 ? :filter : :raw_filter
61
70
  end
62
- new(filters[:before], filters[:after], filters[:around], action: Action.build(controller))
63
71
  end
64
72
 
65
73
  def print
@@ -5,20 +5,64 @@ module ActionTracer
5
5
  module ActiveSupport
6
6
  module Callbacks
7
7
  module CallTemplate
8
- def expand(*)
9
- target, block, method, *arguments = super
10
- if target.is_a? ActionController::Base
11
- case method
12
- when :instance_exec # filter is a proc
13
- ActionTracer.applied_filters << block
14
- when String # filter is an object
15
- ActionTracer.applied_filters << block
16
- when Symbol # filter is a method
17
- ActionTracer.applied_filters << method
8
+ if Rails::VERSION::MAJOR > 6
9
+ module MethodCall
10
+ def expand(*)
11
+ super.tap { ActionTracer.applied_filters << @method_name }
12
+ end
13
+
14
+ def make_lambda
15
+ super >> proc { ActionTracer.applied_filters << @method_name }
16
+ end
17
+
18
+ def inverted_lambda
19
+ super >> proc { ActionTracer.applied_filters << @method_name }
20
+ end
21
+ end
22
+
23
+ module ProcCall
24
+ def expand(*)
25
+ super.tap { ActionTracer.applied_filters << @override_target }
26
+ end
27
+
28
+ def make_lambda
29
+ super >> proc { ActionTracer.applied_filters << @override_target }
30
+ end
31
+
32
+ def inverted_lambda
33
+ super >> proc { ActionTracer.applied_filters << @override_target }
34
+ end
35
+ end
36
+
37
+ module InstanceExec
38
+ def expand(*)
39
+ super.tap { ActionTracer.applied_filters << @override_block }
40
+ end
41
+
42
+ def make_lambda
43
+ super >> proc { ActionTracer.applied_filters << @override_block }
44
+ end
45
+
46
+ def inverted_lambda
47
+ super >> proc { ActionTracer.applied_filters << @override_block }
18
48
  end
19
49
  end
50
+ else
51
+ def expand(*)
52
+ target, block, method, *arguments = super
53
+ if target.is_a? ActionController::Base
54
+ case method
55
+ when :instance_exec # filter is a proc
56
+ ActionTracer.applied_filters << block
57
+ when String # filter is an object
58
+ ActionTracer.applied_filters << block
59
+ when Symbol # filter is a method
60
+ ActionTracer.applied_filters << method
61
+ end
62
+ end
20
63
 
21
- [target, block, method, *arguments]
64
+ [target, block, method, *arguments]
65
+ end
22
66
  end
23
67
  end
24
68
  end
@@ -23,7 +23,29 @@ module ActionTracer
23
23
  initializer "action_tracer" do
24
24
  ActiveSupport.on_load(:action_controller) do
25
25
  require "action_tracer/monkey_patches/active_support/callbacks"
26
- ::ActiveSupport::Callbacks::CallTemplate.prepend ActionTracer::MonkeyPatches::ActiveSupport::Callbacks::CallTemplate
26
+ if Rails::VERSION::MAJOR > 6
27
+ [
28
+ ::ActiveSupport::Callbacks::CallTemplate::MethodCall,
29
+ ::ActiveSupport::Callbacks::CallTemplate::ObjectCall,
30
+ ].each do |klass|
31
+ klass.prepend ActionTracer::MonkeyPatches::ActiveSupport::Callbacks::CallTemplate::MethodCall
32
+ end
33
+ [
34
+ ::ActiveSupport::Callbacks::CallTemplate::InstanceExec0,
35
+ ::ActiveSupport::Callbacks::CallTemplate::InstanceExec1,
36
+ ::ActiveSupport::Callbacks::CallTemplate::InstanceExec2,
37
+ ].each do |klass|
38
+ klass.prepend ActionTracer::MonkeyPatches::ActiveSupport::Callbacks::CallTemplate::InstanceExec
39
+ end
40
+ [
41
+ ::ActiveSupport::Callbacks::CallTemplate::ProcCall,
42
+ ].each do |klass|
43
+ klass.prepend ActionTracer::MonkeyPatches::ActiveSupport::Callbacks::CallTemplate::ProcCall
44
+ end
45
+ else
46
+ ::ActiveSupport::Callbacks::CallTemplate.prepend ActionTracer::MonkeyPatches::ActiveSupport::Callbacks::CallTemplate
47
+ end
48
+
27
49
  require "action_tracer/monkey_patches/abstract_controller/callbacks"
28
50
  ::ActionController::Base.prepend ActionTracer::MonkeyPatches::AbstractController::Callbacks
29
51
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActionTracer
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_tracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - makicamel
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-27 00:00:00.000000000 Z
11
+ date: 2022-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -99,7 +99,7 @@ homepage: https://github.com/makicamel/action_tracer
99
99
  licenses:
100
100
  - MIT
101
101
  metadata: {}
102
- post_install_message:
102
+ post_install_message:
103
103
  rdoc_options: []
104
104
  require_paths:
105
105
  - lib
@@ -114,8 +114,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  requirements: []
117
- rubygems_version: 3.1.4
118
- signing_key:
117
+ rubygems_version: 3.2.32
118
+ signing_key:
119
119
  specification_version: 4
120
120
  summary: Log Rails application actions and filters when accepts a request
121
121
  test_files: []