Sha256: 64d307828499d4a93132a3d7f3e8efad30a28d1b603f03b4a3e5560e8d1303b1

Contents?: true

Size: 774 Bytes

Versions: 2

Compression:

Stored size: 774 Bytes

Contents

# frozen_string_literal: true

module Unwrappr
  module Writers
    # Add the gem name to the annotation as a heading. If a homepage
    # URI has been determined this heading will link to that page.
    #
    # Implements the `annotation_writer` interface required by the
    # LockFileAnnotator.
    module Title
      class << self
        def write(gem_change, gem_change_info)
          embellished_gem_name = maybe_link(
            gem_change.name,
            gem_change_info.dig(:ruby_gems, 'homepage_uri')
          )
          "### #{embellished_gem_name}\n"
        end

        private

        def maybe_link(text, url)
          if url.nil?
            text
          else
            "[#{text}](#{url})"
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
unwrappr-0.8.2 lib/unwrappr/writers/title.rb
unwrappr-0.8.1 lib/unwrappr/writers/title.rb