Module: Cliver
- Extended by:
- Cliver
- Included in:
- Cliver
- Defined in:
- lib/cliver.rb,
lib/cliver/filter.rb,
lib/cliver/version.rb,
lib/cliver/detector.rb,
lib/cliver/dependency.rb,
lib/cliver/shell_capture.rb
Overview
Cliver is tool for making dependency assertions against command-line executables.
Defined Under Namespace
Modules: Filter Classes: Dependency, Detector, ShellCapture
Constant Summary collapse
- VERSION =
Cliver follows SemVer
'0.3.2'
Class Method Summary collapse
-
#initialize(executables, *requirements, options = {}) {|executable_path| ... } ⇒ Dependency
A legacy interface for detect with the option ‘strict: true`, ensures that the first executable on your path matches the requirements.
-
#initialize(executables, *requirements, options = {}) {|executable_path| ... } ⇒ Dependency
A non-raising variant of detect!, simply returns false if dependency cannot be found.
-
#initialize(executables, *requirements, options = {}) {|executable_path| ... } ⇒ Dependency
The primary interface for the Cliver gem allows detection of an executable on your path that matches a version requirement, or raise an appropriate exception to make resolution simple and straight-forward.
-
.verify!(executable, *requirements, options = {}) ⇒ String
Verify an absolute-path to an executable.
Instance Method Summary collapse
-
#dependency_unmet?(*args, &block) ⇒ False, String
Wraps Cliver::assert and returns truthy/false instead of raising.
Class Method Details
#initialize(executables, *requirements, options = {}) {|executable_path| ... } ⇒ Dependency
A legacy interface for detect with the option ‘strict: true`, ensures that the first executable on your path matches the requirements.
46 47 48 49 50 |
# File 'lib/cliver.rb', line 46 def self.assert(*args, &block) = args.last.kind_of?(Hash) ? args.pop : {} args << .merge(:strict => true) Dependency::new(*args, &block).detect! end |
#initialize(executables, *requirements, options = {}) {|executable_path| ... } ⇒ Dependency
A non-raising variant of detect!, simply returns false if dependency cannot be found.
34 35 36 |
# File 'lib/cliver.rb', line 34 def self.detect(*args, &block) Dependency::new(*args, &block).detect end |
#initialize(executables, *requirements, options = {}) {|executable_path| ... } ⇒ Dependency
The primary interface for the Cliver gem allows detection of an executable on your path that matches a version requirement, or raise an appropriate exception to make resolution simple and straight-forward.
23 24 25 |
# File 'lib/cliver.rb', line 23 def self.detect!(*args, &block) Dependency::new(*args, &block).detect! end |
.verify!(executable, *requirements, options = {}) ⇒ String
Verify an absolute-path to an executable.
59 60 61 62 63 64 65 66 67 |
# File 'lib/cliver.rb', line 59 def self.verify!(executable, *args, &block) unless File.absolute_path?(executable) raise ArgumentError, "executable path must be absolute, " + "got '#{executable.inspect}'." end = args.last.kind_of?(Hash) ? args.pop : {} args << .merge(:path => '.') # ensure path non-empty. Dependency::new(executable, *args, &block).detect! end |
Instance Method Details
#dependency_unmet?(*args, &block) ⇒ False, String
Wraps Cliver::assert and returns truthy/false instead of raising
77 78 79 80 81 82 83 84 |
# File 'lib/cliver.rb', line 77 def dependency_unmet?(*args, &block) Cliver.assert(*args, &block) false rescue Dependency::NotMet => error # Cliver::Assertion::VersionMismatch -> 'Version Mismatch' reason = error.class.name.split(':').last.gsub(/([a-z])([A-Z])/, '\\1 \\2') "#{reason}: #{error.}" end |