Module: PSWindows::File
Instance Attribute Summary
Attributes included from Beaker::CommandFactory
Instance Method Summary collapse
- #cat(path) ⇒ Object
- #file_exist?(path) ⇒ Boolean
- #path_split(paths) ⇒ Object
- #tmpdir(name = '') ⇒ Object
- #tmpfile(_name = '') ⇒ Object
Methods included from Beaker::CommandFactory
Instance Method Details
#cat(path) ⇒ Object
21 22 23 |
# File 'lib/beaker/host/pswindows/file.rb', line 21 def cat(path) exec(powershell("type #{path}")).stdout end |
#file_exist?(path) ⇒ Boolean
25 26 27 28 |
# File 'lib/beaker/host/pswindows/file.rb', line 25 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
17 18 19 |
# File 'lib/beaker/host/pswindows/file.rb', line 17 def path_split(paths) paths.split(';') end |
#tmpdir(name = '') ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/beaker/host/pswindows/file.rb', line 9 def tmpdir(name = '') tmp_path = exec(powershell('[System.IO.Path]::GetTempPath()')).stdout.chomp name = exec(powershell('[System.IO.Path]::GetRandomFileName()')).stdout.chomp if name == '' 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 |