class ERBLint::RunnerConfigResolver
def base_configs(file_loader, inherit_from)
def base_configs(file_loader, inherit_from) configs = Array(inherit_from).compact.map do |f| inherited_file = File.expand_path(f, file_loader.base_path) file_loader.yaml(inherited_file) end configs.compact end
def gem_config_path(gem_name, relative_config_path)
def gem_config_path(gem_name, relative_config_path) spec = Gem::Specification.find_by_name(gem_name) File.join(spec.gem_dir, relative_config_path) rescue Gem::LoadError => e raise Gem::LoadError, "Unable to find gem #{gem_name}; is the gem installed? #{e}" end
def resolve_inheritance(hash, file_loader)
def resolve_inheritance(hash, file_loader) inherited_files = Array(hash["inherit_from"]) base_configs(file_loader, inherited_files).reverse_each do |base_config| base_config.each do |k, v| next unless v.is_a?(Hash) v = v.deep_merge(hash[k]) if hash.key?(k) hash[k] = v end end end
def resolve_inheritance_from_gems(hash, gems)
def resolve_inheritance_from_gems(hash, gems) (gems || {}).each_pair do |gem_name, config_path| raise(ArgumentError, "can't inherit configuration from the erb_lint gem") if gem_name == "erb_lint" hash["inherit_from"] = Array(hash["inherit_from"]) Array(config_path).reverse_each do |path| # Put gem configuration first so local configuration overrides it. hash["inherit_from"].unshift(gem_config_path(gem_name, path)) end end end