Class: Xezat::DetectorManager
- Inherits:
-
Object
- Object
- Xezat::DetectorManager
- Defined in:
- lib/xezat/detectors.rb
Constant Summary collapse
- @@detectors =
{}
Class Method Summary collapse
- .[](name) ⇒ Object
-
.detect(variables) ⇒ Object
登録されている detector で source tree を検証する.
-
.load_default_detectors(path = File::expand_path(File::join(File::dirname(__FILE__), 'detector'))) ⇒ Object
detector をロードする.
-
.register(name, klass) ⇒ Object
detector を登録する.
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::(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 |