Class: Aid::Scripts::Doctor

Inherits:
Aid::Script show all
Defined in:
lib/aid/scripts/doctor.rb

Defined Under Namespace

Classes: Check

Constant Summary

Constants included from Colorize

Colorize::COLOR_CODES

Instance Attribute Summary

Attributes inherited from Aid::Script

#argv

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Aid::Script

#description, #exit_with_help!, #help, name, run, #step, #system!

Methods included from Inheritable

included

Methods included from Colorize

#colorize, included

Constructor Details

#initialize(*args) ⇒ Doctor

Returns a new instance of Doctor.



45
46
47
48
# File 'lib/aid/scripts/doctor.rb', line 45

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

Class Method Details

.descriptionObject



37
38
39
# File 'lib/aid/scripts/doctor.rb', line 37

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

.helpObject



41
42
43
# File 'lib/aid/scripts/doctor.rb', line 41

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

Instance Method Details

#check(**options) ⇒ Object



50
51
52
53
54
55
# File 'lib/aid/scripts/doctor.rb', line 50

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

  check.run!
end

#command(s) ⇒ Object



90
91
92
# File 'lib/aid/scripts/doctor.rb', line 90

def command(s)
  "run #{colorize :command, s}"
end

#exit_codeObject



86
87
88
# File 'lib/aid/scripts/doctor.rb', line 86

def exit_code
  problems.size
end

#problemsObject



82
83
84
# File 'lib/aid/scripts/doctor.rb', line 82

def problems
  @checks.map(&:problems).flatten
end

#runObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/aid/scripts/doctor.rb', line 57

def run
  puts "  To implement this script for your repository, create the following\n  file in \#{colorize(:green, \"\#{aid_directory}/doctor.rb\")}:\n\n    class Doctor < Aid::Scripts::Doctor\n      def run\n        check_phantomjs_installed\n      end\n\n      private\n\n      def check_phantomjs_installed\n        check name: \"PhantomJS installed\",\n          command: \"which phantomjs\",\n          remedy: command(\"brew install phantomjs\")\n      end\n    end\n\n  You can add as many checks to your script as you want.\n  HELP\n\n  exit\nend\n"