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
#initialize ⇒ Commands
Returns a new instance of Commands.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/commands.rb', line 15 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[:publish] = Publish.new self[:push] = Push.new end |
Instance Attribute Details
#build ⇒ Object
Returns the value of attribute build.
13 14 15 |
# File 'lib/commands.rb', line 13 def build @build end |
Instance Method Details
#execute_command(command) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/commands.rb', line 31 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 |
#show ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/commands.rb', line 51 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
27 28 29 |
# File 'lib/commands.rb', line 27 def update self[:upgrade].update end |