Sha256: 1a1c0984dae3c046d93a99f61e5645e68f35151a679fa3c1d317e38232f0004a

Contents?: true

Size: 356 Bytes

Versions: 4

Compression:

Stored size: 356 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|
        YAML.safe_load(
          File.read(Pathname(dir).join(filename)),
          [Symbol]
        )
      rescue Errno::ENOENT
        {}
      end.reduce(default, &:merge)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
natour-0.6.0 lib/natour/config.rb
natour-0.5.0 lib/natour/config.rb
natour-0.4.0 lib/natour/config.rb
natour-0.3.0 lib/natour/config.rb