lib/linux_admin/common.rb in linux_admin-0.2.1 vs lib/linux_admin/common.rb in linux_admin-0.2.2
- old
+ new
@@ -22,11 +22,14 @@
ensure
output ||= ""
error ||= ""
self.exitstatus = nil
end
-
+ rescue Errno::ENOENT => err
+ raise NoSuchFileError.new(err.message) if NoSuchFileError.detected?(err.message)
+ raise
+ else
CommandResult.new(output, error, status)
end
def run!(cmd, options = {})
params = options[:params] || options[:parameters]
@@ -54,16 +57,16 @@
end
end
def assemble_params(sanitized_params)
sanitized_params.collect do |pair|
- pair_joiner = pair.first.try(:end_with?, "=") ? "" : " "
+ pair_joiner = pair.first.to_s.end_with?("=") ? "" : " "
pair.flatten.compact.join(pair_joiner)
end.join(" ")
end
def build_cmd(cmd, params = nil)
- return cmd if params.blank?
+ return cmd.to_s if params.blank?
"#{cmd} #{assemble_params(sanitize(params))}"
end
# IO pipes have a maximum size of 64k before blocking,
# so we need to read and write synchronously.