class Herodot::Configuration

Constants

CONFIG_FILE
DEFAULT_CONFIGURATION

Public Class Methods

new(worklog_file = '~/.worklog') click to toggle source
# File lib/herodot/configuration.rb, line 16
def initialize(worklog_file = '~/.worklog')
  @worklog_file = worklog_file
  if File.exist?(CONFIG_FILE)
    @config = load_configuration
  else
    @config = DEFAULT_CONFIGURATION
    save_configuration
  end
end

Public Instance Methods

load_configuration() click to toggle source
# File lib/herodot/configuration.rb, line 43
def load_configuration
  File.open(CONFIG_FILE) { |f| YAML.load(f) }
end
projects_directory() click to toggle source
# File lib/herodot/configuration.rb, line 30
def projects_directory
  File.expand_path(@config['projects_directory'] || DEFAULT_CONFIGURATION['projects_directory'])
end
save_configuration() click to toggle source
# File lib/herodot/configuration.rb, line 39
def save_configuration
  File.open(CONFIG_FILE, 'w') { |f| YAML.dump(@config, f) }
end
work_times() click to toggle source
# File lib/herodot/configuration.rb, line 34
def work_times
  (@config['work_times'] || DEFAULT_CONFIGURATION['work_times'])
    .map { |k, v| [k.to_sym, v.split(':').map(&:to_i)] }
end
worklog_file() click to toggle source
# File lib/herodot/configuration.rb, line 26
def worklog_file
  File.expand_path(@worklog_file)
end