Sha256: d0420ad4b332198a71604da578d4cf7e370bda70defc27788f4c014d63eedafa

Contents?: true

Size: 1.07 KB

Versions: 11

Compression:

Stored size: 1.07 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

		#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

		Logger.end_command self
	end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
dev_tasks-1.0.7 lib/command.rb
dev_tasks-1.0.6 lib/command.rb
dev_tasks-1.0.5 lib/command.rb
dev_tasks-1.0.4 lib/command.rb
dev_tasks-1.0.3 lib/command.rb
dev_tasks-1.0.2 lib/command.rb
dev_tasks-1.0.1 lib/command.rb
dev_tasks-0.0.167 lib/command.rb
dev_tasks-1.0.0 lib/command.rb
dev_tasks-0.0.166 lib/command.rb
dev_tasks-0.0.164 lib/command.rb