Class: AppMap::Hook::Config

Inherits:
Struct
  • Object
show all
Defined in:
lib/appmap/hook.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, packages = []) ⇒ Config

Returns a new instance of Config.



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

def initialize(name, packages = [])
  super name, packages || []
end

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



18
19
20
# File 'lib/appmap/hook.rb', line 18

def name
  @name
end

#packagesObject

Returns the value of attribute packages

Returns:

  • (Object)

    the current value of packages



18
19
20
# File 'lib/appmap/hook.rb', line 18

def packages
  @packages
end

Class Method Details

.load(config_data) ⇒ Object

Loads configuration from a Hash.



27
28
29
30
31
32
# File 'lib/appmap/hook.rb', line 27

def load(config_data)
  packages = (config_data['packages'] || []).map do |package|
    Package.new(package['path'], package['exclude'] || [])
  end
  Config.new config_data['name'], packages
end

.load_from_file(config_file_name) ⇒ Object

Loads configuration data from a file, specified by the file name.



21
22
23
24
# File 'lib/appmap/hook.rb', line 21

def load_from_file(config_file_name)
  require 'yaml'
  load YAML.safe_load(::File.read(config_file_name))
end

Instance Method Details

#to_hObject



39
40
41
42
43
44
# File 'lib/appmap/hook.rb', line 39

def to_h
  {
    name: name,
    packages: packages.map(&:to_h)
  }
end