Module | Juicer::Binary |
In: |
lib/juicer/binary.rb
|
Defines an abstract implementation of a binary that needs to be "shelled out" to be run. Provides a starting point when wrapping and API around a shell binary.
The module requires the including class to define the default_options method. It should return a hash of options where options are keys and default values are the values. Only options defined in this hash will be allowed to set on the binary.
Locate the binary to execute. The binary is searched for in the following places:
1) The paths specified through my_binary.path << "/usr/bin" 2) The path specified by the given environment variable 3) Current working directory
The name of the binary may be a glob pattern, resulting in locate returning an array of matches. This is useful in cases where the path is expected to store several versions oof a binary in the same directory, like /usr/bin/ruby /usr/bin/ruby1.8 /usr/bin/ruby1.9
locate always returns an array, or nil if no binaries where found. The result is always all files matching the given pattern in one of the specified paths - ie the first path where the pattern matches something.
Allows for options to be set and read directly on the object as though they were standard attributes. compressor.verbose translates to compressor.get_opt(‘verbose’) and compressor.verbose = true to compressor.set_opt(‘verbose’, true)
Set an option. Important: you can only set options that are predefined by the implementing class opt = The option to set value = The value of the option