Sha256: 6c11713d1740d63ae6f0b178f5bab23cf59a9e463226a29ea807cc0c986203c9

Contents?: true

Size: 1.07 KB

Versions: 11

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require "refinements/string"

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

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

      def id = record.fetch(:name)

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

      def subtitle = "Downloads: #{downloads}. Licenses: #{licenses}. Updated: #{updated_at[..9]}."

      def version = record.fetch(__method__)

      def licenses = Array(record.fetch(__method__)).to_sentence

      def downloads = record.fetch(__method__)

      def site_url = record.fetch(:homepage_uri)

      def source_url = record.fetch(:source_code_uri)

      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-17.3.0 lib/pennyworth/presenters/gem.rb
pennyworth-17.2.0 lib/pennyworth/presenters/gem.rb
pennyworth-17.1.0 lib/pennyworth/presenters/gem.rb
pennyworth-17.0.0 lib/pennyworth/presenters/gem.rb
pennyworth-16.7.0 lib/pennyworth/presenters/gem.rb
pennyworth-16.5.0 lib/pennyworth/presenters/gem.rb
pennyworth-16.4.0 lib/pennyworth/presenters/gem.rb
pennyworth-16.3.0 lib/pennyworth/presenters/gem.rb
pennyworth-16.2.0 lib/pennyworth/presenters/gem.rb
pennyworth-16.1.0 lib/pennyworth/presenters/gem.rb
pennyworth-16.0.0 lib/pennyworth/presenters/gem.rb