Sha256: bf3e45e79a9e966f13955f79a1d5f07a3079353d2c9e10fa61ebda94b7f9676f
Contents?: true
Size: 1.03 KB
Versions: 41
Compression:
Stored size: 1.03 KB
Contents
require 'cucumber/formatter/color_io' module Cucumber module Formatter module Io def ensure_io(path_or_io, name) return nil if path_or_io.nil? return path_or_io if ColorIO === path_or_io || path_or_io.respond_to?(:write) file = File.open(path_or_io, Cucumber.file_mode('w')) at_exit do unless file.closed? file.flush file.close end end file end def ensure_file(path, name) raise "You *must* specify --out FILE for the #{name} formatter" unless String === path raise "I can't write #{name} to a directory - it has to be a file" if File.directory?(path) ensure_io(path, name) end def ensure_dir(path, name) raise "You *must* specify --out DIR for the #{name} formatter" unless String === path raise "I can't write #{name} reports to a file - it has to be a directory" if File.file?(path) FileUtils.mkdir_p(path) unless File.directory?(path) path end end end end
Version data entries
41 entries across 41 versions & 4 rubygems