Class: AppMap::Hook::Config
- Inherits:
-
Struct
- Object
- Struct
- AppMap::Hook::Config
- Defined in:
- lib/appmap/hook.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#packages ⇒ Object
Returns the value of attribute packages.
Class Method Summary collapse
-
.load(config_data) ⇒ Object
Loads configuration from a Hash.
-
.load_from_file(config_file_name) ⇒ Object
Loads configuration data from a file, specified by the file name.
Instance Method Summary collapse
-
#initialize(name, packages = []) ⇒ Config
constructor
A new instance of Config.
- #to_h ⇒ Object
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
#name ⇒ Object
Returns the value of attribute name
18 19 20 |
# File 'lib/appmap/hook.rb', line 18 def name @name end |
#packages ⇒ Object
Returns the value of attribute 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_h ⇒ Object
39 40 41 42 43 44 |
# File 'lib/appmap/hook.rb', line 39 def to_h { name: name, packages: packages.map(&:to_h) } end |