Sha256: 2434f9139d07075c96c8588e3cfbe3a764876b003fd6a3e8d4e91274bf049352
Contents?: true
Size: 801 Bytes
Versions: 3
Compression:
Stored size: 801 Bytes
Contents
# coding: utf-8 require 'yaml' module Mnogootex class Configuration < Hash DEFAULT = { 'animation' => '⣾⣽⣻⢿⡿⣟⣯⣷' } CFG_FILENAME = '.mnogootex.yml'.freeze def initialize @paths = [] merge! DEFAULT end def load(pathname = Dir.pwd) scan_cfg Pathname(pathname) filter_cfg merge! load_cfg self end private def scan_cfg(pathname) @paths << pathname.join(CFG_FILENAME) return if pathname.root? scan_cfg pathname.parent end def filter_cfg @paths. select!(&:readable?). reject!(&:zero?) end def load_cfg @paths. reverse. map { |pathname| YAML.load_file pathname }. inject(&:merge!) # TODO: deep merge end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mnogootex-0.2.1 | lib/mnogootex/configuration.rb |
mnogootex-0.2.0 | lib/mnogootex/configuration.rb |
mnogootex-0.1.0 | lib/mnogootex/configuration.rb |