Class: AppMap::Config::PackageDir

Inherits:
Directory show all
Defined in:
lib/appmap/config/package_dir.rb

Overview

Scan a directory for AppMap features, treating it as a package and its sub-folders as sub-packages.

Instance Attribute Summary collapse

Attributes inherited from Path

#mode

Attributes inherited from PathStruct

#path

Instance Method Summary collapse

Methods inherited from Path

#<=>

Constructor Details

#initialize(path, package_name = Pathname.new(path || '').basename.to_s) ⇒ PackageDir

Returns a new instance of PackageDir.



13
14
15
16
17
18
19
# File 'lib/appmap/config/package_dir.rb', line 13

def initialize(path, package_name = Pathname.new(path || '').basename.to_s)
  super(path)

  @package_name = package_name
  @base_path = path
  @exclude = []
end

Instance Attribute Details

#base_pathObject

Returns the value of attribute base_path.



10
11
12
# File 'lib/appmap/config/package_dir.rb', line 10

def base_path
  @base_path
end

#excludeObject

Returns the value of attribute exclude.



10
11
12
# File 'lib/appmap/config/package_dir.rb', line 10

def exclude
  @exclude
end

#package_nameObject

Returns the value of attribute package_name.



10
11
12
# File 'lib/appmap/config/package_dir.rb', line 10

def package_name
  @package_name
end

Instance Method Details

#childrenObject



35
36
37
# File 'lib/appmap/config/package_dir.rb', line 35

def children
  child_files.sort + child_packages.sort
end

#exclude?(path) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
# File 'lib/appmap/config/package_dir.rb', line 29

def exclude?(path)
  relative_path = path.gsub("#{base_path}/", '')
  exclude.member?(relative_path)
end

#sub_package_dir(dir) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/appmap/config/package_dir.rb', line 21

def sub_package_dir(dir)
  PackageDir.new(::File.join(path, dir), dir).tap do |m|
    m.base_path = base_path
    m.exclude = exclude
    m.mode = mode
  end
end