class Xezat::DetectorManager

Public Class Methods

new(detector_dir = File.expand_path(File.join(File.dirname(__FILE__), 'detector'))) click to toggle source
# File lib/xezat/detectors.rb, line 8
def initialize(detector_dir = File.expand_path(File.join(File.dirname(__FILE__), 'detector')))
  Xezat.logger.debug('  Load detectors')
  @detectors = {}
  Dir.glob(File.join(detector_dir, '*.rb')).sort.each do |rb|
    require rb
    @detectors[File.basename(rb, '.rb').intern] = Object.const_get("Xezat::Detector::#{File.basename(rb, '.rb').camelize}").new
  end
end

Public Instance Methods

detect(variables) click to toggle source
# File lib/xezat/detectors.rb, line 17
def detect(variables)
  Xezat.logger.debug('    Detect tools')
  tools = []
  @detectors.each do |name, detector|
    if detector.detect(variables)
      tools << name
      Xezat.logger.debug("      #{name} ... yes")
    else
      Xezat.logger.debug("      #{name} ... no")
    end
  end
  if tools.include?(:python27) && (tools.include?(:python36) || tools.include?(:python37))
    Xezat.logger.debug('    Remove python27 because of detecting python3x')
    tools.delete(:python27)
  end
  tools
end