Class: CitizenCodeScripts::Doctor

Inherits:
Base
  • Object
show all
Defined in:
lib/citizen_code_scripts/doctor.rb

Direct Known Subclasses

HerokuDoctor

Defined Under Namespace

Classes: Check

Constant Summary

Constants included from Colorize

Colorize::COLOR_CODES

Instance Attribute Summary

Attributes inherited from Base

#argv

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#app_names, #app_root, inherited, load_scripts_deferred, name, run, script_classes, script_names, scripts, #staging_app_name, #step, #system!

Methods included from Colorize

#colorize, included

Constructor Details

#initialize(*args) ⇒ Doctor

Returns a new instance of Doctor.



39
40
41
42
# File 'lib/citizen_code_scripts/doctor.rb', line 39

def initialize(*args)
  super
  @checks = []
end

Class Method Details

.descriptionObject



35
36
37
# File 'lib/citizen_code_scripts/doctor.rb', line 35

def self.description
  "Checks the health of your development environment"
end

.helpObject



53
54
55
# File 'lib/citizen_code_scripts/doctor.rb', line 53

def self.help
  "doctor - helps you diagnose any setup issues with this application\n"
end

.help_subcommandsObject



57
58
59
60
61
62
# File 'lib/citizen_code_scripts/doctor.rb', line 57

def self.help_subcommands
  {
    "citizen doctor" => "runs health checks and gives a report",
    "citizen doctor list" => "prints a list of default checks you can use when overriding doctor checks in your app"
  }
end

Instance Method Details

#check(**options) ⇒ Object



80
81
82
83
84
85
# File 'lib/citizen_code_scripts/doctor.rb', line 80

def check(**options)
  check = Check.new(options)
  @checks << check

  check.run!
end

#list_default_checksObject



69
70
71
72
73
74
75
76
77
78
# File 'lib/citizen_code_scripts/doctor.rb', line 69

def list_default_checks
  puts "These default checks are available for use in your overrides:"
  puts

  default_checks.each do |name|
    puts "  - #{colorize(:light_blue, name)}"
  end

  puts
end

#runObject



44
45
46
47
48
49
50
51
# File 'lib/citizen_code_scripts/doctor.rb', line 44

def run
  case argv.first
  when "list"
    list_default_checks
  else
    run_doctor
  end
end

#run_doctorObject



64
65
66
67
# File 'lib/citizen_code_scripts/doctor.rb', line 64

def run_doctor
  run_checks
  report
end