Sha256: 2ab4d0c3c6f69fa88975014a6973258a057d7f95d07b47383c4824881a5e0653

Contents?: true

Size: 1.05 KB

Versions: 6

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module Pennyworth
  module Serializers
    # Serializes a project presenter for parsing by Alfred script filters.
    class Project
      def initialize presenter
        @presenter = presenter
      end

      def to_h
        {
          uid: presenter.id,
          title: presenter.label,
          subtitle: presenter.subtitle,
          arg: site_url,
          quicklookurl: site_url,
          mods: modifications,
          text:
        }
      end

      private

      attr_reader :presenter

      def modifications
        {
          alt: modification(presenter.source_url, "View source."),
          cmd: modification(presenter.issues_url, "View issues."),
          control: modification(presenter.versions_url, "View versions.")
        }
      end

      def modification argument, subtitle
        {
          subtitle:,
          arg: argument
        }
      end

      def text
        {
          copy: site_url,
          largetype: site_url
        }
      end

      def site_url = presenter.site_url
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pennyworth-17.8.0 lib/pennyworth/serializers/project.rb
pennyworth-17.7.0 lib/pennyworth/serializers/project.rb
pennyworth-17.6.0 lib/pennyworth/serializers/project.rb
pennyworth-17.5.0 lib/pennyworth/serializers/project.rb
pennyworth-17.4.1 lib/pennyworth/serializers/project.rb
pennyworth-17.4.0 lib/pennyworth/serializers/project.rb