Sha256: 53579caa6671d1cce78a3c58f66912c38cb11772f14a308a705ed099b5343f7e

Contents?: true

Size: 908 Bytes

Versions: 15

Compression:

Stored size: 908 Bytes

Contents

# frozen_string_literal: true

require "refinements/strings"

module Pennyworth
  module Presenters
    # Renders a GitHub repository record into a compatible format for use in Alfred script filters.
    class Repository
      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 = record.fetch(:description)

      def site_url = record.fetch(:homepage)

      def source_url = record.fetch(:html_url)

      def changes_url
        warn "[DEPRECATION]: #changes_url is deprecated, use #versions_url instead."
        versions_url
      end

      def issues_url = "#{source_url}/issues"

      def versions_url = "#{site_url}/versions"

      private

      attr_reader :record, :inflector
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
pennyworth-13.8.0 lib/pennyworth/presenters/repository.rb
pennyworth-13.7.0 lib/pennyworth/presenters/repository.rb
pennyworth-13.6.0 lib/pennyworth/presenters/repository.rb
pennyworth-13.5.0 lib/pennyworth/presenters/repository.rb
pennyworth-13.4.0 lib/pennyworth/presenters/repository.rb
pennyworth-13.3.0 lib/pennyworth/presenters/repository.rb
pennyworth-13.2.0 lib/pennyworth/presenters/repository.rb
pennyworth-13.1.0 lib/pennyworth/presenters/repository.rb
pennyworth-13.0.1 lib/pennyworth/presenters/repository.rb
pennyworth-13.0.0 lib/pennyworth/presenters/repository.rb
pennyworth-12.3.1 lib/pennyworth/presenters/repository.rb
pennyworth-12.3.0 lib/pennyworth/presenters/repository.rb
pennyworth-12.2.0 lib/pennyworth/presenters/repository.rb
pennyworth-12.1.0 lib/pennyworth/presenters/repository.rb
pennyworth-12.0.2 lib/pennyworth/presenters/repository.rb