Module: Chef::Knife::API
- Included in:
- Rake::API
- Defined in:
- lib/knife/api.rb,
lib/knife/api/version.rb
Overview
adding API module to existing Chef::Knife packaging
Defined Under Namespace
Modules: Support
Constant Summary collapse
- VERSION =
'0.1.6'
Instance Method Summary collapse
Instance Method Details
#knife(command, args = []) ⇒ Object
30 31 32 |
# File 'lib/knife/api.rb', line 30 def knife(command, args = []) Chef::Knife::API::Support.run_knife(command, args) end |
#knife_capture(command, args = [], input = nil) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/knife/api.rb', line 34 def knife_capture(command, args = [], input = nil) null = Gem.win_platform? ? File.open('NUL:', 'r') : File.open('/dev/null', 'r') warn = $VERBOSE $VERBOSE = nil stderr, stdout, stdin = STDERR, STDOUT, 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 status = Chef::Knife::API::Support.run_knife(command, args) return STDOUT.string, STDERR.string, status ensure warn = $VERBOSE $VERBOSE = nil Object.const_set('STDERR', stderr) Object.const_set('STDOUT', stdout) Object.const_set('STDIN', stdin) $VERBOSE = warn null.close end |