class Unwrappr::Writers::ProjectLinks

Add links to project documentation as obtained from Rubygems.org. Specifically, the changelog and sourcecode.

Implements the `annotation_writer` interface required by the LockFileAnnotator.

Constants

GEM_DIFF_URL_TEMPLATE

Public Class Methods

new(gem_change, gem_change_info) click to toggle source
# File lib/unwrappr/writers/project_links.rb, line 15
def initialize(gem_change, gem_change_info)
  @gem_change = gem_change
  @gem_change_info = gem_change_info
end
write(gem_change, gem_change_info) click to toggle source
# File lib/unwrappr/writers/project_links.rb, line 11
def self.write(gem_change, gem_change_info)
  new(gem_change, gem_change_info).write
end

Public Instance Methods

write() click to toggle source
# File lib/unwrappr/writers/project_links.rb, line 20
def write
  "[_#{change_log}, #{source_code}, #{gem_diff}_]\n"
end

Private Instance Methods

change_log() click to toggle source
# File lib/unwrappr/writers/project_links.rb, line 26
def change_log
  link_or_strikethrough('change-log',
                        ruby_gems_info&.changelog_uri)
end
gem_diff() click to toggle source
# File lib/unwrappr/writers/project_links.rb, line 39
def gem_diff
  if !ruby_gems_info.nil? && !@gem_change.added? && !@gem_change.removed?
    gem_diff_url = format(GEM_DIFF_URL_TEMPLATE,
                          @gem_change.name,
                          @gem_change.base_version.to_s,
                          @gem_change.head_version.to_s)
  end
  link_or_strikethrough('gem-diff', gem_diff_url)
end
ruby_gems_info() click to toggle source
# File lib/unwrappr/writers/project_links.rb, line 49
def ruby_gems_info
  @gem_change_info[:ruby_gems]
end
source_code() click to toggle source
# File lib/unwrappr/writers/project_links.rb, line 31
def source_code
  link_or_strikethrough('source-code',
                        ruby_gems_info&.source_code_uri)
end