Sha256: 0c5c9ad3fa784a90beb251f1c2277009aad73b10d1d777d268e8042fe1f3a5b1

Contents?: true

Size: 799 Bytes

Versions: 7

Compression:

Stored size: 799 Bytes

Contents

# frozen_string_literal: true

require "dry/monads"

module SublimeTextKit
  module Configuration
    module Transformers
      # Transforms session path into fully qualified path based on home directory.
      class SessionPath
        include Dry::Monads[:result]

        DEFAULT = "Library/Application Support/Sublime Text/Local/Session.sublime_session"

        def initialize key = :session_path, default: DEFAULT
          @key = key
          @default = default
        end

        def call content
          return Success content unless content.key? :home

          Pathname(content[:home]).join(default)
                                  .then { |value| Success content.merge!(key => value) }
        end

        private

        attr_reader :key, :default
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sublime_text_kit-16.3.0 lib/sublime_text_kit/configuration/transformers/session_path.rb
sublime_text_kit-16.2.0 lib/sublime_text_kit/configuration/transformers/session_path.rb
sublime_text_kit-16.1.0 lib/sublime_text_kit/configuration/transformers/session_path.rb
sublime_text_kit-16.0.0 lib/sublime_text_kit/configuration/transformers/session_path.rb
sublime_text_kit-15.2.1 lib/sublime_text_kit/configuration/transformers/session_path.rb
sublime_text_kit-15.2.0 lib/sublime_text_kit/configuration/transformers/session_path.rb
sublime_text_kit-15.1.0 lib/sublime_text_kit/configuration/transformers/session_path.rb