class Chef::Resource::ChocolateySource
Public Instance Methods
choco_cmd(action)
click to toggle source
@param [String] action the name of the action to perform @return [String] the choco source command string
# File lib/chef/resource/chocolatey_source.rb, line 116 def choco_cmd(action) cmd = "#{ENV['ALLUSERSPROFILE']}\\chocolatey\\bin\\choco source #{action} -n \"#{new_resource.source_name}\"" if action == "add" cmd << " -s #{new_resource.source} --priority=#{new_resource.priority}" cmd << " --bypassproxy" if new_resource.bypass_proxy cmd << " --allowselfservice" if new_resource.allow_self_service cmd << " --adminonly" if new_resource.admin_only end cmd end
fetch_source_element(id)
click to toggle source
@param [String] id the source name @return [REXML::Attributes] finds the source element with the
# File lib/chef/resource/chocolatey_source.rb, line 62 def fetch_source_element(id) 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) config_contents = REXML::Document.new(::File.read(config_file)) data = REXML::XPath.first(config_contents, "//sources/source[@id=\"#{id}\"]") data ? data.attributes : nil # REXML just returns nil if it can't find anything so avoid an undefined method error end