appmap 0.75.0 → 0.76.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: 322b607426359e9dcebd46ea4a565550c75413e785275b736530149e19f493c4
4
- data.tar.gz: 34b81b8f50e4312b0d1b3e54ad58bb86666812eafaba19338aca73ed12f12c37
3
+ metadata.gz: 15371b6980bcc95640c4d579c323da11db85509c0f50110c318da0d9cc04f189
4
+ data.tar.gz: 03a4e889edcfaf15629a7e9662f230df18b3b1123c86ce463edf4ba03c9e7280
5
5
  SHA512:
6
- metadata.gz: ac8aa369f84bd56aa5b2fddba6211eb528beb9c79d710738e9b7feb20198922a35a98e7b57bb615979ad186d7920b358f3ef06f9ced9d4b9289c5627cc660512
7
- data.tar.gz: 9e1c7ab9a501fd4043b31843291f62f71257d3d946a46d8b4c08e3330546a6680cdb53ac512b23ce81ac525e1d35178cc491b5a72113e23a93649c8f87948dab
6
+ metadata.gz: a1bc1b230b3e946400acbc3d1bc8ee87508973ce594ca488c17f2d39d1280346959e2c5acb5c9d3f6cd62627b61764f5cd0d96ef60639c645337df2ac850409b
7
+ data.tar.gz: e0bb0223a99795cedc38470d49dae428a720f0638674dc4e04b26d15aa085286d51c42aacc1ee490ff713122711728af9df1064adcb66a6dff7ccb89292b72a5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [0.76.0](https://github.com/applandinc/appmap-ruby/compare/v0.75.0...v0.76.0) (2022-03-19)
2
+
3
+
4
+ ### Features
5
+
6
+ * Autoload hook handlers ([4cc0e70](https://github.com/applandinc/appmap-ruby/commit/4cc0e7003a8c37d3b6c8c8bbc68cffac0335b878))
7
+
1
8
  # [0.75.0](https://github.com/applandinc/appmap-ruby/compare/v0.74.0...v0.75.0) (2022-03-17)
2
9
 
3
10
 
data/lib/appmap/config.rb CHANGED
@@ -4,8 +4,7 @@ require 'pathname'
4
4
  require 'set'
5
5
  require 'yaml'
6
6
  require 'appmap/util'
7
- require 'appmap/handler/net_http'
8
- require 'appmap/handler/rails/template'
7
+ require 'appmap/handler'
9
8
  require 'appmap/service/guesser'
10
9
  require 'appmap/swagger/configuration'
11
10
  require 'appmap/depends/configuration'
@@ -206,8 +205,8 @@ module AppMap
206
205
  }.compact
207
206
 
208
207
  handler_class = hook_decl['handler_class']
209
- options[:handler_class] = Util.class_from_string(handler_class) if handler_class
210
-
208
+ options[:handler_class] = Handler.find(handler_class) if handler_class
209
+
211
210
  package_hooks(methods, **options)
212
211
  end
213
212
 
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/inflector/methods'
4
+
5
+ module AppMap
6
+ # Specific hook handler classes and general related utilities.
7
+ module Handler
8
+ # Try to find handler module with a given name.
9
+ #
10
+ # If the module is not loaded, tries to require the appropriate file
11
+ # using the usual conventions, eg. `Acme::Handler::AppMap` will try
12
+ # to require `acme/handler/app_map`, then `acme/handler` and
13
+ # finally `acme`. Raises NameError if the module could not be loaded
14
+ # this way.
15
+ def self.find(name)
16
+ begin
17
+ return Object.const_get name
18
+ rescue NameError
19
+ try_load ActiveSupport::Inflector.underscore name
20
+ end
21
+ Object.const_get name
22
+ end
23
+
24
+ def self.try_load(fname)
25
+ fname = fname.sub %r{^app_map/}, 'appmap/'
26
+ fname = fname.split '/'
27
+ until fname.empty?
28
+ begin
29
+ require fname.join '/'
30
+ return
31
+ rescue LoadError
32
+ # pass
33
+ end
34
+ fname.pop
35
+ end
36
+ end
37
+ end
38
+ end
data/lib/appmap/hook.rb CHANGED
@@ -108,8 +108,11 @@ module AppMap
108
108
 
109
109
  warn "AppMap: Initiating hook for builtin #{class_name} #{method_name}" if LOG
110
110
 
111
- base_cls = Util.class_from_string(class_name, must: false)
112
- next unless base_cls
111
+ begin
112
+ base_cls = Object.const_get class_name
113
+ rescue NameError
114
+ next
115
+ end
113
116
 
114
117
  hook_method = lambda do |entry|
115
118
  cls, method = entry
data/lib/appmap/util.rb CHANGED
@@ -21,14 +21,6 @@ module AppMap
21
21
  WHITE = "\e[37m"
22
22
 
23
23
  class << self
24
- def class_from_string(fq_class, must: true)
25
- fq_class.split('::').inject(Object) do |mod, class_name|
26
- mod.const_get(class_name)
27
- end
28
- rescue NameError
29
- raise if must
30
- end
31
-
32
24
  def parse_function_name(name)
33
25
  package_tokens = name.split('/')
34
26
 
@@ -3,7 +3,7 @@
3
3
  module AppMap
4
4
  URL = 'https://github.com/applandinc/appmap-ruby'
5
5
 
6
- VERSION = '0.75.0'
6
+ VERSION = '0.76.0'
7
7
 
8
8
  APPMAP_FORMAT_VERSION = '1.5.1'
9
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appmap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.75.0
4
+ version: 0.76.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Gilpin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-17 00:00:00.000000000 Z
11
+ date: 2022-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -374,6 +374,7 @@ files:
374
374
  - lib/appmap/gem_hooks/resque.yml
375
375
  - lib/appmap/gem_hooks/sidekiq.yml
376
376
  - lib/appmap/gem_hooks/sprockets.yml
377
+ - lib/appmap/handler.rb
377
378
  - lib/appmap/handler/function.rb
378
379
  - lib/appmap/handler/net_http.rb
379
380
  - lib/appmap/handler/rails/request_handler.rb