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.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/commands.rb', line 14 def initialize self["pull"] = Pull.new self["upgrade"] = Upgrade.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.
12 13 14 |
# File 'lib/commands.rb', line 12 def build @build end |
Instance Method Details
#execute_command(command) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/commands.rb', line 29 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
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/commands.rb', line 49 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
25 26 27 |
# File 'lib/commands.rb', line 25 def update self["upgrade"].update end |