Sha256: 0ea8909777a6abfd8df2e8e6d754ea88c35faa4a24e3a1c714751a70f2230836

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

# encoding: utf-8
require 'cliver/version'
require 'cliver/which'
require 'cliver/assertion'
require 'cliver/detector'
require 'cliver/detector/default'

# Cliver is tool for making dependency assertions against
# command-line executables.
module Cliver
  # @see Cliver::Assertion
  # @overload (see Cliver::Assertion#initialize)
  # @param (see Cliver::Assertion#initialize)
  # @raise (see Cliver::Assertion#assert!)
  # @return (see Cliver::Assertion#assert!)
  def self.assert(*args, &block)
    Assertion.new(*args, &block).assert!
  end

  extend self

  # Wraps Cliver::assert and returns truthy/false instead of raising
  # @see Cliver::assert
  # @overload (see Cliver::Assertion#initialize)
  # @param (see Cliver::Assertion#initialize)
  # @return [False,String] either returns false or the reason why the
  #                        assertion was unmet.
  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)[A-Z]/, ' \\0')
    "#{reason}: #{error.message}"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cliver-0.1.3 lib/cliver.rb