lib/timetrap/config.rb in timetrap-1.4.1 vs lib/timetrap/config.rb in timetrap-1.5.0
- old
+ new
@@ -12,11 +12,13 @@
def defaults
{
# Path to the sqlite db
'database_file' => "#{ENV['HOME']}/.timetrap.db",
# Unit of time for rounding (-r) in seconds
- 'round_in_seconds' => 900
+ 'round_in_seconds' => 900,
+ # delimiter used when appending notes with `t edit --append`
+ 'append_notes_delimiter' => ' '
}
end
def [](key)
overrides = File.exist?(PATH) ? YAML.load(File.read(PATH)) : {}
@@ -26,13 +28,16 @@
puts e.message
defaults[key]
end
def configure!
- unless File.exist?(PATH)
- File.open(PATH, 'w') do |fh|
- fh.puts(defaults.to_yaml)
- end
+ configs = if File.exist?(PATH)
+ defaults.merge(YAML.load_file(PATH))
+ else
+ defaults
+ end
+ File.open(PATH, 'w') do |fh|
+ fh.puts(configs.to_yaml)
end
end
end
end