Class: AppMap::Config::LookupHookConfig
- 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
- #hook_config ⇒ 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
469 470 471 |
# File 'lib/appmap/config.rb', line 469 def cls @cls end |
#config ⇒ Object
Returns the value of attribute config
469 470 471 |
# File 'lib/appmap/config.rb', line 469 def config @config end |
#method ⇒ Object
Returns the value of attribute method
469 470 471 |
# File 'lib/appmap/config.rb', line 469 def method @method end |
Instance Method Details
#hook_config ⇒ Object
470 471 472 473 474 475 476 477 478 479 480 |
# File 'lib/appmap/config.rb', line 470 def hook_config # Global "excludes" configuration can be used to ignore any class/method. return if config.never_hook?(cls, method) pkg = package_for_code_object || package_for_location return unless pkg comment = method.comment labels = (pkg.labels || []) + ClassMap.parse_labels(comment) HookConfig.new(pkg, labels) end |
#package_for_code_object ⇒ Object
Hook a method which is specified by class and method name.
483 484 485 486 487 488 489 490 491 492 493 494 495 496 |
# File 'lib/appmap/config.rb', line 483 def package_for_code_object class_name = begin (cls.to_s.index("#<Class:") == 0) ? cls.to_s["#<Class:".length...-1] : cls.name rescue # Calling #to_s on some Rails classes # (e.g. those generated to represent # associations) will raise an exception. Fall # back to using the class name. cls.name end 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).
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 |
# File 'lib/appmap/config.rb', line 499 def package_for_location location = method.source_location location_file, = location return unless location_file location_file = AppMap::Util.normalize_path(location_file) pkg = config .packages .select { |pkg| pkg.path } .select do |pkg| (location_file.index(pkg.path) == 0) && !pkg.exclude.find { |p| location_file.index(p) } end .min { |a, b| b.path <=> a.path } # Longest matching package first pkg.subpackage(location_file, config) if pkg end |