Module: Cliver::Detector
- Included in:
- Default
- Defined in:
- lib/cliver/detector.rb
Overview
The interface for Cliver::Detector classes.
Defined Under Namespace
Classes: Default
Class Method Summary collapse
-
.new(*args, &block) ⇒ Default
Forward to default implementation.
Instance Method Summary collapse
-
#detect_version(executable_path) ⇒ String
-
should be Gem::Version-parsable.
-
-
#to_proc ⇒ Proc
This is the interface that any detector must have.
- #version_command(executable_path) ⇒ Array<String>
-
#version_pattern ⇒ Regexp
-
the pattern used against the output of the #version_command, which should typically be Gem::Version-parsable.
-
Class Method Details
Instance Method Details
#detect_version(executable_path) ⇒ String
Returns - should be Gem::Version-parsable.
34 35 36 37 38 |
# File 'lib/cliver/detector.rb', line 34 def detect_version(executable_path) output = `#{version_command(executable_path).shelljoin} 2>&1` ver = output.scan(version_pattern) ver && ver.first end |
#to_proc ⇒ Proc
This is the interface that any detector must have. If not overridden, returns a proc that wraps #detect_version
44 45 46 |
# File 'lib/cliver/detector.rb', line 44 def to_proc method(:detect_version).to_proc end |
#version_command(executable_path) ⇒ Array<String>
20 21 22 |
# File 'lib/cliver/detector.rb', line 20 def version_command(executable_path) raise NotImplementedError end |
#version_pattern ⇒ Regexp
Returns - the pattern used against the output of the #version_command, which should typically be Gem::Version-parsable.
27 28 29 30 |
# File 'lib/cliver/detector.rb', line 27 def version_pattern raise NotImplementedError unless defined? super super end |