Class: Checkup::CLI::Utility

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/checkup/cli/utility.rb

Instance Method Summary collapse

Instance Method Details

#listObject



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/checkup/cli/utility.rb', line 32

def list
  root_path = options[:root_path]
  
  if root_path == ""
    root_path = Checkup::Config::DEFAULT_ROOT_PATH
  end
  
  load root_path
  
  Model.all.each do |model|
    puts model.trigger
  end
end

#performObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/checkup/cli/utility.rb', line 9

def perform
  root_path = options[:root_path]
  
  if root_path == ""
    root_path = Checkup::Config::DEFAULT_ROOT_PATH
  end
        
  load root_path
  
  triggers = options[:trigger].split(",")
  triggers.map!(&:strip).map! {|t|
    t.include?('*') ? Model.find_matching(t) : t
  }.flatten!

  triggers.each do |trigger|
    model = Model.find(trigger)
    model.perform!
    Logger.clear!
  end
end