Class: Commands

Inherits:
Hash
  • Object
show all
Defined in:
lib/commands.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCommands

Returns a new instance of Commands.



9
10
11
12
13
14
# File 'lib/commands.rb', line 9

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

Instance Attribute Details

#buildObject

Returns the value of attribute build.



7
8
9
# File 'lib/commands.rb', line 7

def build
  @build
end

Instance Method Details

#execute_command(command) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/commands.rb', line 16

def execute_command command
  puts Color.yellow + command + Color.clear
  puts " "

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

#showObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/commands.rb', line 32

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