Sha256: c0b32227ee26e7ce4ddf677e204e1a7da416ac7a141a6b905af0ba3f899c166f

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require "refinements/strings"

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

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

      def id = record.fetch(:name)

      def label = inflector.call(id.titleize)

      def subtitle
        "Version: #{version}. " \
        "Updated: #{updated_at[..9]}. " \
        "Licenses: #{licenses}. " \
        "Downloads: #{downloads}."
      end

      def version = record.fetch(__method__)

      def licenses = Array(record.fetch(__method__)).join(", ")

      def downloads = record.fetch(__method__)

      def site_url = record.fetch(:homepage_uri)

      def source_url = record.fetch(:source_code_uri)

      def changes_url = record.fetch(:changelog_uri)

      def issues_url = record.fetch(:bug_tracker_uri)

      def updated_at = record.fetch(:version_created_at)

      private

      attr_reader :record, :inflector
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pennyworth-12.0.1 lib/pennyworth/presenters/gem.rb
pennyworth-12.0.0 lib/pennyworth/presenters/gem.rb
pennyworth-11.2.2 lib/pennyworth/presenters/gem.rb
pennyworth-11.2.1 lib/pennyworth/presenters/gem.rb
pennyworth-11.2.0 lib/pennyworth/presenters/gem.rb
pennyworth-11.1.3 lib/pennyworth/presenters/gem.rb
pennyworth-11.1.2 lib/pennyworth/presenters/gem.rb