Sha256: ed3a59bc14ff679c1fbc001e2637a1f6c273582d57bfc1073fdba72076d428bc

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 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'

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
    puts " " + Color.green + command + Color.clear

	if command.include?('<%') && command.include?('%>')
	  ruby = command.gsub("<%","").gsub("%>","")
      eval(ruby)
    else
		out = `#{command}`
		if $? != 0
		  puts out
		  raise Color.bright_yellow + "`" + Color.green + command + Color.bright_yellow + "`" + Color.clear + 
			  " has exit code " + $?.to_s
		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

2 entries across 2 versions & 1 rubygems

Version Path
dev_tasks-0.0.37 lib/commands.rb
dev_tasks-0.0.36 lib/commands.rb