Method: AppMap::Config::LookupHookConfig#package_for_location

Defined in:
lib/appmap/config.rb

#package_for_locationObject

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