Sha256: fee40bd70a81d50d87508f5a51b4da25d88f78a060955e9164e061d7734fda00

Contents?: true

Size: 840 Bytes

Versions: 1

Compression:

Stored size: 840 Bytes

Contents

# frozen_string_literal: true

module SublimeTextKit
  module CLI
    module Actions
      # Handles snippets action.
      class Snippets
        PRINTERS = {
          ascii_doc: SublimeTextKit::Snippets::Printers::ASCIIDoc.new,
          markdown: SublimeTextKit::Snippets::Printers::Markdown.new
        }.freeze

        def initialize printers: PRINTERS, container: Container
          @printers = printers
          @container = container
        end

        def call
          kind = configuration.snippets_format
          printers.fetch(kind).call
        rescue KeyError
          logger.error { "Invalid snippet format: #{kind}." }
        end

        private

        attr_reader :printers, :container

        def configuration = container[__method__]

        def logger = container[__method__]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sublime_text_kit-11.0.0 lib/sublime_text_kit/cli/actions/snippets.rb