class R10kDiff::PuppetModule

Attributes

branch[R]
commit[R]
name[R]
ref[R]
tag[R]

Public Class Methods

new(name, ref:nil, git:nil, forge:nil, tag:nil, commit:nil, branch:nil) click to toggle source
# File lib/r10kdiff.rb, line 26
def initialize(name, ref:nil, git:nil, forge:nil, tag:nil, commit:nil, branch:nil)
  @name = name
  @ref = ref
  @git = git
  @forge = forge
end

Public Instance Methods

different?(other_module) click to toggle source
# File lib/r10kdiff.rb, line 38
def different?(other_module)
  # Note that forge & git r10k modules have different naming convention so
  # we don't need to compare url (forge is user/modulename and git is just
  # modulename with :git attr as the url of the module
  @ref != other_module.ref
end
git?() click to toggle source
# File lib/r10kdiff.rb, line 34
def git?
  !!@git
end
git_https() click to toggle source
# File lib/r10kdiff.rb, line 69
def git_https
  if @git.start_with? "https://"
    return @git
  elsif @git.start_with? "git://"
    return @git.gsub(/^git:/, "https:")
  elsif @git.start_with? "git@"
    return @git.gsub(":", "/").gsub(/^git@/, "https://").gsub(/.git$/, "")
  end
end
pretty_version(include_url) click to toggle source
# File lib/r10kdiff.rb, line 59
def pretty_version(include_url)
  basic_string = "#{name} at #{ref}"
  if include_url
    return "#{basic_string} (#{web_url})"
  else
    return basic_string
  end

end
pretty_version_diff(other_module, include_url) click to toggle source
# File lib/r10kdiff.rb, line 45
def pretty_version_diff(other_module, include_url)
  basic_compare = "#{ref} -> #{other_module.ref}"

  # special case for github - generate compate url
  if git? && other_module.git? && include_url
    return "#{name} #{git_https}/compare/#{ref}...#{other_module.ref}"

  elsif include_url
    return "#{name} #{basic_compare} (#{web_url})"
  else
    return "#{name} #{basic_compare}"
  end
end
web_url() click to toggle source
# File lib/r10kdiff.rb, line 79
def web_url
  return git? ? git_https : @forge
end