Class: Chef

Inherits:
Object
  • Object
show all
Defined in:
lib/knife/api.rb,
lib/knife/api/version.rb

Overview

Chef::Knife classes are opened to expose the Knife entry points to code via the injected API module

Defined Under Namespace

Classes: Knife

Instance Method Summary collapse

Instance Method Details

#assign_io_channelsObject



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/knife/api.rb', line 54

def assign_io_channels
  @warn = $VERBOSE
  $VERBOSE = nil
  @stderr = STDERR
  @stdout = STDOUT
  @stdin = STDIN

  Object.const_set('STDERR', StringIO.new('', 'r+'))
  Object.const_set('STDOUT', StringIO.new('', 'r+'))
  Object.const_set('STDIN', @input ? StringIO.new(@input, 'r') : null)
  $VERBOSE = @warn
end

#revert_io_channelsObject



67
68
69
70
71
72
73
74
75
# File 'lib/knife/api.rb', line 67

def revert_io_channels
  @warn = $VERBOSE
  $VERBOSE = nil
  Object.const_set('STDERR', @stderr)
  Object.const_set('STDOUT', @stdout)
  Object.const_set('STDIN', @stdin)
  $VERBOSE = @warn
  null.close
end

#set_nullObject



46
47
48
49
50
51
52
# File 'lib/knife/api.rb', line 46

def set_null
  if Gem.win_platform? == null
    File.open('NUL:', 'r')
  else
    File.open('/dev/null', 'r')
  end
end