Class: Vgcal::Handlers::Describer

Inherits:
Thor
  • Object
show all
Defined in:
lib/vgcal/handlers/describer.rb

Overview

Describer

Instance Method Summary collapse

Instance Method Details

#initObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/vgcal/handlers/describer.rb', line 15

def init
  vgcal_dir = "#{Dir.home}/.vgcal"
  cred_json = "#{vgcal_dir}/credentials.json"
  dot_env = "#{vgcal_dir}/.env"
  gem_root = File.expand_path('../../../', __dir__ || '.')
  FileUtils.mkdir_p(vgcal_dir, mode: 0o755)
  FileUtils.cp(File.join(gem_root, 'template-credentials.json'), cred_json) unless File.exist?(cred_json)
  FileUtils.cp(File.join(gem_root, 'template.env'), dot_env) unless File.exist?(dot_env)
  puts "Fix the __FIX_ME__ in #{cred_json} and #{dot_env}"
end

#showObject



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/vgcal/handlers/describer.rb', line 35

def show
  Dotenv.load("#{Dir.home}/.vgcal/.env")
  my_calendar = MyCalendar.new(DateCalculator.start_date(options), DateCalculator.end_date(options))
  events = my_calendar.events

  case options[:output]
  when 'json'
    stdout_json(my_calendar.tasks(events), my_calendar.invited_meetings(events))
  else
    stdout_default(my_calendar.tasks(events), my_calendar.invited_meetings(events))
  end
end

#versionObject



50
51
52
# File 'lib/vgcal/handlers/describer.rb', line 50

def version
  puts VERSION
end