Class: AppMap::Config::LookupPackage
- Inherits:
-
Struct
- Object
- Struct
- AppMap::Config::LookupPackage
- Defined in:
- lib/appmap/config.rb
Overview
Looks up a class and method in the config, to find the matching Package configuration.
This class is only used after path_enabled? has returned true.
Instance Attribute Summary collapse
-
#cls ⇒ Object
Returns the value of attribute cls.
-
#config ⇒ Object
Returns the value of attribute config.
-
#method ⇒ Object
Returns the value of attribute method.
Instance Method Summary collapse
- #package ⇒ Object
-
#package_for_code_object ⇒ Object
Hook a method which is specified by class and method name.
-
#package_for_location ⇒ Object
Hook a method which is specified by code location (i.e. path).
Instance Attribute Details
#cls ⇒ Object
Returns the value of attribute cls
429 430 431 |
# File 'lib/appmap/config.rb', line 429 def cls @cls end |
#config ⇒ Object
Returns the value of attribute config
429 430 431 |
# File 'lib/appmap/config.rb', line 429 def config @config end |
#method ⇒ Object
Returns the value of attribute method
429 430 431 |
# File 'lib/appmap/config.rb', line 429 def method @method end |
Instance Method Details
#package ⇒ Object
430 431 432 433 434 435 |
# File 'lib/appmap/config.rb', line 430 def package # Global "excludes" configuration can be used to ignore any class/method. return if config.never_hook?(cls, method) package_for_code_object || package_for_location end |
#package_for_code_object ⇒ Object
Hook a method which is specified by class and method name.
438 439 440 441 442 443 |
# File 'lib/appmap/config.rb', line 438 def package_for_code_object class_name = cls.to_s.index('#<Class:') == 0 ? cls.to_s['#<Class:'.length...-1] : cls.name Array(config.gem_hooks[class_name]) .find { |hook| hook.include_method?(method.name) } &.package end |
#package_for_location ⇒ Object
Hook a method which is specified by code location (i.e. path).
446 447 448 449 450 451 452 453 454 455 456 457 458 459 |
# File 'lib/appmap/config.rb', line 446 def package_for_location location = method.source_location location_file, = location return unless location_file location_file = AppMap::Util.normalize_path(location_file) config .packages .select { |pkg| pkg.path } .find do |pkg| (location_file.index(pkg.path) == 0) && !pkg.exclude.find { |p| location_file.index(p) } end end |