Class: Chef::Util::Powershell::CmdletResult

Inherits:
Object
  • Object
show all
Defined in:
lib/chef/util/powershell/cmdlet_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, streams, output_format) ⇒ CmdletResult

Returns a new instance of CmdletResult.



27
28
29
30
31
# File 'lib/chef/util/powershell/cmdlet_result.rb', line 27

def initialize(status, streams, output_format)
  @status = status
  @output_format = output_format
  @streams = streams
end

Instance Attribute Details

#output_formatObject (readonly)

Returns the value of attribute output_format.



25
26
27
# File 'lib/chef/util/powershell/cmdlet_result.rb', line 25

def output_format
  @output_format
end

Instance Method Details

#return_valueObject



45
46
47
48
49
50
51
52
53
# File 'lib/chef/util/powershell/cmdlet_result.rb', line 45

def return_value
  if output_format == :object
    Chef::JSONCompat.parse(stream(:json))
  elsif output_format == :json
    stream(:json)
  else
    @status.stdout
  end
end

#stderrObject



37
38
39
# File 'lib/chef/util/powershell/cmdlet_result.rb', line 37

def stderr
  @status.stderr
end

#stdoutObject



33
34
35
# File 'lib/chef/util/powershell/cmdlet_result.rb', line 33

def stdout
  @status.stdout
end

#stream(name) ⇒ Object



41
42
43
# File 'lib/chef/util/powershell/cmdlet_result.rb', line 41

def stream(name)
  @streams[name].read
end

#succeeded?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/chef/util/powershell/cmdlet_result.rb', line 55

def succeeded?
  @succeeded = @status.status.exitstatus == 0
end