Sha256: 8cb866dcf1504d845732218f0adaa61866d360f6f661e8d4a9693e9b239eeb95

Contents?: true

Size: 546 Bytes

Versions: 2

Compression:

Stored size: 546 Bytes

Contents

module Ocp::Registry
  module YamlHelper

    def load_yaml_file(path, expected_type = Hash)
      unless File.exists?(path)
        raise(ConfigError, "Cannot find file `#{path}'")
      end

      yaml = Psych.load_file(path)

      if expected_type && !yaml.is_a?(expected_type)
        raise ConfigError, "Incorrect file format in `#{path}', " \
                           "#{expected_type} expected"
      end

      yaml
    rescue SystemCallError => e
      raise ConfigError, "Cannot load YAML file at `#{path}': #{e}"
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ocp_registry-0.0.5.pre lib/ocp_registry/yaml_helper.rb
ocp_registry-0.0.1.alpha lib/ocp_registry/yaml_helper.rb