Sha256: 5fbc45fb817fbb4b4f2d89d90943fc743629e518c7556825d12d320bd3d41bfb

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

require_relative './build.rb'
require_relative './test.rb'
require_relative './add.rb'
require_relative './commit.rb'
require_relative './publish.rb'
require_relative './upgrade.rb'
require_relative './timer.rb'

class Commands < Hash
  attr_accessor :build

  def initialize
    self["build"] = Build.new
	self["test"] = Test.new
	self["add"] = Add.new
	self["commit"] = Commit.new
	self["publish"] = Publish.new
	self["upgrade"] = Upgrade.new
  end

  def execute_command command
    print " " + Color.green + command + Color.clear

	timer=Timer.new
	if command.include?('<%') && command.include?('%>')
	  ruby = command.gsub("<%","").gsub("%>","")
      eval(ruby)
	  puts " " + timer.elapsed_str
    else
		out = `#{command}`
		if $? != 0
		  puts out
		  raise Color.yellow + "`" + Color.green + command + Color.yellow + "`" + Color.clear + 
			  " has exit code " + $?.to_s
		else
		  puts " " + timer.elapsed_str
		end
	end
  end

  def show
    self.each do |key,array|
	  if(array.length > 0)
	    puts key
	    array.each {|v|
	      puts "  " + Color.green + v + Color.clear + " "
	    }
	  end
	end
	puts " "
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dev_tasks-0.0.44 lib/commands.rb
dev_tasks-0.0.43 lib/commands.rb
dev_tasks-0.0.42 lib/commands.rb