class Chef::Provider::WindowsScript

Public Class Methods

new( new_resource, run_context, script_extension='') click to toggle source
Calls superclass method Chef::Provider::Script.new
# File lib/chef/provider/windows_script.rb, line 30
def initialize( new_resource, run_context, script_extension='')
  super( new_resource, run_context )
  @script_extension = script_extension

  target_architecture = new_resource.architecture.nil? ?
    node_windows_architecture(run_context.node) : new_resource.architecture

  @is_wow64 = wow64_architecture_override_required?(run_context.node, target_architecture)

  # if the user wants to run the script 32 bit && we are on a 64bit windows system && we are running a 64bit ruby ==> fail
  if ( target_architecture == :i386 ) && node_windows_architecture(run_context.node) == :x86_64 && !is_i386_process_on_x86_64_windows?
    raise Chef::Exceptions::Win32ArchitectureIncorrect,
    "Support for the i386 architecture from a 64-bit Ruby runtime is not yet implemented"
  end
end

Public Instance Methods

action_run() click to toggle source
Calls superclass method Chef::Provider::Script#action_run
# File lib/chef/provider/windows_script.rb, line 48
def action_run
  wow64_redirection_state = nil

  if @is_wow64
    wow64_redirection_state = disable_wow64_file_redirection(@run_context.node)
  end

  begin
    super
  rescue
    raise
  ensure
    if ! wow64_redirection_state.nil?
      restore_wow64_file_redirection(@run_context.node, wow64_redirection_state)
    end
  end
end
script_file() click to toggle source
# File lib/chef/provider/windows_script.rb, line 66
def script_file
  base_script_name = "chef-script"
  temp_file_arguments = [ base_script_name, @script_extension ]

  @script_file ||= Tempfile.open(temp_file_arguments)
end