Sha256: 62273dc477cda09df5c9ed565a80fa49d5888fd685f3ba71f0a08a946baac1b5

Contents?: true

Size: 675 Bytes

Versions: 3

Compression:

Stored size: 675 Bytes

Contents

require 'fileutils'

class FileHelper

  def initialize
    @temp_folders = []
  end

  def create_temp_folder
    folder_name = "#{ENV['TMP'].gsub('\\', '/')}/#{timestamp}"
    @temp_folders << folder_name
    Dir.mkdir folder_name
    folder_name
  end

  def remove_temp_folders
    @temp_folders.each do |folder_name|
      FileUtils.rm_rf folder_name
    end
  end

  def create_temp_file(folder, content)
    file_name = "#{folder}/file #{timestamp}.txt"
    sleep(0.01)
    File.open(file_name, 'w') do |file|
      file.puts content
    end
    file_name
  end

  private

  def timestamp
    (Time.now.to_f * 1000).to_i
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
git_wrapper-1.0.2 spec/support/helpers/file_helper.rb
git_wrapper-1.0.1 spec/support/helpers/file_helper.rb
git_wrapper-1.0.0 spec/support/helpers/file_helper.rb