Module: Shr::Builtin
- Included in:
- Shell
- Defined in:
- lib/shr/builtin.rb
Instance Method Summary collapse
Instance Method Details
#capture(&block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/shr/builtin.rb', line 7 def capture(&block) proc = Proc.new do |environment| output = relay capture_stdout(&block) if environment.key? :out File.write(environment[:out], output.read) end [output, nil] end @commands << [:capture, proc] self end |
#cd!(path = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/shr/builtin.rb', line 19 def cd!(path=nil) proc = Proc.new do path ? Dir.chdir(path) : Dir.chdir [nil, nil] end @commands << ["#cd! #{path}".strip, proc] force self end |