Class: Chef::Taste::Changelog::GithubChangelog
- Inherits:
-
Object
- Object
- Chef::Taste::Changelog::GithubChangelog
- Defined in:
- lib/chef/taste/changelog.rb
Overview
The class for computing the changelog for cookbooks hosted in Github.
Instance Attribute Summary collapse
-
#from_version ⇒ Object
readonly
The version to compare from.
-
#repo ⇒ Object
readonly
The Github repository.
-
#to_version ⇒ Object
readonly
The version to compare to.
Instance Method Summary collapse
-
#compare_url(from_tag, to_tag) ⇒ String
Returns the compare URL for comparing two tags on Github.
-
#compute ⇒ String
Computes the changelog URL for Github repositories.
-
#initialize(repo, from_version, to_version) ⇒ GithubChangelog
constructor
Constructor.
Constructor Details
#initialize(repo, from_version, to_version) ⇒ GithubChangelog
Constructor
77 78 79 80 81 |
# File 'lib/chef/taste/changelog.rb', line 77 def initialize(repo, from_version, to_version) @repo = repo @from_version = from_version @to_version = to_version end |
Instance Attribute Details
#from_version ⇒ Object (readonly)
The version to compare from
64 65 66 |
# File 'lib/chef/taste/changelog.rb', line 64 def from_version @from_version end |
#repo ⇒ Object (readonly)
The Github repository
61 62 63 |
# File 'lib/chef/taste/changelog.rb', line 61 def repo @repo end |
#to_version ⇒ Object (readonly)
The version to compare to
67 68 69 |
# File 'lib/chef/taste/changelog.rb', line 67 def to_version @to_version end |
Instance Method Details
#compare_url(from_tag, to_tag) ⇒ String
Returns the compare URL for comparing two tags on Github
106 107 108 |
# File 'lib/chef/taste/changelog.rb', line 106 def compare_url(from_tag, to_tag) "https://github.com/#{repo}/compare/#{from_tag}...#{to_tag}" end |
#compute ⇒ String
Computes the changelog URL for Github repositories
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/chef/taste/changelog.rb', line 87 def compute = Octokit.(repo) from_tag = nil to_tag = nil .each do |tag| tag_name = tag.name from_tag = tag_name if tag_name =~ /^v?#{from_version}$/ to_tag = tag_name if tag_name =~ /^v?#{to_version}$/ end compare_url(from_tag, to_tag) if from_tag && to_tag end |