Sha256: 24c73354dce36787134d0946f33e988fa6211b6c4e093bd9e8ce04af35084542
Contents?: true
Size: 615 Bytes
Versions: 1
Compression:
Stored size: 615 Bytes
Contents
module Timetrap module Config extend self PATH = ENV['TIMETRAP_CONFIG_FILE'] || File.join(ENV['HOME'], '.timetrap.yml') def defaults { 'database_file' => "#{ENV['HOME']}/.timetrap.db" } end def [](key) overrides = File.exist?(PATH) ? YAML.load(File.read(PATH)) : {} defaults.merge(overrides)[key] rescue => e puts "invalid config file" puts e.message defaults[key] end def configure! unless File.exist?(PATH) File.open(PATH, 'w') do |fh| fh.puts(defaults.to_yaml) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
timetrap-1.2.0 | lib/timetrap/config.rb |