Class: Pedant::CommandCheck

Inherits:
Command
  • Object
show all
Defined in:
lib/pedant/commands/check.rb

Class Method Summary collapse

Methods inherited from Command

all, banner, find, inherited, initialize!, run

Class Method Details

.analyze(cfg, path, args) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/pedant/commands/check.rb', line 33

def self.analyze(cfg, path, args)
  Check.initialize!

  # Get a list of every existing check.
  pending = Check.all

  # Initialize the knowledge base where checks can store information for
  # other checks.
  kb = KnowledgeBase.new(:file_mode, path)

  # Try to run each pending check, until we've run all our checks or
  # deadlocked.
  fatal = false
  until pending.empty? || fatal
    # Find all of the checks that can run right now.
    ready = pending.select { |cls| cls.ready?(kb) }
    break if ready.empty?

    # Run all of the checks that are ready.
    ready.each do |cls|
      # Create a new check instance.
      chk = cls.new(kb)
      pending.delete(cls)

      chk.run

      # Fatal errors mean that no further checks should be processed.
      if chk.result == :fatal
        fatal = true
        break
      end

      # Display the results of the check.
      puts chk.report(cfg[:verbose])
    end
  end

  # Notify the user if any checks did not run due to unsatisfied
  # dependencies or a fatal error occurring before they had the chance to
  # run.
  pending.each { |cls| puts cls.new(kb).report(cfg[:verbose]) }
end

.bindingObject



29
30
31
# File 'lib/pedant/commands/check.rb', line 29

def self.binding
  'check'
end