Class: StatusPageRubyCli

Inherits:
Thor
  • Object
show all
Defined in:
lib/status_page_ruby_cli.rb

Constant Summary collapse

PULL_SECONDS =
10

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ StatusPageRubyCli

Returns a new instance of StatusPageRubyCli.



4
5
6
7
8
9
10
11
# File 'lib/status_page_ruby_cli.rb', line 4

def initialize(*args)
  super(*args)
  data_file_path = File.join(ENV['HOME'], '.status_page_ruby_data.csv')
  create_data_file_if_needed(data_file_path)
  storage = StatusPageRuby::Storage.new(data_file_path)
  repository = StatusPageRuby::Repositories::Status.new(storage)
  setup_services(repository)
end

Instance Method Details

#backupObject



42
43
44
# File 'lib/status_page_ruby_cli.rb', line 42

def backup
  backup_data.call(options[:path])
end

#historyObject



30
31
32
# File 'lib/status_page_ruby_cli.rb', line 30

def history
  puts build_history_table.call(options[:service])
end

#liveObject



21
22
23
24
25
26
# File 'lib/status_page_ruby_cli.rb', line 21

def live
  loop do
    puts build_log_table.call(pull_statuses.call)
    sleep PULL_SECONDS
  end
end

#pullObject



15
16
17
18
# File 'lib/status_page_ruby_cli.rb', line 15

def pull
  records = pull_statuses.call
  puts build_log_table.call(records) if options[:log]
end

#restoreObject



48
49
50
# File 'lib/status_page_ruby_cli.rb', line 48

def restore
  restore_data.call(options[:path])
end

#statsObject



36
37
38
# File 'lib/status_page_ruby_cli.rb', line 36

def stats
  puts build_stats_table.call(options[:service])
end