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) ⇒ Object
Forward to default implementation.
Instance Method Summary collapse
-
#detect_version(executable) ⇒ String
-
should be Gem::Version-parsable.
-
-
#to_proc ⇒ Proc
This is the interface that any detector must have.
- #version_command(executable) ⇒ 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
.new(*args, &block) ⇒ Object
Forward to default implementation
9 10 11 |
# File 'lib/cliver/detector.rb', line 9 def self.new(*args, &block) Default.new(*args, &block) end |
Instance Method Details
#detect_version(executable) ⇒ String
Returns - should be Gem::Version-parsable.
30 31 32 33 34 |
# File 'lib/cliver/detector.rb', line 30 def detect_version(executable) output, _ = Open3.capture2e(*version_command(executable)) ver = output.scan(version_pattern) ver && ver.first end |
#to_proc ⇒ Proc
This is the interface that any detector must have.
39 40 41 |
# File 'lib/cliver/detector.rb', line 39 def to_proc method(:detect_version).to_proc end |
#version_command(executable) ⇒ Array<String>
15 16 17 18 |
# File 'lib/cliver/detector.rb', line 15 def version_command(executable) raise NotImplementedError unless defined? super super end |
#version_pattern ⇒ Regexp
Returns - the pattern used against the output of the #version_command, which should typically be Gem::Version-parsable.
23 24 25 26 |
# File 'lib/cliver/detector.rb', line 23 def version_pattern raise NotImplementedError unless defined? super super end |