Sha256: 20faed1c580df39da47e70b53b7ffe5fbb5177186419155dc110e7d14beff75e

Contents?: true

Size: 823 Bytes

Versions: 22

Compression:

Stored size: 823 Bytes

Contents

module PSWindows::File
  include Beaker::CommandFactory

  def tmpfile(name = '')
    result = exec(powershell('[System.IO.Path]::GetTempFileName()'))
    result.stdout.chomp()
  end

  def tmpdir(name = '')
    tmp_path = exec(powershell('[System.IO.Path]::GetTempPath()')).stdout.chomp()

    if name == ''
      name = exec(powershell('[System.IO.Path]::GetRandomFileName()')).stdout.chomp()
    end
    exec(powershell("New-Item -Path '#{tmp_path}' -Force -Name '#{name}' -ItemType 'directory'"))
    File.join(tmp_path, name)
  end

  def path_split(paths)
    paths.split(';')
  end

  def cat(path)
    exec(powershell("type #{path}")).stdout
  end

  def file_exist?(path)
    result = exec(Beaker::Command.new("if exist #{path} echo true"), accept_all_exit_codes: true)
    result.stdout.strip == 'true'
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
beaker-4.38.1 lib/beaker/host/pswindows/file.rb
beaker-4.38.0 lib/beaker/host/pswindows/file.rb
beaker-4.37.2 lib/beaker/host/pswindows/file.rb
beaker-4.37.1 lib/beaker/host/pswindows/file.rb
beaker-4.37.0 lib/beaker/host/pswindows/file.rb
beaker-4.36.1 lib/beaker/host/pswindows/file.rb
beaker-4.36.0 lib/beaker/host/pswindows/file.rb
beaker-4.35.0 lib/beaker/host/pswindows/file.rb
beaker-4.34.0 lib/beaker/host/pswindows/file.rb
beaker-4.33.0 lib/beaker/host/pswindows/file.rb
beaker-4.32.0 lib/beaker/host/pswindows/file.rb
beaker-4.31.0 lib/beaker/host/pswindows/file.rb
beaker-4.30.0 lib/beaker/host/pswindows/file.rb
beaker-4.29.1 lib/beaker/host/pswindows/file.rb
beaker-4.29.0 lib/beaker/host/pswindows/file.rb
beaker-4.28.1 lib/beaker/host/pswindows/file.rb
beaker-4.28.0 lib/beaker/host/pswindows/file.rb
beaker-4.27.1 lib/beaker/host/pswindows/file.rb
beaker-4.27.0 lib/beaker/host/pswindows/file.rb
beaker-4.26.0 lib/beaker/host/pswindows/file.rb