Module: Cliver

Extended by:
Cliver
Included in:
Cliver
Defined in:
lib/cliver.rb,
lib/cliver/which.rb,
lib/cliver/filter.rb,
lib/cliver/version.rb,
lib/cliver/detector.rb,
lib/cliver/assertion.rb,
lib/cliver/which/posix.rb,
lib/cliver/which/windows.rb

Overview

Cliver is tool for making dependency assertions against command-line executables.

Defined Under Namespace

Modules: Filter, Which Classes: Assertion, Detector

Constant Summary collapse

VERSION =

Cliver follows SemVer

'0.1.4'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

#initialize(executable, *requirements, options = {}) ⇒ Assertion

Parameters:

  • executable (String)
  • requirements (Array<String>, String)

    splat of strings whose elements follow the pattern

    [<operator>] <version>
    

    Where <operator> is optional (default ‘=”) and in the set

    '=', '!=', '>', '<', '>=', '<=', or '~>'
    

    And <version> is dot-separated integers with optional alphanumeric pre-release suffix. See also Specifying Versions

  • options (Hash<Symbol,Object>)

Raises:

  • (DependencyVersionMismatch)

    if installed version does not match

  • (DependencyNotFound)

    if no installed version on your path

See Also:



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

def self.assert(*args, &block)
  Assertion.new(*args, &block).assert!
end

Instance Method Details

#initialize(executable, *requirements, options = {}) ⇒ Assertion

Wraps Cliver::assert and returns truthy/false instead of raising

Parameters:

  • executable (String)
  • requirements (Array<String>, String)

    splat of strings whose elements follow the pattern

    [<operator>] <version>
    

    Where <operator> is optional (default ‘=”) and in the set

    '=', '!=', '>', '<', '>=', '<=', or '~>'
    

    And <version> is dot-separated integers with optional alphanumeric pre-release suffix. See also Specifying Versions

  • options (Hash<Symbol,Object>)

Returns:

  • (False, String)

    either returns false or the reason why the assertion was unmet.

See Also:

  • assert


28
29
30
31
32
33
34
35
# File 'lib/cliver.rb', line 28

def dependency_unmet?(*args, &block)
  Cliver.assert(*args, &block)
  false
rescue Assertion::DependencyNotMet => error
  # Cliver::Assertion::VersionMismatch -> 'Version Mismatch'
  reason = error.class.name.split(':').last.gsub(/([a-z])([A-Z])/, '\\1 \\2')
  "#{reason}: #{error.message}"
end