Method: Flydata::Cron#update

Defined in:
lib/flydata/cron.rb

#update(option = nil) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/flydata/cron.rb', line 19

def update(option=nil)
  arg = option ? option : ''

  # Check condition
  check_crontab_command
  dump_cron_setting
  reagistered = check_cron_setting

  # Remove mode
  if arg == REMOVE_OPTION
    unless reagistered
      puts "Skip removing. There are no flydata jobs in crontab."
    else
      remove_cron_setting
      puts "Updated crontab to remove the deletion of your log data."
    end
  # Add mode
  else
    if reagistered
      puts "Skip register. Already cron setup done."
    else
      add_cron_setting
      puts "Updated crontab to manage the deletion of your log data."
    end
  end
  true
end