Class: Chef::Util::Powershell::Cmdlet::CmdletStream

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ CmdletStream

Returns a new instance of CmdletStream.



146
147
148
149
# File 'lib/chef/util/powershell/cmdlet.rb', line 146

def initialize(name)
  @filename = Dir::Tmpname.create(name) {}
  ObjectSpace.define_finalizer(self, self.class.destroy(@filename))
end

Class Method Details

.destroy(name) ⇒ Object



163
164
165
# File 'lib/chef/util/powershell/cmdlet.rb', line 163

def self.destroy(name)
  proc { File.delete(name) if File.exists? name }
end

Instance Method Details

#pathObject



151
152
153
# File 'lib/chef/util/powershell/cmdlet.rb', line 151

def path
  @filename
end

#readObject



155
156
157
158
159
160
161
# File 'lib/chef/util/powershell/cmdlet.rb', line 155

def read
  if File.exist? @filename
    File.open(@filename, "rb:bom|UTF-16LE") do |f|
      f.read.encode("UTF-8")
    end
  end
end