Class: Train::Extras::WindowsFile

Inherits:
FileCommon show all
Defined in:
lib/train/extras/file_windows.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.



14
15
16
17
18
# File 'lib/train/extras/file_windows.rb', line 14

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

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



13
14
15
# File 'lib/train/extras/file_windows.rb', line 13

def path
  @path
end

Instance Method Details

#basename(suffix = nil, sep = '\\') ⇒ Object



20
21
22
# File 'lib/train/extras/file_windows.rb', line 20

def basename(suffix = nil, sep = '\\')
  super(suffix, sep)
end

#contentObject



24
25
26
27
28
29
30
31
# File 'lib/train/extras/file_windows.rb', line 24

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)


33
34
35
36
37
# File 'lib/train/extras/file_windows.rb', line 33

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

#file_versionObject



67
68
69
# File 'lib/train/extras/file_windows.rb', line 67

def file_version
  nil
end


43
44
45
# File 'lib/train/extras/file_windows.rb', line 43

def link_path
  nil
end


39
40
41
# File 'lib/train/extras/file_windows.rb', line 39

def link_target
  nil
end

#mountedObject



47
48
49
# File 'lib/train/extras/file_windows.rb', line 47

def mounted
  nil
end

#product_versionObject



63
64
65
# File 'lib/train/extras/file_windows.rb', line 63

def product_version
  nil
end

#statObject



71
72
73
# File 'lib/train/extras/file_windows.rb', line 71

def stat
  nil
end

#typeObject



51
52
53
# File 'lib/train/extras/file_windows.rb', line 51

def type
  :unknown
end