Class: Cliver::Detector::Default
- Inherits:
-
Struct
- Object
- Struct
- Cliver::Detector::Default
- 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 =
Default pattern to use when searching #version_command output
/(?<=version )[0-9][.0-9a-z]+/i.freeze
- DEFAULT_COMMAND_ARG =
Default command argument to use against the executable to get version output
'--version'.freeze
Instance Attribute Summary collapse
-
#command_arg ⇒ String
The argument to pass to the executable to get current version Defaults to DEFAULT_COMMAND_ARG.
-
#version_pattern ⇒ Regexp
The pattern to match the version in #version_command‘s output.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Default
constructor
Forgiving input, allows either argument if only one supplied.
- #version_command(executable_path) ⇒ Array<String>
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.
25 26 27 28 29 |
# File 'lib/cliver/detector/default.rb', line 25 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_arg ⇒ String
The argument to pass to the executable to get current version Defaults to DEFAULT_COMMAND_ARG
8 9 10 |
# File 'lib/cliver/detector/default.rb', line 8 def command_arg @command_arg end |
#version_pattern ⇒ Regexp
The pattern to match the version in #version_command‘s output. Defaults to DEFAULT_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_path) ⇒ Array<String>
48 49 50 |
# File 'lib/cliver/detector/default.rb', line 48 def version_command(executable_path) [executable_path, command_arg] end |