class KeepAChangelogManager::Repo
Handles all things related to a repository and its filesystem
Attributes
root[RW]
@return String the repository root
Public Class Methods
new(root)
click to toggle source
Create a new Repo
representing git repository, given its path
@param root String path to root directory of repository
# File lib/keepachangelog_manager/repo.rb, line 15 def initialize(root) @root = root end
Public Instance Methods
_owner_from_git_url(url)
click to toggle source
Extract the owner from a git URL
@param url String the URL (git:// or https://) @return String
# File lib/keepachangelog_manager/repo.rb, line 40 def _owner_from_git_url(url) parsed = Git::Remote::Parser.new.parse(url) raise BadGitRepoUrl, "Could not parse '#{url}' as a git url" if parsed.nil? parsed.owner end
changelog()
click to toggle source
A changelog object
@return KeepAChangelog::Changelog
# File lib/keepachangelog_manager/repo.rb, line 71 def changelog Changelog.new(self) end
changelog_path()
click to toggle source
the path to the CHANGELOG.md file
@return String
# File lib/keepachangelog_manager/repo.rb, line 64 def changelog_path File.join(@root, "CHANGELOG.md") end
name()
click to toggle source
Get the repository name. It is assumed to be the name of the repo root directory
keepachangelog.com CHANGELOG.md syntax assumes git and github.com so use that to our advantage: assume git repo exists.
@return String
# File lib/keepachangelog_manager/repo.rb, line 25 def name File.basename(@root) end
origin_url()
click to toggle source
The git remote origin url
@return String
# File lib/keepachangelog_manager/repo.rb, line 32 def origin_url `git remote get-url origin` end
owner()
click to toggle source
Get the repo owner
Assumes an “origin” url!
@return String
# File lib/keepachangelog_manager/repo.rb, line 52 def owner Dir.chdir(@root) do url = origin_url raise NoGitRepo, "Could not find a git repo in '#{@root}'" if url.empty? _owner_from_git_url(url) end end