diff options
author | Adam Edwards <adamed@opscode.com> | 2014-05-03 00:25:54 -0700 |
---|---|---|
committer | sersut <serdar@opscode.com> | 2014-05-30 13:05:47 -0700 |
commit | e0c2469f3af617c34f13a32cc8b0490204be7979 (patch) | |
tree | 1bf4615abd4e3f64aa73e7c117b81dbad4b61ce5 | |
parent | 771662f8edc7f8251379f3207399bbdffa2248cc (diff) | |
download | chef-e0c2469f3af617c34f13a32cc8b0490204be7979.tar.gz |
Use invoke instead of send, fix first_of, remove ruby-wmi-rdp from gemspec
-rw-r--r-- | chef-x86-mingw32.gemspec | 1 | ||||
-rw-r--r-- | lib/chef/win32/wmi.rb | 12 |
2 files changed, 9 insertions, 4 deletions
diff --git a/chef-x86-mingw32.gemspec b/chef-x86-mingw32.gemspec index 49a15bcf00..819c7eddbb 100644 --- a/chef-x86-mingw32.gemspec +++ b/chef-x86-mingw32.gemspec @@ -4,7 +4,6 @@ gemspec = eval(IO.read(File.expand_path("../chef.gemspec", __FILE__))) gemspec.platform = "x86-mingw32" gemspec.add_dependency "ffi", "1.5.0" -gemspec.add_dependency "rdp-ruby-wmi", "0.3.1" gemspec.add_dependency "windows-api", "0.4.2" gemspec.add_dependency "windows-pr", "1.2.2" gemspec.add_dependency "win32-api", "1.5.1" diff --git a/lib/chef/win32/wmi.rb b/lib/chef/win32/wmi.rb index c3d6cf7d3b..9ed02c6aea 100644 --- a/lib/chef/win32/wmi.rb +++ b/lib/chef/win32/wmi.rb @@ -16,6 +16,7 @@ # limitations under the License. # +require 'win32ole' require 'chef/reserved_names' class Chef @@ -45,7 +46,12 @@ class Chef def first_of(wmi_class) query_result = start_query("select * from #{wmi_class}") - wmi_result_to_snapshot(query_result.first) + first_result = nil + query_result.each do | record | + first_result = record + break + end + first_result.nil? ? nil : wmi_result_to_snapshot(first_result) end private @@ -55,14 +61,14 @@ class Chef end def new_connection(namespace) - locator = WIN32OLE.new("WbemScripting.SWbemLocator") + locator = ::WIN32OLE.new("WbemScripting.SWbemLocator") locator.ConnectServer('.', namespace) end def wmi_result_to_hash(wmi_object) property_map = {} wmi_object.properties_.each do |property| - property_map[property.name.downcase] = wmi_object.send(property.name) + property_map[property.name.downcase] = wmi_object.invoke(property.name) end property_map[:wmi_object] = wmi_object |