class ERBLint::RunnerConfigResolver
Public Instance Methods
resolve_inheritance(hash, file_loader)
click to toggle source
# File lib/erb_lint/runner_config_resolver.rb, line 26 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
resolve_inheritance_from_gems(hash, gems)
click to toggle source
# File lib/erb_lint/runner_config_resolver.rb, line 37 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
Private Instance Methods
base_configs(file_loader, inherit_from)
click to toggle source
# File lib/erb_lint/runner_config_resolver.rb, line 58 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
gem_config_path(gem_name, relative_config_path)
click to toggle source
# File lib/erb_lint/runner_config_resolver.rb, line 51 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