Class: Commands

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Commands

Returns a new instance of Commands.



11
12
13
14
15
16
17
18
# File 'lib/commands.rb', line 11

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

Instance Attribute Details

#build ⇒ Object

Returns the value of attribute build.



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

def build
  @build
end

Instance Method Details

#execute_command(command) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/commands.rb', line 20

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

#show ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/commands.rb', line 36

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