Sha256: 45ad6f3946836930ab523a7828390562c91ad99c369b2dabf6a87ad4da2a0b8f
Contents?: true
Size: 1.12 KB
Versions: 3
Compression:
Stored size: 1.12 KB
Contents
# encoding: utf-8 require 'open3' module Cliver # Default implementation of Cliver::Detector # Requires a command argument (default '--version') # and a pattern-matcher Regexp with sensible default. class Detector::Default < Struct.new(:command_arg, :version_pattern) include Detector DEFAULT_VERSION_PATTERN = /(?<=version )[0-9][.0-9a-z]+/i.freeze DEFAULT_COMMAND_ARG = '--version'.freeze # Forgiving input, allows either argument if only one supplied. # # @overload initialize(command_arg) # @overload initialize(version_pattern) # @overload initialize(command_arg, version_pattern) # @param command_arg [String] ('--version') # @param version_pattern [Regexp] (/(?<=version )[0-9][.0-9a-z]+/i) def initialize(*args) command_arg = args.shift if args.first.kind_of?(String) version_pattern = args.shift super(command_arg, version_pattern) end def version_pattern super || DEFAULT_VERSION_PATTERN end def command_arg super || DEFAULT_COMMAND_ARG end def version_command(executable) [executable, command_arg] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cliver-0.1.2 | lib/cliver/detector/default.rb |
cliver-0.1.1 | lib/cliver/detector/default.rb |
cliver-0.1.0 | lib/cliver/detector/default.rb |