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

Version Path
brightbox-cli-5.0.0 spec/support/tmp_config.rb
brightbox-cli-5.0.0.rc2 spec/support/tmp_config.rb
brightbox-cli-5.0.0.rc1 spec/support/tmp_config.rb
brightbox-cli-5.0.0.alpha spec/support/tmp_config.rb
brightbox-cli-4.8.0 spec/support/tmp_config.rb
brightbox-cli-4.7.0 spec/support/tmp_config.rb
brightbox-cli-4.6.0 spec/support/tmp_config.rb
brightbox-cli-4.5.0 spec/support/tmp_config.rb
brightbox-cli-4.5.0.rc1 spec/support/tmp_config.rb
brightbox-cli-4.4.0 spec/support/tmp_config.rb
brightbox-cli-4.3.2 spec/support/tmp_config.rb
brightbox-cli-4.3.1 spec/support/tmp_config.rb
brightbox-cli-4.3.0 spec/support/tmp_config.rb
brightbox-cli-4.2.1 spec/support/tmp_config.rb
brightbox-cli-4.2.0 spec/support/tmp_config.rb
brightbox-cli-4.1.0 spec/support/tmp_config.rb
brightbox-cli-4.0.0 spec/support/tmp_config.rb
brightbox-cli-4.0.0.rc2 spec/support/tmp_config.rb