Module: Work::Md::Config

Defined in:
lib/work/md/config.rb

Constant Summary collapse

DEFAULT_WORK_DIR =
"#{Dir.home}/work-md"
TRANSLATIONS =
{
  'pt' =>
    {
      tasks: 'Atividades',
      meetings: 'Reuniões',
      interruptions: 'Interrupções',
      difficulties: 'Dificuldades',
      observations: 'Observações',
      pomodoros: 'Pomodoros / Ciclos',
      per_day: 'por dia',
      total: 'total',
      days_bars: 'Resumo',
      did: 'Feito',
      todo: 'Planejado'
    },
  'en' =>
    {
      tasks: 'Tasks',
      meetings: 'Meetings',
      interruptions: 'Interruptions',
      difficulties: 'Difficulties',
      observations: 'Observations',
      pomodoros: 'Pomodoros / Cycles',
      per_day: 'per day',
      total: 'all',
      days_bars: 'Summary',
      did: 'Done',
      todo: 'To do'
    },
  'es' =>
    {
      tasks: 'Tareas',
      meetings: 'Reuniones',
      interruptions: 'Interrupciones',
      difficulties: 'Dificultades',
      observations: 'Observaciones',
      pomodoros: 'Pomodoros / Ciclos',
      per_day: 'por día',
      total: 'total',
      days_bars: 'Abstracto',
      did: 'Hecho',
      todo: 'Planificado'
    }
}.freeze

Class Method Summary collapse

Class Method Details

.editorObject



58
59
60
# File 'lib/work/md/config.rb', line 58

def self.editor
  ENV['EDITOR'] || ENV['VISUAL'] || yaml_file['editor'] || nil
end

.titleObject



54
55
56
# File 'lib/work/md/config.rb', line 54

def self.title
  yaml_file['title'] || ''
end

.translationsObject



71
72
73
74
75
# File 'lib/work/md/config.rb', line 71

def self.translations
  TRANSLATIONS[ENV['WORK_MD_LANG']] ||
    TRANSLATIONS[yaml_file['lang']] ||
    TRANSLATIONS['en']
end

.work_dirObject



62
63
64
65
66
67
68
69
# File 'lib/work/md/config.rb', line 62

def self.work_dir
  dir =
    ENV['WORK_MD_DIR'] || DEFAULT_WORK_DIR

  return "#{dir}/#{ENV['WORK_MD_TAG']}" if ENV['WORK_MD_TAG']

  dir
end

.yaml_fileObject



77
78
79
80
81
# File 'lib/work/md/config.rb', line 77

def self.yaml_file
  YAML.load_file("#{DEFAULT_WORK_DIR}/config.yml")
rescue StandardError
  {}
end