Class: R10kDiff::PuppetModule
- Inherits:
-
Object
- Object
- R10kDiff::PuppetModule
- Defined in:
- lib/r10kdiff.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
Instance Method Summary collapse
- #different?(other_module) ⇒ Boolean
- #git? ⇒ Boolean
- #git_https ⇒ Object
-
#initialize(name, ref: nil, git: nil, forge: nil) ⇒ PuppetModule
constructor
A new instance of PuppetModule.
- #pretty_version(include_url) ⇒ Object
- #pretty_version_diff(other_module, include_url) ⇒ Object
- #web_url ⇒ Object
Constructor Details
#initialize(name, ref: nil, git: nil, forge: nil) ⇒ PuppetModule
Returns a new instance of PuppetModule.
26 27 28 29 30 31 |
# File 'lib/r10kdiff.rb', line 26 def initialize(name, ref:nil, git:nil, forge:nil) @name = name @ref = ref @git = git @forge = forge end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
32 33 34 |
# File 'lib/r10kdiff.rb', line 32 def name @name end |
#ref ⇒ Object (readonly)
Returns the value of attribute ref.
32 33 34 |
# File 'lib/r10kdiff.rb', line 32 def ref @ref end |
Instance Method Details
#different?(other_module) ⇒ Boolean
38 39 40 41 42 43 |
# 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? ⇒ Boolean
34 35 36 |
# File 'lib/r10kdiff.rb', line 34 def git? !!@git end |
#git_https ⇒ Object
69 70 71 72 73 74 75 76 77 |
# 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) ⇒ Object
59 60 61 62 63 64 65 66 67 |
# 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) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# 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 ⇒ Object
79 80 81 |
# File 'lib/r10kdiff.rb', line 79 def web_url return git? ? git_https : @forge end |