Module: AppMap::Config
- Defined in:
- lib/appmap/config.rb,
lib/appmap/config/file.rb,
lib/appmap/config/path.rb,
lib/appmap/config/directory.rb,
lib/appmap/config/package_dir.rb,
lib/appmap/config/named_function.rb
Defined Under Namespace
Classes: Configuration, Directory, File, NamedFunction, NamedFunctionStruct, PackageDir, Path, PathStruct
Constant Summary collapse
- NAMED_FUNCTIONS =
Config::NamedFunction.new(:rack_handler_webrick, 'rack', 'lib/rack/handler/webrick.rb', %w[Rack Handler WEBrick], 'service', false) ].freeze
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.
Class Method Details
.load(config_data) ⇒ Object
Loads configuration from a Hash.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/appmap/config.rb', line 37 def load(config_data) Configuration.new(config_data['name']).tap do |config| builders = Hash.new { |_, key| raise "Unknown config type #{key.inspect}" } builders[:packages] = lambda { |path, | AppMap::Config::PackageDir.new(path).tap do |pdir| pdir.package_name = ['name'] if ['name'] pdir.exclude = ['exclude'] if ['exclude'] end } builders[:files] = ->(path, _) { AppMap::Config::File.new(path) } i[packages files].each do |kind| next unless (members = config_data[kind.to_s]) members.each do |member| path = member.delete('path') config.send(kind) << builders[kind].call(path, member) end end NAMED_FUNCTIONS.each do |dep| next if config_data['named_functions'] && !config_data['named_functions'].member?(dep.gem_name) config.named_functions << dep end end end |
.load_from_file(config_file_name) ⇒ Object
Loads configuration data from a file, specified by the file name.
31 32 33 34 |
# File 'lib/appmap/config.rb', line 31 def load_from_file(config_file_name) require 'yaml' load YAML.safe_load(::File.read(config_file_name)) end |