Sha256: 0aece53db71a8934e90b20b46f22c31fb3dd228e53d94f25fce5938c30808f8d

Contents?: true

Size: 953 Bytes

Versions: 1

Compression:

Stored size: 953 Bytes

Contents

# frozen_string_literal: true

require "open3"

module SublimeTextKit
  module Snippets
    module Printers
      class Markdown
        DEFAULT_USER_PATH = "Library/Application Support/Sublime Text 3/Packages/User"

        def initialize user_path = DEFAULT_USER_PATH, environment: ENV
          @user_path = user_path
          @environment = environment
        end

        def home_path
          Pathname environment.fetch("HOME")
        end

        def root_path
          home_path.join user_path
        end

        def call
          snippets.sort_by(&:description).each do |snippet|
            puts "- #{snippet.description} - `#{snippet.trigger}`\n"
          end
        end

        private

        attr_reader :user_path, :environment

        def snippets
          root_path.glob("*.sublime-snippet").map do |path|
            Snippet.new REXML::Document.new(File.open(path))
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sublime_text_kit-8.5.0 lib/sublime_text_kit/snippets/printers/markdown.rb