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

Instance Method Summary collapse

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.

Parameters:

  • executable (String)
    • the path to the executable to test

Returns:

  • (String)
    • 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_procProc

This is the interface that any detector must have.

Returns:

  • (Proc)

See Also:



39
40
41
# File 'lib/cliver/detector.rb', line 39

def to_proc
  method(:detect_version).to_proc
end

#version_command(executable) ⇒ Array<String>

Parameters:

  • executable (String)

    the executable to test

Returns:

  • (Array<String>)

Raises:

  • (NotImplementedError)


15
16
17
18
# File 'lib/cliver/detector.rb', line 15

def version_command(executable)
  raise NotImplementedError unless defined? super
  super
end

#version_patternRegexp

Returns - the pattern used against the output of the #version_command, which should typically be Gem::Version-parsable.

Returns:

  • (Regexp)
    • the pattern used against the output

    of the #version_command, which should typically be Gem::Version-parsable.

Raises:

  • (NotImplementedError)


23
24
25
26
# File 'lib/cliver/detector.rb', line 23

def version_pattern
  raise NotImplementedError unless defined? super
  super
end