Skip to content

Instantly share code, notes, and snippets.

@groob
Created October 21, 2013 15:03
Show Gist options
  • Save groob/7085380 to your computer and use it in GitHub Desktop.
Save groob/7085380 to your computer and use it in GitHub Desktop.
require 'cfpropertylist'
module Puppet::Parser::Functions
newfunction(:has_app, :type => :rvalue) do |args|
if (args.is_a? String)
args = [args]
end
appname = args[0]
plist = CFPropertyList::List.new(:file => "/Library/Managed Installs/ApplicationInventory.plist")
data = CFPropertyList.native_types(plist.value)
list_of_applications = Hash.new
data.each do |app|
if app['name'] =~ /#{appname}/i
list_of_applications[app['name']] = app
has_app = list_of_applications[appname]["CFBundleName"]
return has_app
else
false
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment