Module: PSWindows::File

Includes:
Beaker::CommandFactory
Included in:
Host
Defined in:
lib/beaker/host/pswindows/file.rb

Instance Attribute Summary

Attributes included from Beaker::CommandFactory

#assertions

Instance Method Summary collapse

Methods included from Beaker::CommandFactory

#execute, #fail_test

Instance Method Details

#cat(path) ⇒ Object



23
24
25
# File 'lib/beaker/host/pswindows/file.rb', line 23

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

#file_exist?(path) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
30
# File 'lib/beaker/host/pswindows/file.rb', line 27

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

#path_split(paths) ⇒ Object



19
20
21
# File 'lib/beaker/host/pswindows/file.rb', line 19

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

#tmpdir(name = '') ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/beaker/host/pswindows/file.rb', line 9

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

#tmpfile(name = '') ⇒ Object



4
5
6
7
# File 'lib/beaker/host/pswindows/file.rb', line 4

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