Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
def run rd, wr = IO.pipe rd.fcntl(Fcntl::F_SETFD, 1) ENV['TM_ERROR_FD'] = wr.to_i.to_s args = add_test_path( *[ ruby, '-rcatch_exception', '-rstdin_dialog', Array(@args), @path, ARGV.to_a ].flatten ) stdin, stdout, stderr = Open3.popen3(*args) Thread.new { stdin.write @content; stdin.close } unless ENV.has_key? 'TM_FILEPATH' wr.close [ stdout, stderr, rd ] end attr_reader :display_name, :path private def add_test_path(*args) if test_script? path_ary = @path.split("/") if index = path_ary.rindex("test") test_path = File.join(*path_ary[0..-2]) lib_path = File.join( *( path_ary[0..-2] + [".."] * (path_ary.length - index - 1) ) + ["lib"] ) if File.exist? lib_path args.insert(1, "-I#{lib_path}:#{test_path}") end end end args end
This paste will be private.
From the Design Piracy series on my blog: