class Chef::Resource::ChocolateyFeature
Public Instance Methods
choco_cmd(action)
click to toggle source
@param [String] action the name of the action to perform @return [String] the choco feature command string
# File lib/chef/resource/chocolatey_feature.rb, line 73 def choco_cmd(action) cmd = "#{ENV['ALLUSERSPROFILE']}\\chocolatey\\bin\\choco feature #{action} --name #{new_resource.feature_name}" cmd end
fetch_feature_element(name)
click to toggle source
@param [String] id the feature name @return [String] the element's value field
# File lib/chef/resource/chocolatey_feature.rb, line 40 def fetch_feature_element(name) require "rexml/document" unless defined?(REXML::Document) config_file = "#{ENV['ALLUSERSPROFILE']}\\chocolatey\\config\\chocolatey.config" raise "Could not find the Chocolatey config at #{config_file}!" unless ::File.exist?(config_file) contents = REXML::Document.new(::File.read(config_file)) data = REXML::XPath.first(contents, "//features/feature[@name=\"#{name}\"]") data ? data.attribute("enabled").to_s : nil # REXML just returns nil if it can't find anything so avoid an undefined method error end