class AdLint::Analyzer

Attributes

logger[R]
message_catalog[R]
traits[R]

Public Class Methods

new(name, traits, msg_catalog, target_name, output_dpath, log_basename, verbose) click to toggle source
# File lib/adlint/analyzer.rb, line 48
def initialize(name, traits, msg_catalog, target_name, output_dpath,
               log_basename, verbose)
  @name            = name
  @traits          = traits
  @message_catalog = msg_catalog
  @target_name     = target_name
  @output_dpath    = output_dpath
  @log_basename    = log_basename
  @verbose         = verbose
  @logger          = nil
end

Public Instance Methods

run() click to toggle source
# File lib/adlint/analyzer.rb, line 64
def run
  File.open(log_fpath, "w") do |log_io|
    @logger = Logger.new(log_io).tap { |logger|
      logger.progname = @name
      logger.datetime_format = "%F %T "
    }
    begin
      log_start_analysis
      execute(ProgressMonitor.new(@target_name, phases.size, @verbose))
    rescue => ex
      @logger.fatal(ex)
      return false
    end
  end
  true
end

Private Instance Methods

execute(monitor) click to toggle source
# File lib/adlint/analyzer.rb, line 82
def execute(monitor)
  subclass_responsibility
end
log_fpath() click to toggle source
# File lib/adlint/analyzer.rb, line 90
def log_fpath
  log_fname = @log_basename.add_ext(".log")
  @output_dpath ? @output_dpath.join(log_fname) : log_fname
end
log_start_analysis() click to toggle source
# File lib/adlint/analyzer.rb, line 95
def log_start_analysis
  exam_vers = @traits.exam_packages.map { |exam_pkg|
    exam_pkg.catalog
  }.map { |exam_cat| "#{exam_cat.name}-#{exam_cat.short_version}" }

  msg = "start analysis by adlint-#{SHORT_VERSION} with "
  if exam_vers.size < 3
    msg += exam_vers.join(" and ")
  else
    msg += exam_vers[0..-2].join(", ") + " and " + exam_vers.last
  end

  @logger.info("#{msg}.")
end
phases() click to toggle source
# File lib/adlint/analyzer.rb, line 86
def phases
  subclass_responsibility
end