Sha256: 1b6664ed0ffc0ab6212aa4f51852c6b75dd4d5f49228d9805987113228be9736

Contents?: true

Size: 413 Bytes

Versions: 2

Compression:

Stored size: 413 Bytes

Contents

require 'pathname'
require 'yaml'

module Natour
  class Config
    def self.load_file(filename, default: {}, dirs: [Dir.home, Dir.pwd])
      dirs.map do |dir|
        begin
          YAML.safe_load(
            File.read(Pathname(dir).join(filename)),
            permitted_classes: [Symbol]
          )
        rescue Errno::ENOENT
          {}
        end
      end.reduce(default, &:merge)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
natour-0.2.0 lib/natour/config.rb
natour-0.1.0 lib/natour/config.rb