appmap 0.72.4 → 0.72.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/appmap/hook/method.rb +42 -4
- data/lib/appmap/version.rb +1 -1
- data/spec/fixtures/hook/report_parameters.rb +8 -0
- data/spec/hook_spec.rb +67 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6b34c9af8d6d392be8211d9667daaccd2156c41a9c3c040bcdcfbfcbcba9332
|
4
|
+
data.tar.gz: 16bc9b9fe0a4288af913b3b6038ea4866913db72c0a49e5b91b11f08eebf06b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5d3870cecadc652deb2c7dfa682d54e4ca166eb3ed8bd10df40d7d03a45f43dc1737190541c22a28e605207ab27925bd4ce2ea80fa67ab9e5d1090cfdeb253b
|
7
|
+
data.tar.gz: 3a2f3c10dec5548ad30a4ffb3c32ca94b1efcc3848fcb9b050a76f33bcb0b084d1f26a69c74269da77264c11f85b130fcdcce9c53c3a7bb52742301b864b251d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [0.72.5](https://github.com/applandinc/appmap-ruby/compare/v0.72.4...v0.72.5) (2022-02-17)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* Override method accessors to provide the correct signature ([#223](https://github.com/applandinc/appmap-ruby/issues/223)) ([936bba4](https://github.com/applandinc/appmap-ruby/commit/936bba470c5360ee313e0b3e45a65d83acd0b53d))
|
7
|
+
|
1
8
|
## [0.72.4](https://github.com/applandinc/appmap-ruby/compare/v0.72.3...v0.72.4) (2022-02-17)
|
2
9
|
|
3
10
|
|
data/lib/appmap/hook/method.rb
CHANGED
@@ -7,6 +7,23 @@ module AppMap
|
|
7
7
|
end
|
8
8
|
|
9
9
|
class Hook
|
10
|
+
SIGNATURES = {}
|
11
|
+
|
12
|
+
LOOKUP_SIGNATURE = lambda do |id|
|
13
|
+
method = super(id)
|
14
|
+
|
15
|
+
signature = SIGNATURES[[ method.owner, method.name ]]
|
16
|
+
if signature
|
17
|
+
method.singleton_class.module_eval do
|
18
|
+
define_method(:parameters) do
|
19
|
+
signature
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
method
|
25
|
+
end
|
26
|
+
|
10
27
|
class Method
|
11
28
|
attr_reader :hook_package, :hook_class, :hook_method
|
12
29
|
|
@@ -100,12 +117,10 @@ module AppMap
|
|
100
117
|
hook_method_def = hook_method_def.ruby2_keywords if hook_method_def.respond_to?(:ruby2_keywords)
|
101
118
|
|
102
119
|
hook_method_parameters = hook_method.parameters.dup.freeze
|
120
|
+
SIGNATURES[[ hook_class, hook_method.name ]] = hook_method_parameters
|
121
|
+
|
103
122
|
hook_class.ancestors.first.tap do |cls|
|
104
123
|
cls.define_method_with_arity(hook_method.name, hook_method.arity, hook_method_def)
|
105
|
-
redefined_method = cls.instance_method(hook_method.name)
|
106
|
-
redefined_method.singleton_class.module_eval do
|
107
|
-
define_method(:parameters) { hook_method_parameters }
|
108
|
-
end
|
109
124
|
end
|
110
125
|
end
|
111
126
|
|
@@ -136,4 +151,27 @@ module AppMap
|
|
136
151
|
end
|
137
152
|
end
|
138
153
|
end
|
154
|
+
|
155
|
+
module ObjectMethods
|
156
|
+
define_method(:method, AppMap::Hook::LOOKUP_SIGNATURE)
|
157
|
+
define_method(:public_method, AppMap::Hook::LOOKUP_SIGNATURE)
|
158
|
+
define_method(:singleton_method, AppMap::Hook::LOOKUP_SIGNATURE)
|
159
|
+
end
|
160
|
+
|
161
|
+
module ModuleMethods
|
162
|
+
define_method(:instance_method, AppMap::Hook::LOOKUP_SIGNATURE)
|
163
|
+
define_method(:public_instance_method, AppMap::Hook::LOOKUP_SIGNATURE)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
unless ENV['APPMAP_NO_PATCH_OBJECT'] == 'true'
|
168
|
+
class Object
|
169
|
+
prepend AppMap::ObjectMethods
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
unless ENV['APPMAP_NO_PATCH_MODULE'] == 'true'
|
174
|
+
class Module
|
175
|
+
prepend AppMap::ModuleMethods
|
176
|
+
end
|
139
177
|
end
|
data/lib/appmap/version.rb
CHANGED
data/spec/hook_spec.rb
CHANGED
@@ -225,6 +225,12 @@ describe 'AppMap class Hooking', docker: false do
|
|
225
225
|
:value: default
|
226
226
|
YAML
|
227
227
|
test_hook_behavior 'spec/fixtures/hook/instance_method.rb', events_yaml do
|
228
|
+
expect(InstanceMethod.instance_method(:say_default).parameters).to eq([])
|
229
|
+
expect(InstanceMethod.public_instance_method(:say_default).parameters).to eq([])
|
230
|
+
expect(InstanceMethod.new.method(:say_default).parameters).to eq([])
|
231
|
+
expect(InstanceMethod.new.public_method(:say_default).parameters).to eq([])
|
232
|
+
expect { InstanceMethod.new.singleton_method(:say_default) }.to raise_error(NameError)
|
233
|
+
|
228
234
|
expect(InstanceMethod.new.say_default).to eq('default')
|
229
235
|
end
|
230
236
|
end
|
@@ -315,7 +321,22 @@ describe 'AppMap class Hooking', docker: false do
|
|
315
321
|
:class: String
|
316
322
|
:value: protected
|
317
323
|
YAML
|
324
|
+
parameters = []
|
318
325
|
test_hook_behavior 'spec/fixtures/hook/protected_method.rb', events_yaml do
|
326
|
+
expect(ProtectedMethod.singleton_method(:call_protected).parameters).to eq(parameters)
|
327
|
+
expect(ProtectedMethod.instance_method(:call_protected).parameters).to eq(parameters)
|
328
|
+
expect(ProtectedMethod.public_instance_method(:call_protected).parameters).to eq(parameters)
|
329
|
+
expect(ProtectedMethod.new.method(:call_protected).parameters).to eq(parameters)
|
330
|
+
expect(ProtectedMethod.new.public_method(:call_protected).parameters).to eq(parameters)
|
331
|
+
expect { ProtectedMethod.new.singleton_method(:call_protected) }.to raise_error(NameError)
|
332
|
+
|
333
|
+
expect(ProtectedMethod.singleton_method(:protected_method).parameters).to eq(parameters)
|
334
|
+
expect(ProtectedMethod.instance_method(:protected_method).parameters).to eq(parameters)
|
335
|
+
expect(ProtectedMethod.public_instance_method(:protected_method).parameters).to eq(parameters)
|
336
|
+
expect(ProtectedMethod.new.method(:protected_method).parameters).to eq(parameters)
|
337
|
+
expect(ProtectedMethod.new.public_method(:protected_method).parameters).to eq(parameters)
|
338
|
+
expect { ProtectedMethod.new.singleton_method(:protected_method) }.to raise_error(NameError)
|
339
|
+
|
319
340
|
expect(ProtectedMethod.new.call_protected).to eq('protected')
|
320
341
|
end
|
321
342
|
end
|
@@ -358,6 +379,7 @@ describe 'AppMap class Hooking', docker: false do
|
|
358
379
|
:class: String
|
359
380
|
:value: self.protected
|
360
381
|
YAML
|
382
|
+
parameters = []
|
361
383
|
test_hook_behavior 'spec/fixtures/hook/protected_method.rb', events_yaml do
|
362
384
|
expect(ProtectedMethod.call_protected).to eq('self.protected')
|
363
385
|
end
|
@@ -1100,6 +1122,51 @@ describe 'AppMap class Hooking', docker: false do
|
|
1100
1122
|
end
|
1101
1123
|
end
|
1102
1124
|
|
1125
|
+
it 'preserves the sighnature of hooked methods' do
|
1126
|
+
parameters = []
|
1127
|
+
events = <<~YAML
|
1128
|
+
---
|
1129
|
+
- :id: 1
|
1130
|
+
:event: :call
|
1131
|
+
:defined_class: ReportParameters
|
1132
|
+
:method_id: report_parameters
|
1133
|
+
:path: spec/fixtures/hook/report_parameters.rb
|
1134
|
+
:lineno: 5
|
1135
|
+
:static: false
|
1136
|
+
:parameters:
|
1137
|
+
- :name: :args
|
1138
|
+
:class: Array
|
1139
|
+
:value: '["foo"]'
|
1140
|
+
:kind: :rest
|
1141
|
+
- :name: :kw1
|
1142
|
+
:class: String
|
1143
|
+
:value: kw1
|
1144
|
+
:kind: :keyreq
|
1145
|
+
- :name: :kw2
|
1146
|
+
:class: NilClass
|
1147
|
+
:value: null
|
1148
|
+
:kind: :key
|
1149
|
+
- :name: :kws
|
1150
|
+
:class: Hash
|
1151
|
+
:value: "{}"
|
1152
|
+
:kind: :keyrest
|
1153
|
+
:receiver:
|
1154
|
+
:class: ReportParameters
|
1155
|
+
:value: ReportParameters
|
1156
|
+
- :id: 2
|
1157
|
+
:event: :return
|
1158
|
+
:parent_id: 1
|
1159
|
+
:return_value:
|
1160
|
+
:class: Array
|
1161
|
+
:value: "[[:rest, :args], [:keyreq, :kw1], [:key, :kw2], [:keyrest, :kws]]"
|
1162
|
+
YAML
|
1163
|
+
parameters = [[:rest, :args], [:keyreq, :kw1], [:key, :kw2], [:keyrest, :kws]]
|
1164
|
+
test_hook_behavior 'spec/fixtures/hook/report_parameters.rb', events do
|
1165
|
+
expect(ReportParameters.instance_method(:report_parameters).parameters).to eq(parameters)
|
1166
|
+
expect(ReportParameters.new.report_parameters('foo', kw1: 'kw1')).to eq(parameters)
|
1167
|
+
end
|
1168
|
+
end
|
1169
|
+
|
1103
1170
|
describe 'kwargs handling' do
|
1104
1171
|
if ruby_2?
|
1105
1172
|
# https://github.com/applandinc/appmap-ruby/issues/153
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.72.
|
4
|
+
version: 0.72.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Gilpin
|
@@ -447,6 +447,7 @@ files:
|
|
447
447
|
- spec/fixtures/hook/pkg_a/a.rb
|
448
448
|
- spec/fixtures/hook/prepended_override.rb
|
449
449
|
- spec/fixtures/hook/protected_method.rb
|
450
|
+
- spec/fixtures/hook/report_parameters.rb
|
450
451
|
- spec/fixtures/hook/revoke_api_key.appmap.json
|
451
452
|
- spec/fixtures/hook/singleton_method.rb
|
452
453
|
- spec/fixtures/hook/spec/api_spec.rb
|