Sha256: 4602f68d985d52bacd4dd51a29da17f3a7bb6fe853bfeda44b75403bb27315fd

Contents?: true

Size: 1.59 KB

Versions: 8

Compression:

Stored size: 1.59 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 './setup.rb'
require_relative './upgrade.rb'
require_relative './timer.rb'
require_relative './verify.rb'

class Commands < Hash
  attr_accessor :build

  def initialize
    self[:pull] = Pull.new if(Environment.scm=='git' && Environment.scm_origin.length > 0)
    self[:upgrade] = Upgrade.new
	self[:setup] = Setup.new
    self[:build] = Build.new
	self[:test] = Test.new
	self[:add] = Add.new
	self[:commit] = Commit.new
	self[:push] = Push.new
	self[:verify] = Verify.new
	self[:publish] = Publish.new
  end

  def update
    self[:upgrade].update
	self[:setup].update
	self[:build].update
	self[:verify].update
	self[:publish].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  + " " + out
		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

8 entries across 8 versions & 1 rubygems

Version Path
dev_tasks-0.0.163 lib/commands.rb
dev_tasks-0.0.162 lib/commands.rb
dev_tasks-0.0.161 lib/commands.rb
dev_tasks-0.0.160 lib/commands.rb
dev_tasks-0.0.159 lib/commands.rb
dev_tasks-0.0.158 lib/commands.rb
dev_tasks-0.0.157 lib/commands.rb
dev_tasks-0.0.156 lib/commands.rb