Sha256: 16530dccb80f2e5840cab19edc74ebdb86a72818991450c97661c606ba3cf324
Contents?: true
Size: 657 Bytes
Versions: 18
Compression:
Stored size: 657 Bytes
Contents
require "tmpdir" require "fileutils" # This class encapsulates the pattern of creating a temporary configuration file # from a String, easiliy referencing the directory to initialise a BBConfig and # dispose of # class TmpConfig attr_reader :path # Creates a temporary directory and a "config" file within using the contents # of a passed String. # # Recommended to use {#close} to delete # # @param [String] contents # def initialize(contents) @path = Dir.mktmpdir @file = File.open(File.join(@path, "config"), "w+") @file.write(contents) @file.close end def close FileUtils.remove_entry_secure(path) end end
Version data entries
18 entries across 18 versions & 1 rubygems