lib/juicer/binary.rb in juicer-0.2.6 vs lib/juicer/binary.rb in juicer-1.0.0
- old
+ new
@@ -1,6 +1,6 @@
-require File.expand_path(File.join(File.dirname(__FILE__), "chainable"))
+require "juicer/chainable"
module Juicer
# 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
@@ -10,16 +10,15 @@
# 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.
#
module Binary
-
# Initialize binary with options
# options = Hash of options, optional
#
def initialize(binary, options = {})
- @options = self.respond_to?(:defualt_options) ? default_options.merge(options) : options
+ @options = self.respond_to?(:default_options) ? default_options.merge(options) : options
@opt_set = false
@command = nil
@binary = binary
@path = []
end
@@ -29,11 +28,10 @@
end
# Run command
#
def execute(params = nil)
- #puts "#{self.command} #{params}"
cmd = IO.popen("#{self.command} #{params}", "r")
results = cmd.gets(nil)
cmd.close
results
end
@@ -129,10 +127,10 @@
# the specified paths - ie the first path where the pattern matches
# something.
#
def locate(bin_glob, env = nil)
path << ENV[env] if env && ENV.key?(env) && File.exist?(ENV[env])
-
+
(path << Dir.pwd).each do |path|
files = Dir.glob(File.expand_path(File.join(path, bin_glob)))
return files unless files.empty?
end