class Chef::Taste::Changelog

The Changelog class that computes the changelog if the current version being used and the latest version are different and the changelog is computable.

Public Class Methods

compute(dep) click to toggle source

Compute the changelog for the dependent cookbook if available

@param dep [Dependency] the dependent cookbook

@return [String] the goo.gl shortened URL for the changelog

# File lib/chef/taste/changelog.rb, line 41
def compute(dep)
  # Skip dependent cookbook which has no source url
  return '' if dep.source_url.nil?

  # The source url is of the form https://HOSTING_PROVIDER/USER/REPO
  matched = dep.source_url.match(%r(^(https?:\/\/)?(.*?)\/(.*?)\/(.*?)$))
  changelog_url =
    if matched[2] == 'github.com'
      GithubChangelog.new("#{matched[3]}/#{matched[4]}", dep.version_used, dep.latest).compute
    else
      nil
    end
  Googl.shorten(changelog_url).short_url unless changelog_url.nil?
end