Class: Computering::Dsl::Command
- Defined in:
- lib/computering/dsl/command.rb
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(cmd) ⇒ Command
constructor
A new instance of Command.
Methods inherited from Text
Constructor Details
#initialize(cmd) ⇒ Command
Returns a new instance of Command.
5 6 7 8 9 |
# File 'lib/computering/dsl/command.rb', line 5 def initialize(cmd) @text = " #{'⌘'.color(:green)} #{cmd.color(:black).background(:cyan)}" @buffer = "" @cmd = cmd end |
Class Method Details
.from_text(cmd) ⇒ Object
21 22 23 |
# File 'lib/computering/dsl/command.rb', line 21 def self.from_text(cmd) Array(self.new cmd) end |
Instance Method Details
#execute ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/computering/dsl/command.rb', line 11 def execute output = "" Bundler.with_clean_env do output = `#{@cmd}` end @buffer = "\n#{output}\n" rescue puts $! end |