Class: LayerChecker::Config
- Inherits:
-
Object
- Object
- LayerChecker::Config
- Defined in:
- lib/layer_checker/config.rb
Instance Attribute Summary collapse
-
#all_modules ⇒ Object
readonly
Returns the value of attribute all_modules.
-
#modules ⇒ Object
readonly
Returns the value of attribute modules.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(config_path) ⇒ Config
constructor
A new instance of Config.
-
#module_for_file(file_path) ⇒ Object
Find which module a file belongs to.
-
#option(key, default = nil) ⇒ Object
Get option value with default.
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'] || {}) = (config['options'] || {}) @all_modules = build_all_modules_map end |
Instance Attribute Details
#all_modules ⇒ Object (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 |
#modules ⇒ Object (readonly)
Returns the value of attribute modules.
8 9 10 |
# File 'lib/layer_checker/config.rb', line 8 def modules @modules end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/layer_checker/config.rb', line 8 def 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) .fetch(key, default) end |