action_tracer 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/action_tracer/filters.rb +15 -7
- data/lib/action_tracer/monkey_patches/active_support/callbacks.rb +55 -11
- data/lib/action_tracer/railtie.rb +23 -1
- data/lib/action_tracer/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 421d6789ec680cc762a0844c9182d4dd8b03a5c6371c1a1852cb1fd0e2c0746a
|
4
|
+
data.tar.gz: b13b98ed44e0cb98df31709135170e6764eb11df43ba528d696cfa253835cec8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a97e4728b5ca7f02f7ee5c2bb384edeba87bf5eaac370bdf2dbfdc6833ccc7607595618234df5ac7c7e76c1701fcb18e90ffe4ff886528c75ca0a279432b8562
|
7
|
+
data.tar.gz: 1c81fe333dd9815b5dbcd93689d5443e17e39e2bdf4876639e432e66282b5f1f64d993f2f84d9232e065f862ef13c651aacfc58e4fc48b3ad9a19ed07191f0ce
|
data/CHANGELOG.md
CHANGED
@@ -51,15 +51,23 @@ module ActionTracer
|
|
51
51
|
@action = action
|
52
52
|
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
ActionTracer.applied_filters <<
|
16
|
-
|
17
|
-
|
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
|
-
|
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
|
-
::
|
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
|
|
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.
|
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:
|
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.
|
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: []
|