summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Edwards <adamed@opscode.com>2014-05-03 00:25:54 -0700
committersersut <serdar@opscode.com>2014-05-30 13:05:48 -0700
commit9a35a9b5804561033b712fddc65b5f9c4b0d5edc (patch)
treee5f3dc69de2f2e68f29666236002bdfc19a6b486
parent17a7d93df559f24d687341331b2329a134b0b619 (diff)
downloadchef-9a35a9b5804561033b712fddc65b5f9c4b0d5edc.tar.gz
Use invoke instead of send, fix first_of, remove ruby-wmi-rdp from gemspec
-rw-r--r--lib/chef/win32/wmi.rb12
1 files changed, 9 insertions, 3 deletions
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