Class: Train::Extras::WindowsFile

Inherits:
FileCommon show all
Defined in:
lib/train/extras/windows_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from FileCommon

#block_device?, #character_device?, #directory?, #file?, #grouped_into?, #linked_to?, #md5sum, #mode?, #mounted?, #owned_by?, #pipe?, #sha256sum, #socket?, #symlink?, #unix_mode_mask, #version?

Constructor Details

#initialize(backend, path) ⇒ WindowsFile

Returns a new instance of WindowsFile.



13
14
15
16
17
# File 'lib/train/extras/windows_file.rb', line 13

def initialize(backend, path)
  @backend = backend
  @path = path
  @spath = Shellwords.escape(@path)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



12
13
14
# File 'lib/train/extras/windows_file.rb', line 12

def path
  @path
end

Instance Method Details

#contentObject



19
20
21
22
23
24
25
26
# File 'lib/train/extras/windows_file.rb', line 19

def content
  return @content if defined?(@content)
  @content = @backend.run_command(
    "Get-Content(\"#{@spath}\") | Out-String").stdout
  return @content unless @content.empty?
  @content = nil if directory? # or size.nil? or size > 0
  @content
end

#exist?Boolean

Returns:

  • (Boolean)


28
29
30
31
32
# File 'lib/train/extras/windows_file.rb', line 28

def exist?
  return @exist if defined?(@exist)
  @exist = @backend.run_command(
    "(Test-Path -Path \"#{@spath}\").ToString()").stdout.chomp == 'True'
end

#file_versionObject



62
63
64
# File 'lib/train/extras/windows_file.rb', line 62

def file_version
  nil
end


38
39
40
# File 'lib/train/extras/windows_file.rb', line 38

def link_path
  nil
end


34
35
36
# File 'lib/train/extras/windows_file.rb', line 34

def link_target
  nil
end

#mountedObject



42
43
44
# File 'lib/train/extras/windows_file.rb', line 42

def mounted
  nil
end

#product_versionObject



58
59
60
# File 'lib/train/extras/windows_file.rb', line 58

def product_version
  nil
end

#statObject



66
67
68
# File 'lib/train/extras/windows_file.rb', line 66

def stat
  nil
end

#typeObject



46
47
48
# File 'lib/train/extras/windows_file.rb', line 46

def type
  :unknown
end