Sha256: 0884a9c2f52d583ccd5bf5cf8b24f5692d9441b5cfcfcda4f6118cd22aac1b34

Contents?: true

Size: 1.32 KB

Versions: 36

Compression:

Stored size: 1.32 KB

Contents

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

class Commands < Hash
  attr_accessor :build

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

  def update
    self["upgrade"].update
  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

36 entries across 36 versions & 1 rubygems

Version Path
dev_tasks-0.0.75 lib/commands.rb
dev_tasks-0.0.74 lib/commands.rb
dev_tasks-0.0.73 lib/commands.rb
dev_tasks-0.0.72 lib/commands.rb
dev_tasks-0.0.71 lib/commands.rb
dev_tasks-0.0.70 lib/commands.rb
dev_tasks-0.0.69 lib/commands.rb
dev_tasks-0.0.68 lib/commands.rb
dev_tasks-0.0.67 lib/commands.rb
dev_tasks-0.0.66 lib/commands.rb
dev_tasks-0.0.65 lib/commands.rb
dev_tasks-0.0.64 lib/commands.rb
dev_tasks-0.0.63 lib/commands.rb
dev_tasks-0.0.62 lib/commands.rb
dev_tasks-0.0.61 lib/commands.rb
dev_tasks-0.0.60 lib/commands.rb