Thanks for the feedback Luke and Daniel. :) I submitted a new patch with the suggested changes.
+  # Included spaces to ensure its uniqueness
+  @releases = [" XP ", " Vista ", " 7 ", " 2003 ", " 2008 ", " 2008 R2 ", " 8 
"]
+
+  @releases.each do |r|
+    if Facter::Util::MSWindows.getWindowsRelease.include?(r)
+      setcode do
+        osrelease = r.gsub(/\s/, "")
+      end
I don't like this very much.  I think we should export the unadorned
WMI/CIM value, without interpretation.  Otherwise we are going to have
very strange behaviours *and* a headache: either we don't export an
unknown value, or we force ourselves to have an ABI change when we
*do* add it to the list.  Neither of those is very nice.
I could trying using regex to capture the value. It just gets a bit complicated because they were inconsistent with there latest server edition. Specifically, the decision to tag on a "R2" makes it more complicated.

    Microsoft Windows Server 2008 R2 Enterprise
    Microsoft Windows Server 2008 Enterprise
    Microsoft Windows 7 Professional
    Microsoft Windows XP Professional
+  def self.getWindowsRelease
+    caption = ""
+    self.Win32_OperatingSystem.each { |x| caption = x["Caption"] }
+    caption
+  end
That seems ... odd.  It isn't clear why you don't rewrite it as:

   Win32_OperatingSystem.last["Caption"]

...since that seems to be the effect of the code.  Is there some
detail I am missing?  If so, a comment explaining it would probably be
a good idea. :)

Unfortunately, WMI returns a IEnumVariant object rather than an array.
+  def self.Win32_OperatingSystem
+    require 'win32ole'
+    wmi = WIN32OLE.connect("winmgmts://")
+    query = wmi.ExecQuery("select * from Win32_OperatingSystem")
+    query
Ruby, and our, style is that we don't have an explicit return; in this
case, assigning to a variable and using it on the next line is extra
strange.  So, best drop 'query' entirely.  (Also, that isn't a query,
it is a result.  ;)
Fixed

Regards,
William

--
You received this message because you are subscribed to the Google Groups "Puppet 
Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to