Class: Cliver::Detector::Default

Inherits:
Struct
  • Object
show all
Includes:
Cliver::Detector
Defined in:
lib/cliver/detector/default.rb

Overview

Default implementation of Cliver::Detector Requires a command argument (default ‘–version’) and a pattern-matcher Regexp with sensible default.

Constant Summary collapse

DEFAULT_VERSION_PATTERN =
/(?<=version )[0-9][.0-9a-z]+/i.freeze
DEFAULT_COMMAND_ARG =
'--version'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Cliver::Detector

#detect_version, new, #to_proc

Constructor Details

#initialize(command_arg) ⇒ Default #initialize(version_pattern) ⇒ Default #initialize(command_arg, version_pattern) ⇒ Default

Forgiving input, allows either argument if only one supplied.

Parameters:

  • command_arg (String)

    (‘–version’)

  • version_pattern (Regexp)

    (/(?<=version )[0-9]+/i)



21
22
23
24
25
# File 'lib/cliver/detector/default.rb', line 21

def initialize(*args)
  command_arg = args.shift if args.first.kind_of?(String)
  version_pattern = args.shift
  super(command_arg, version_pattern)
end

Instance Attribute Details

#command_argObject

Returns the value of attribute command_arg

Returns:

  • (Object)

    the current value of command_arg



8
9
10
# File 'lib/cliver/detector/default.rb', line 8

def command_arg
  @command_arg
end

#version_patternObject

Returns the value of attribute version_pattern

Returns:

  • (Object)

    the current value of version_pattern



8
9
10
# File 'lib/cliver/detector/default.rb', line 8

def version_pattern
  @version_pattern
end

Instance Method Details

#version_command(executable) ⇒ Object



35
36
37
# File 'lib/cliver/detector/default.rb', line 35

def version_command(executable)
  [executable, command_arg]
end