class Central::Devtools::Config
Abstract base class of tool configuration
Constants
- DEFAULT_CONFIG
Represent no configuration
- TypeError
Error raised on type errors
Private Class Methods
attribute(name, classes, **options)
click to toggle source
Declare an attribute
@param [Symbol] name @param [Array<Class>] classes @return [self] @api private
# File lib/central/devtools/config.rb, line 50 def self.attribute(name, classes, **options) default = [options.fetch(:default)] if options.key?(:default) type_check = TypeCheck.new(name, classes) key = name.to_s define_method(name) do type_check.call(raw.fetch(key, *default)) end end
Public Instance Methods
config_file()
click to toggle source
Return config path
@return [String] @api private
# File lib/central/devtools/config.rb, line 65 def config_file config_dir.join(self.class::FILE) end
Private Instance Methods
raw()
click to toggle source
Return raw data
@return [Hash] @api private
# File lib/central/devtools/config.rb, line 76 def raw yaml_config || DEFAULT_CONFIG end
yaml_config()
click to toggle source
Return the raw config data from a yaml file
@return [Hash]
returned if the yaml file is found
@return [nil]
returned if the yaml file is not found
@api private
# File lib/central/devtools/config.rb, line 88 def yaml_config IceNine.deep_freeze(YAML.load_file(config_file)) if config_file.file? end