Sha256: 6bf9c5be6fc72b74cf08deb38c289f55da6ae194f2538fdb849b046104edc39e
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
# frozen_string_literal: true module Cucumber module Formatter module Io module_function def ensure_io(path_or_io) return nil if path_or_io.nil? return path_or_io if 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) raise "I can't write #{name} to a file in the non-existing directory #{File.dirname(path)}" if !File.directory?(File.dirname(path)) ensure_io(path) 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) File.absolute_path path end end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
honeybadger-4.5.3 | vendor/bundle/ruby/2.6.0/gems/cucumber-3.1.2/lib/cucumber/formatter/io.rb |
cucumber-3.1.2 | lib/cucumber/formatter/io.rb |
cucumber-3.1.1 | lib/cucumber/formatter/io.rb |