Class: ES::Diag::Check
- Inherits:
-
Object
- Object
- ES::Diag::Check
- Defined in:
- lib/es-diag/check.rb
Instance Method Summary collapse
- #all_checks ⇒ Object
- #data ⇒ Object
- #how_to(text) ⇒ Object
-
#initialize(ui) ⇒ Check
constructor
A new instance of Check.
- #run_check(filename) ⇒ Object
- #title(text) ⇒ Object
- #warn(text) ⇒ Object
Constructor Details
#initialize(ui) ⇒ Check
Returns a new instance of Check.
2 3 4 |
# File 'lib/es-diag/check.rb', line 2 def initialize(ui) @ui = ui end |
Instance Method Details
#all_checks ⇒ Object
24 25 26 27 28 |
# File 'lib/es-diag/check.rb', line 24 def all_checks Dir[File.('../checks/*.rb', File.dirname(__FILE__))].each do |fcheck| run_check(fcheck) end end |
#data ⇒ Object
10 11 12 |
# File 'lib/es-diag/check.rb', line 10 def data @data ||= ES::Diag::Context.new(@ui).data end |
#how_to(text) ⇒ Object
14 15 16 |
# File 'lib/es-diag/check.rb', line 14 def how_to(text) @run_context[:help ] = text end |
#run_check(filename) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/es-diag/check.rb', line 30 def run_check(filename) @run_context = {} self.instance_eval(IO.read(filename), filename, 1) @ui.title @run_context[:title] || "#{filename}" if @run_context[:warnings] && @run_context[:warnings].length > 0 @ui.warn "#{@run_context[:warnings].length} problem(s) found:" @run_context[:warnings].each do | warning | @ui.warn "- #{warning}" end if @run_context[:help] @ui.info "\n\n#{@ui.em 'Use these instructions to amend the problems:'}" @ui.info @run_context[:help] + "\n" end end end |
#title(text) ⇒ Object
6 7 8 |
# File 'lib/es-diag/check.rb', line 6 def title(text) @run_context[:title] = text end |
#warn(text) ⇒ Object
18 19 20 21 |
# File 'lib/es-diag/check.rb', line 18 def warn(text) @run_context[:warnings] ||= [] @run_context[:warnings] << text end |