Sha256: 59d9dc64dead0a95638d926f2fa60f1506d88cabbc0dd7af54a00ade7a609ba1
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
class Command < Hash def initialize command self[:input] = command self[:timeout] = 0 self[:directory] = '' self[:exit_code] = 0 self[:output] = '' self[:error] = '' self[:machine_name] = '' self[:user_name] = '' self[:start_time] = nil self[:end_time] = nil end def execute Logger.start_command self pwd=Dir.pwd Dir.chdir(self[:directory]) if(self.has_key?(:directory) && File.exists?(self[:directory])) #print " " + Color.green + self[:input] + Color.clear self[:start_time]=Time.now timer=Timer.new if self[:input].include?('<%') && self[:input].include?('%>') ruby = self[:input].gsub("<%","").gsub("%>","") self[:output]=eval(ruby) #puts " " + timer.elapsed_str self[:elapsed] = timer.elapsed_str self[:end_time] = Time.now else self[:output] = `#{self[:input]}` self[:elapsed] = timer.elapsed_str self[:end_time] = Time.now self[:exit_code]=$? #if $? != 0 # puts self[:output] # raise Color.yellow + "`" + Color.green + self[:input] + Color.yellow + "`" + Color.clear + # " has exit code " + $?.to_s + " " + out #else # puts " " + timer.elapsed_str #end end Dir.chdir(pwd) if pwd != Dir.pwd Logger.end_command self end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dev_tasks-1.0.9 | lib/command.rb |
dev_tasks-1.0.8 | lib/command.rb |