Sha256: ce21c45fd00bfd980b3cdfc646354ea9dffa1263888eab25ebb8dbcc9d06b3f1

Contents?: true

Size: 1.07 KB

Versions: 11

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require "core"
require "refinements/string"

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

      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

      # :reek:FeatureEnvy
      def version
        versions = record.fetch :versions, Core::EMPTY_HASH
        (versions[:bundled] || versions[:default] || versions).values.first
      end

      def site_url = record.fetch(:sourceRepository, Core::EMPTY_STRING)

      def source_url = record.fetch(:sourceRepository, Core::EMPTY_STRING)

      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

11 entries across 11 versions & 1 rubygems

Version Path
pennyworth-17.3.0 lib/pennyworth/presenters/standard_gem.rb
pennyworth-17.2.0 lib/pennyworth/presenters/standard_gem.rb
pennyworth-17.1.0 lib/pennyworth/presenters/standard_gem.rb
pennyworth-17.0.0 lib/pennyworth/presenters/standard_gem.rb
pennyworth-16.7.0 lib/pennyworth/presenters/standard_gem.rb
pennyworth-16.5.0 lib/pennyworth/presenters/standard_gem.rb
pennyworth-16.4.0 lib/pennyworth/presenters/standard_gem.rb
pennyworth-16.3.0 lib/pennyworth/presenters/standard_gem.rb
pennyworth-16.2.0 lib/pennyworth/presenters/standard_gem.rb
pennyworth-16.1.0 lib/pennyworth/presenters/standard_gem.rb
pennyworth-16.0.0 lib/pennyworth/presenters/standard_gem.rb