Class: Xezat::DetectorManager

Inherits:
Object
  • Object
show all
Defined in:
lib/xezat/detectors.rb

Constant Summary collapse

@@detectors =
{}

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object



31
32
33
# File 'lib/xezat/detectors.rb', line 31

def self.[](name)
  @@detectors[name]
end

.detect(variables) ⇒ Object

登録されている detector で source tree を検証する



23
24
25
26
27
28
29
# File 'lib/xezat/detectors.rb', line 23

def self.detect(variables)
  tools = []
  @@detectors.each do |name, detector|
    tools << name if detector.detect(variables)
  end
  tools
end

.load_default_detectors(path = File::expand_path(File::join(File::dirname(__FILE__), 'detector'))) ⇒ Object

detector をロードする



16
17
18
19
20
# File 'lib/xezat/detectors.rb', line 16

def self.load_default_detectors(path = File::expand_path(File::join(File::dirname(__FILE__), 'detector')))
  Dir::glob(File::join(path, '*.rb')) do |rb|
    require rb
  end
end

.register(name, klass) ⇒ Object

detector を登録する



10
11
12
13
# File 'lib/xezat/detectors.rb', line 10

def self.register(name, klass)
  raise MultipleDetectorDefinitionError, "'#{name}' already defined" if @@detectors.key?(name)
  @@detectors[name] = klass.new
end