Module: EndOfLife::VersionDetector
- Defined in:
- lib/end_of_life/version_detector.rb
Instance Method Summary collapse
- #detect(file) ⇒ Object
- #detect_all(files) ⇒ Object
- #detects_from(file, &block) ⇒ Object
- #file_detectors ⇒ Object
- #relevant_files ⇒ Object
Instance Method Details
#detect(file) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/end_of_life/version_detector.rb', line 17 def detect(file) return if file.read.strip.empty? detector = file_detectors[File.basename(file.path)] or return version = detector.call(file.read) or return return if version.zero? version end |
#detect_all(files) ⇒ Object
13 14 15 |
# File 'lib/end_of_life/version_detector.rb', line 13 def detect_all(files) files.filter_map { |file| detect(file) } end |
#detects_from(file, &block) ⇒ Object
7 8 9 |
# File 'lib/end_of_life/version_detector.rb', line 7 def detects_from(file, &block) file_detectors[file] = block end |
#file_detectors ⇒ Object
3 4 5 |
# File 'lib/end_of_life/version_detector.rb', line 3 def file_detectors @file_detectors ||= {} end |
#relevant_files ⇒ Object
11 |
# File 'lib/end_of_life/version_detector.rb', line 11 def relevant_files = file_detectors.keys |