class AdLint::Phase

DESCRIPTION

Base of analysis phase classes.

Public Class Methods

new(phase_ctxt, pkg_name, phase_name) click to toggle source

DESCRIPTION

Constructs an analysis pass.

PARAMETER

phase_ctxt

PhaseContext – Analysis context.

# File lib/adlint/phase.rb, line 48
def initialize(phase_ctxt, pkg_name, phase_name)
  @phase_ctxt = phase_ctxt
  @pkg_name   = pkg_name
  @phase_name = phase_name
end

Public Instance Methods

execute() click to toggle source

DESCRIPTION

Executes the analysis.

# File lib/adlint/phase.rb, line 56
def execute
  monitored_region(@phase_name) do |mon|
    do_execute(@phase_ctxt, mon)
    register_examinations(@phase_ctxt)
  end
rescue Error => ex
  report.write_message(FatalErrorMessage.new(message_catalog, ex))
  raise
end

Private Instance Methods

context_key_of(str) click to toggle source
# File lib/adlint/phase.rb, line 92
def context_key_of(str)
  "#{@pkg_name}_#{str}".to_sym
end
do_execute(phase_ctxt, monitor) click to toggle source

DESCRIPTION

Executes the analysis.

Subclasses must implement this method.

# File lib/adlint/phase.rb, line 71
def do_execute(phase_ctxt, monitor)
  subclass_responsibility
end
examinations() click to toggle source
# File lib/adlint/phase.rb, line 88
def examinations
  @phase_ctxt[context_key_of("examinations")] || []
end
register_examinations(phase_ctxt) click to toggle source
# File lib/adlint/phase.rb, line 75
def register_examinations(phase_ctxt)
  key = context_key_of("examinations")
  phase_ctxt[key] ||= []
  traits.exam_packages.each do |exam_pkg|
    exam_pkg.catalog.examination_classes.each do |exam_class|
      next unless exam_class.registrant_phase_class == self.class
      if exam_class.required?(phase_ctxt)
        phase_ctxt[key].push(exam_class.new(phase_ctxt))
      end
    end
  end
end