lib/timetrap/config.rb in timetrap-1.6.1 vs lib/timetrap/config.rb in timetrap-1.7.0

- old
+ new

@@ -14,20 +14,30 @@ # Path to the sqlite db 'database_file' => "#{ENV['HOME']}/.timetrap.db", # Unit of time for rounding (-r) in seconds 'round_in_seconds' => 900, # delimiter used when appending notes with `t edit --append` - 'append_notes_delimiter' => ' ' + 'append_notes_delimiter' => ' ', + # an array of directories to search for user defined fomatter classes + 'formatter_search_paths' => [ + "#{ENV['HOME']}/.timetrap/formatters" + ], + # formatter to use when display is invoked without a --format option + 'default_formatter' => 'text' } end def [](key) - overrides = File.exist?(PATH) ? YAML.load(File.read(PATH)) : {} + overrides = File.exist?(PATH) ? YAML.load(erb_render(File.read(PATH))) : {} defaults.merge(overrides)[key] rescue => e warn "invalid config file" warn e.message defaults[key] + end + + def erb_render(content) + ERB.new(content).result end def configure! configs = if File.exist?(PATH) defaults.merge(YAML.load_file(PATH))