Module: ChefPowerShell::PowerShell::PowerMod
- Extended by:
- FFI::Library
- Defined in:
- lib/chef-powershell/powershell.rb
Constant Summary collapse
- AllocateCallback =
FFI::Function.new(:pointer, [:size_t]) do |size| # Capture the pointer here so that Ruby knows that it is an # FFI::MemoryPointer that can receive &.free. If you try to # free the pointer from execute_powershell, Ruby will not have # access to the type information and will core dump spectacularly. @@pointer = FFI::MemoryPointer.new(:uchar, size) end
- @@powershell_dll =
FFI requires attaching to modules, not classes, so we need to have a module here. The module level variables could be refactored out here, but still 100% of the work still goes through the module.
Gem.loaded_specs["chef-powershell"].full_gem_path + "/bin/ruby_bin_folder/#{ENV["PROCESSOR_ARCHITECTURE"]}/Chef.PowerShell.Wrapper.dll"
- @@ps_command =
""
- @@ps_timeout =
-1
Class Method Summary collapse
- .do_work ⇒ Object
- .free_pointer ⇒ Object
- .set_ps_command(value) ⇒ Object
- .set_ps_dll(value) ⇒ Object
- .set_ps_timeout(value) ⇒ Object
Class Method Details
.do_work ⇒ Object
100 101 102 103 104 105 |
# File 'lib/chef-powershell/powershell.rb', line 100 def self.do_work ffi_lib @@powershell_dll attach_function :execute_powershell, :ExecuteScript, i{string int pointer}, :pointer execute_powershell(@@ps_command, @@ps_timeout, AllocateCallback) end |
.free_pointer ⇒ Object
83 84 85 86 |
# File 'lib/chef-powershell/powershell.rb', line 83 def self.free_pointer @@pointer&.free @@pointer = nil end |
.set_ps_command(value) ⇒ Object
92 93 94 |
# File 'lib/chef-powershell/powershell.rb', line 92 def self.set_ps_command(value) @@ps_command = value end |
.set_ps_dll(value) ⇒ Object
88 89 90 |
# File 'lib/chef-powershell/powershell.rb', line 88 def self.set_ps_dll(value) @@powershell_dll = value end |
.set_ps_timeout(value) ⇒ Object
96 97 98 |
# File 'lib/chef-powershell/powershell.rb', line 96 def self.set_ps_timeout(value) @@ps_timeout = value end |