Sha256: dcbc4140a8403db4b969a1b59109d084797aea089147f74ba0f9d328e15317fc

Contents?: true

Size: 1.23 KB

Versions: 11

Compression:

Stored size: 1.23 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
        warn "[DEPRECATION]: #changes_url is deprecated, use #versions_url instead."
        versions_url
      end

      def issues_url = record.fetch(:bug_tracker_uri)

      def versions_url = record.fetch(:changelog_uri)

      def updated_at = record.fetch(:version_created_at)

      private

      attr_reader :record, :inflector
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
pennyworth-13.4.0 lib/pennyworth/presenters/gem.rb
pennyworth-13.3.0 lib/pennyworth/presenters/gem.rb
pennyworth-13.2.0 lib/pennyworth/presenters/gem.rb
pennyworth-13.1.0 lib/pennyworth/presenters/gem.rb
pennyworth-13.0.1 lib/pennyworth/presenters/gem.rb
pennyworth-13.0.0 lib/pennyworth/presenters/gem.rb
pennyworth-12.3.1 lib/pennyworth/presenters/gem.rb
pennyworth-12.3.0 lib/pennyworth/presenters/gem.rb
pennyworth-12.2.0 lib/pennyworth/presenters/gem.rb
pennyworth-12.1.0 lib/pennyworth/presenters/gem.rb
pennyworth-12.0.2 lib/pennyworth/presenters/gem.rb