Sha256: 93f4c047752f40a873dc65e1bf0b762035a4d76550c6f5f409a91919e7b20ee1

Contents?: true

Size: 911 Bytes

Versions: 7

Compression:

Stored size: 911 Bytes

Contents

# frozen_string_literal: true

require "sod"

module Pennyworth
  module CLI
    module Actions
      # Handles the Standard Gem action.
      class StandardGem < Sod::Action
        include Import[:kernel]

        ENDPOINTS = {
          "all" => "stdgems.json",
          "default" => "default_gems.json",
          "bundled" => "bundled_gems.json"
        }.freeze

        description "Render Alfred Standard Gems script filter."

        on "--standard_gems", argument: "[KIND]", allow: %w[all default bundled], default: "all"

        def initialize(processor: Processor.for_standard_gems, endpoints: ENDPOINTS, **)
          super(**)
          @processor = processor
          @endpoints = endpoints
        end

        def call(kind = nil) = kernel.puts processor.call(endpoints.fetch(kind || default)).to_json

        private

        attr_reader :processor, :endpoints
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pennyworth-16.7.0 lib/pennyworth/cli/actions/standard_gem.rb
pennyworth-16.5.0 lib/pennyworth/cli/actions/standard_gem.rb
pennyworth-16.4.0 lib/pennyworth/cli/actions/standard_gem.rb
pennyworth-16.3.0 lib/pennyworth/cli/actions/standard_gem.rb
pennyworth-16.2.0 lib/pennyworth/cli/actions/standard_gem.rb
pennyworth-16.1.0 lib/pennyworth/cli/actions/standard_gem.rb
pennyworth-16.0.0 lib/pennyworth/cli/actions/standard_gem.rb