Class: Commands
- Inherits:
-
Hash
- Object
- Hash
- Commands
- Defined in:
- lib/commands.rb
Instance Attribute Summary collapse
-
#build ⇒ Object
Returns the value of attribute build.
Instance Method Summary collapse
- #execute_command(command) ⇒ Object
-
#initialize ⇒ Commands
constructor
A new instance of Commands.
- #show ⇒ Object
- #update ⇒ Object
Constructor Details
Instance Attribute Details
#build ⇒ Object
Returns the value of attribute build.
10 11 12 |
# File 'lib/commands.rb', line 10 def build @build end |
Instance Method Details
#execute_command(command) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/commands.rb', line 25 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 else puts " " + timer.elapsed_str end end end |
#show ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/commands.rb', line 45 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 |
#update ⇒ Object
21 22 23 |
# File 'lib/commands.rb', line 21 def update self["upgrade"].update end |