Permalink
Browse files

ensure windows platform specific gems are only loaded on windows

  • Loading branch information...
1 parent 3768394 commit 4725a10b6f89525fc228fa4881a78a54ff9962ad @schisamo schisamo committed Aug 11, 2011
View
7 windows/libraries/registry_helper.rb
@@ -22,10 +22,13 @@
# limitations under the License.
#
+if RUBY_PLATFORM =~ /mswin|mingw32|windows/
+ require 'win32/registry'
+ require 'ruby-wmi'
+end
+
module Windows
module RegistryHelper
- require 'win32/registry'
- require 'ruby-wmi'
@@native_registry_constant = ENV['PROCESSOR_ARCHITEW6432'] == 'AMD64' ? 0x0100 : 0x0200
View
23 windows/libraries/windows_privileged.rb
@@ -20,22 +20,21 @@
# limitations under the License.
#
+if RUBY_PLATFORM =~ /mswin|mingw32|windows/
+ require 'windows/error'
+ require 'windows/registry'
+ require 'windows/process'
+ require 'windows/security'
+end
+
#helpers for Windows API calls that require privilege adjustments
class Chef
class WindowsPrivileged
- #XXX can we tell Chef not to load this library unless on Windows?
- if RUBY_PLATFORM =~ /mswin|mingw32|windows/
- require 'windows/error'
- require 'windows/registry'
- require 'windows/process'
- require 'windows/security'
-
- include Windows::Error
- include Windows::Registry
- include Windows::Process
- include Windows::Security
- end
+ include Windows::Error
+ include Windows::Registry
+ include Windows::Process
+ include Windows::Security
#File -> Load Hive... in regedit.exe
def reg_load_key(name, file)
View
4 windows/providers/package.rb
@@ -18,10 +18,8 @@
# limitations under the License.
#
-begin
+if RUBY_PLATFORM =~ /mswin|mingw32|windows/
require 'win32/registry'
-rescue LoadError
- Chef::Log.warn("Could not load win32/registry")
end
require 'chef/mixin/shell_out'
View
2 windows/providers/zipfile.rb
@@ -20,7 +20,7 @@
# limitations under the License.
#
-include Windows::Helpers
+include Windows::PackageHelper
action :unzip do
ensure_rubyzip_gem_installed

0 comments on commit 4725a10

Please sign in to comment.