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 =
/(?<=version )[0-9][.0-9a-z]+/i.freeze
- DEFAULT_COMMAND_ARG =
'--version'.freeze
Instance Attribute Summary collapse
-
#command_arg ⇒ Object
Returns the value of attribute command_arg.
-
#version_pattern ⇒ Object
Returns the value of attribute version_pattern.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Default
constructor
Forgiving input, allows either argument if only one supplied.
- #version_command(executable) ⇒ Object
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.
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_arg ⇒ Object
Returns the value of attribute command_arg
8 9 10 |
# File 'lib/cliver/detector/default.rb', line 8 def command_arg @command_arg end |
#version_pattern ⇒ Object
Returns the value of attribute 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 |