chef-server-api/app/helpers/cookbook_version_helper.rb
# takes a cookbook_name and an array of versions and returns a hash
# params:
# - cookbook_name: the name of the cookbook
# - versions: a sorted list of version strings
#
# returns:
# {
#   :url => http://url,
#   :versions => [
#     { :version => version, :url => http://url/version },
#     { :version => version, :url => http://url/version }
#   ]  
# }
takes a cookbook_name and an array of versions and returns a hash
params:
cookbook_name: the name of the cookbook
versions: a sorted list of version strings


takes a cookbook_name and an array of versions and returns a hash params : cookbook_name : the name of the cookbook versions : a sorted list of version strings
def expand_cookbook_urls(cookbook_name, versions, num_versions)
      versions = versions[0...num_versions.to_i] unless num_versions == "all"
      version_list = versions.inject([]) do |res, version|
        res.push({ 
          :url => absolute_url(:cookbook_version, :cookbook_name => cookbook_name, :cookbook_version => version),
          :version => version
        })
        res
      end
      url = absolute_url(:cookbook, :cookbook_name => cookbook_name)
      {:url => url, :versions => version_list}
    end
def expand_cookbook_urls ( cookbook_name , versions , num_versions ) versions = versions [ 0 ... num_versions . to_i ] unless num_versions == "all" version_list = versions . inject ( [ ] ) do | res , version | res . push ( { :url => absolute_url ( :cookbook_version , :cookbook_name => cookbook_name , :cookbook_version => version ) , :version => version } ) res end url = absolute_url ( :cookbook , :cookbook_name => cookbook_name ) { :url => url , :versions => version_list } end
takes a cookbook_name and an array of versions and returns a hash
params:
 cookbook_name: the name of the cookbook
 versions: a sorted list of version strings
takes a cookbook_name and an array of versions and returns a hash params : cookbook_name : the name of the cookbook versions : a sorted list of version strings
cookbook_name
<not_specific>
versions
<not_specific>
num_versions
<not_specific>