Sha256: fee36e37ce6e29eaa46dedc2e69324bc23806d4bb43dcd97f7c40a95b65c8fa3

Contents?: true

Size: 864 Bytes

Versions: 7

Compression:

Stored size: 864 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
          printers.fetch(kind).call
        rescue KeyError
          logger.error { "Invalid snippet format: #{kind}. Use #{formats}." }
        end

        private

        attr_reader :printers, :container

        def formats = printers.keys.join(" or ")

        def configuration = container[__method__]

        def logger = container[__method__]
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sublime_text_kit-12.3.2 lib/sublime_text_kit/cli/actions/snippets.rb
sublime_text_kit-12.3.1 lib/sublime_text_kit/cli/actions/snippets.rb
sublime_text_kit-12.3.0 lib/sublime_text_kit/cli/actions/snippets.rb
sublime_text_kit-12.2.0 lib/sublime_text_kit/cli/actions/snippets.rb
sublime_text_kit-12.1.0 lib/sublime_text_kit/cli/actions/snippets.rb
sublime_text_kit-12.0.1 lib/sublime_text_kit/cli/actions/snippets.rb
sublime_text_kit-12.0.0 lib/sublime_text_kit/cli/actions/snippets.rb