Class: AutomateIt::ShellManager::Which
- Inherits:
-
BaseDriver
- Object
- Common
- Plugin::Base
- Plugin::Driver
- BaseDriver
- AutomateIt::ShellManager::Which
- Defined in:
- lib/automateit/shell_manager/which.rb
Overview
ShellManager::Which
A ShellManager driver providing access to the which
command found on Unix-like systems.
Constant Summary
Constants inherited from Plugin::Driver
Plugin::Driver::BASE_DRIVER_NAME
Constants included from Constants
Constants::PERROR, Constants::PEXEC, Constants::PNOTE, Constants::WARNING_BOILERPLATE
Instance Attribute Summary
Attributes inherited from Plugin::Driver
Attributes inherited from Common
Instance Method Summary collapse
-
#suitability(method, *args) ⇒ Object
:nodoc:.
-
#which(command) ⇒ Object
See ShellManager#which.
-
#which!(command) ⇒ Object
See ShellManager#which!.
Methods inherited from BaseDriver
Methods inherited from Plugin::Driver
abstract_driver, #available?, base_driver, base_driver?, depends_on, inherited, manager_token, #setup
Methods inherited from Plugin::Base
Methods inherited from Common
#initialize, #log, #nitpick, #noop, #noop=, #noop?, #preview, #preview=, #preview?, #preview_for, #setup, #superuser?, #writing, #writing=, #writing?
Constructor Details
This class inherits a constructor from AutomateIt::Common
Instance Method Details
#suitability(method, *args) ⇒ Object
:nodoc:
8 9 10 11 |
# File 'lib/automateit/shell_manager/which.rb', line 8 def suitability(method, *args) # :nodoc: # Level must be higher than Portable return available? ? 2 : 0 end |
#which(command) ⇒ Object
See ShellManager#which
14 15 16 17 |
# File 'lib/automateit/shell_manager/which.rb', line 14 def which(command) data = `which "#{command}" 2>&1`.chomp return (! data.blank? && File.exists?(data)) ? data : nil end |
#which!(command) ⇒ Object
See ShellManager#which!
20 21 22 23 24 |
# File 'lib/automateit/shell_manager/which.rb', line 20 def which!(command) if which(command).nil? raise ArgumentError.new("command not found: #{command}") end end |