Sha256: 42ca3838348859b30f0c532d4ec41251cf04756665e16e32e32bf7c5a3a91854

Contents?: true

Size: 945 Bytes

Versions: 2

Compression:

Stored size: 945 Bytes

Contents

# frozen_string_literal: true

require "core"
require "refinements/strings"

module Pennyworth
  module Presenters
    # Renders Standard Gem records into a compatible format for use in Alfred script filters.
    class StandardGem
      using Refinements::Arrays
      using Refinements::Strings

      def initialize record, inflector: Inflector.new
        @record = record
        @inflector = inflector
      end

      def id = record.fetch :gem

      def label = "#{inflector.call id.titleize} #{version}"

      def subtitle = record.fetch :description

      def version = record.fetch(:versions, Core::EMPTY_HASH).values.first

      def site_url = record.fetch(:sourceRepository)

      def source_url = record.fetch(:sourceRepository)

      def issues_url = "https://github.com/ruby/#{id}/issues"

      def versions_url = "https://github.com/ruby/#{id}/tags"

      private

      attr_reader :record, :inflector
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pennyworth-15.1.1 lib/pennyworth/presenters/standard_gem.rb
pennyworth-15.1.0 lib/pennyworth/presenters/standard_gem.rb