Sha256: b1c805ad3507bc20819fdef139ddf3d87f5fe2d476a5df3a672fc87f3b0f63e9

Contents?: true

Size: 1.53 KB

Versions: 14

Compression:

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

14 entries across 14 versions & 1 rubygems

Version Path
dev_tasks-0.0.155 lib/commands.rb
dev_tasks-0.0.154 lib/commands.rb
dev_tasks-0.0.153 lib/commands.rb
dev_tasks-0.0.152 lib/commands.rb
dev_tasks-0.0.151 lib/commands.rb
dev_tasks-0.0.150 lib/commands.rb
dev_tasks-0.0.149 lib/commands.rb
dev_tasks-0.0.148 lib/commands.rb
dev_tasks-0.0.147 lib/commands.rb
dev_tasks-0.0.146 lib/commands.rb
dev_tasks-0.0.145 lib/commands.rb
dev_tasks-0.0.144 lib/commands.rb
dev_tasks-0.0.143 lib/commands.rb
dev_tasks-0.0.142 lib/commands.rb