class Bundler::Audit::Configuration
def self.load(file_path)
-
(Configuration)
-
Raises:
-
(InvalidConfigurationError)
- -
(FileNotFound)
-
Parameters:
-
file_path
(String
) --
def self.load(file_path) raise(FileNotFound,"Configuration file '#{file_path}' does not exist") unless File.exist?(file_path) doc = YAML.parse(File.new(file_path)) unless doc.root.kind_of?(YAML::Nodes::Mapping) raise(InvalidConfigurationError,"Configuration found in '#{file_path}' is not a Hash") end config = {} doc.root.children.each_slice(2) do |key,value| case key.value when 'ignore' unless value.is_a?(YAML::Nodes::Sequence) raise(InvalidConfigurationError,"'ignore' key found in config file, but is not an Array") end unless value.children.all? { |node| node.is_a?(YAML::Nodes::Scalar) } raise(InvalidConfigurationError,"'ignore' array in config file contains a non-String") end config[:ignore] = value.children.map(&:value) end end new(config) end