Class: LayerChecker::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/layer_checker/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_path) ⇒ Config

Returns a new instance of Config.



10
11
12
13
14
15
16
# File 'lib/layer_checker/config.rb', line 10

def initialize(config_path)
  config = load_config(config_path)
      
  @modules = parse_modules(config['modules'] || {})
  @options = parse_options(config['options'] || {})
  @all_modules = build_all_modules_map
end

Instance Attribute Details

#all_modulesObject (readonly)

Returns the value of attribute all_modules.



8
9
10
# File 'lib/layer_checker/config.rb', line 8

def all_modules
  @all_modules
end

#modulesObject (readonly)

Returns the value of attribute modules.



8
9
10
# File 'lib/layer_checker/config.rb', line 8

def modules
  @modules
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/layer_checker/config.rb', line 8

def options
  @options
end

Instance Method Details

#module_for_file(file_path) ⇒ Object

Find which module a file belongs to



19
20
21
# File 'lib/layer_checker/config.rb', line 19

def module_for_file(file_path)
  @all_modules.values.find { |mod| mod.matches_file?(file_path) }
end

#option(key, default = nil) ⇒ Object

Get option value with default



24
25
26
# File 'lib/layer_checker/config.rb', line 24

def option(key, default = nil)
  @options.fetch(key, default)
end