Module: Pave::Shell
Class Method Summary collapse
Instance Method Summary collapse
- #file_insert(insert_file, insert_pattern, insert_lines) ⇒ Object
- #sh(cmd) ⇒ Object
- #shell(command) ⇒ Object
Class Method Details
.included(base) ⇒ Object
3 4 5 |
# File 'lib/pave/shell.rb', line 3 def Shell.included base base.extend Shell end |
Instance Method Details
#file_insert(insert_file, insert_pattern, insert_lines) ⇒ Object
18 19 20 21 |
# File 'lib/pave/shell.rb', line 18 def file_insert(insert_file, insert_pattern, insert_lines) file_string = File.read(insert_file).sub(insert_pattern, "#{insert_pattern}\n#{insert_lines}") File.write(insert_file, file_string) end |
#sh(cmd) ⇒ Object
12 13 14 15 16 |
# File 'lib/pave/shell.rb', line 12 def sh(cmd) result = shell(cmd) puts result.output result.status end |
#shell(command) ⇒ Object
7 8 9 10 |
# File 'lib/pave/shell.rb', line 7 def shell(command) output = `#{command}` Struct.new(:status, :output).new($?, output) end |