Sha256: fd72d187eec2470d548bd7242dafac84a80f6a961f4d5f342dcd02e5bfeae7ea

Contents?: true

Size: 796 Bytes

Versions: 115

Compression:

Stored size: 796 Bytes

Contents

require 'parallel_tests'

module ParallelTests
  module Gherkin
    module Io

      def prepare_io(path_or_io)
        if path_or_io.respond_to?(:write)
          path_or_io
        else # its a path
          File.open(path_or_io, 'w').close # clean out the file
          file = File.open(path_or_io, 'a')

          at_exit do
            unless file.closed?
              file.flush
              file.close
            end
          end

          file
        end
      end

      # do not let multiple processes get in each others way
      def lock_output
        if File === @io
          begin
            @io.flock File::LOCK_EX
            yield
          ensure
            @io.flock File::LOCK_UN
          end
        else
          yield
        end
      end

    end
  end
end

Version data entries

115 entries across 115 versions & 2 rubygems

Version Path
parallel_tests-3.4.0 lib/parallel_tests/gherkin/io.rb
parallel_tests-3.3.0 lib/parallel_tests/gherkin/io.rb
parallel_tests-3.2.0 lib/parallel_tests/gherkin/io.rb
parallel_tests-3.1.0 lib/parallel_tests/gherkin/io.rb
parallel_tests-3.0.0 lib/parallel_tests/gherkin/io.rb
parallel_tests-2.32.0 lib/parallel_tests/gherkin/io.rb
parallel_tests-2.31.0 lib/parallel_tests/gherkin/io.rb
parallel_tests-2.30.1 lib/parallel_tests/gherkin/io.rb
parallel_tests-2.30.0 lib/parallel_tests/gherkin/io.rb
parallel_tests-2.29.2 lib/parallel_tests/gherkin/io.rb
parallel_tests-2.29.1 lib/parallel_tests/gherkin/io.rb
parallel_tests-2.29.0 lib/parallel_tests/gherkin/io.rb
parallel_tests-2.28.0 lib/parallel_tests/gherkin/io.rb
parallel_tests-2.27.1 lib/parallel_tests/gherkin/io.rb
parallel_tests-2.27.0 lib/parallel_tests/gherkin/io.rb
parallel_tests-2.26.2 lib/parallel_tests/gherkin/io.rb
parallel_tests-2.26.0 lib/parallel_tests/gherkin/io.rb
parallel_tests-2.25.0 lib/parallel_tests/gherkin/io.rb
parallel_tests-2.24.0 lib/parallel_tests/gherkin/io.rb
parallel_tests-2.23.0 lib/parallel_tests/gherkin/io.rb