module Bricolage::CommandUtils
Public Instance Methods
command(*args, env: nil)
click to toggle source
# File lib/bricolage/commandutils.rb, line 7 def command(*args, env: nil) logger.info "command: #{args.join(' ')}" sargs = args.map {|a| a.to_s } sargs.unshift env if env system(*sargs) st = $? logger.info "status: #{st.exitstatus || 'nil'} (#{st})" st end
make_tmpfile(content, tmpdir: Dir.tmpdir) { |path| ... }
click to toggle source
# File lib/bricolage/commandutils.rb, line 17 def make_tmpfile(content, tmpdir: Dir.tmpdir) path = new_tmpfile_path(tmpdir) File.open(path, 'w') {|f| f.write content } yield path ensure FileUtils.rm_f path end
new_tmpfile_path(tmpdir = Dir.tmpdir)
click to toggle source
# File lib/bricolage/commandutils.rb, line 27 def new_tmpfile_path(tmpdir = Dir.tmpdir) "#{tmpdir}/#{Time.now.to_i}_#{$$}_#{'%x' % Thread.current.object_id}_#{rand(2**16)}" end