lib/linux_admin/common.rb in linux_admin-0.1.0 vs lib/linux_admin/common.rb in linux_admin-0.1.1

- old
+ new

@@ -7,10 +7,14 @@ File.open(file, "w") do |f| f.write(content) end end + def cmd(cmd) + Distro.local.class::COMMANDS[cmd] + end + def run(cmd, options = {}) params = options[:params] || options[:parameters] begin out = launch(build_cmd(cmd, params)) @@ -31,18 +35,18 @@ end private def sanitize(params) - return {} if params.blank? - params.each_with_object({}) do |(k, v), h| - h[k] = - case v - when Array; v.collect {|s| s.shellescape} - when NilClass; v - else v.shellescape - end + return [] if params.blank? + params.collect do |k, v| + v = case v + when Array; v.collect(&:shellescape) + when NilClass; v + else v.to_s.shellescape + end + [k, v] end end def assemble_params(sanitized_params) sanitized_params.collect do |pair| @@ -89,6 +93,6 @@ def exitstatus=(value) Thread.current[THREAD_SYNC_KEY] = value end end -end \ No newline at end of file +end