Sha256: f80df464cdfaa9fcbf862e762b4138e951019fbe6229e699b1390ec36fc0759e

Contents?: true

Size: 998 Bytes

Versions: 19

Compression:

Stored size: 998 Bytes

Contents

# frozen_string_literal: true

require "json"
require "refinements/pathnames"

module SublimeTextKit
  module Sessions
    # Manages the rebuilding of session information.
    class Rebuilder
      include Import[:configuration]

      using Refinements::Pathnames

      def call
        session = read

        return unless session.dig "workspaces", "recent_workspaces"

        Pathname(metadata_dir).expand_path
                              .files("*.sublime-workspace")
                              .then do |workspaces|
                                session["workspaces"]["recent_workspaces"] = workspaces
                                write session
                              end
      end

      private

      def read = source_path.exist? ? JSON(source_path.read) : {}

      def write(json) = JSON.dump(json).then { |content| source_path.write content }

      def metadata_dir = configuration.metadata_dir

      def source_path = configuration.session_path
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
sublime_text_kit-15.2.1 lib/sublime_text_kit/sessions/rebuilder.rb
sublime_text_kit-15.2.0 lib/sublime_text_kit/sessions/rebuilder.rb
sublime_text_kit-15.1.0 lib/sublime_text_kit/sessions/rebuilder.rb
sublime_text_kit-15.0.3 lib/sublime_text_kit/sessions/rebuilder.rb
sublime_text_kit-15.0.2 lib/sublime_text_kit/sessions/rebuilder.rb
sublime_text_kit-15.0.1 lib/sublime_text_kit/sessions/rebuilder.rb
sublime_text_kit-15.0.0 lib/sublime_text_kit/sessions/rebuilder.rb
sublime_text_kit-14.2.0 lib/sublime_text_kit/sessions/rebuilder.rb
sublime_text_kit-14.1.2 lib/sublime_text_kit/sessions/rebuilder.rb
sublime_text_kit-14.1.1 lib/sublime_text_kit/sessions/rebuilder.rb
sublime_text_kit-14.1.0 lib/sublime_text_kit/sessions/rebuilder.rb
sublime_text_kit-14.0.0 lib/sublime_text_kit/sessions/rebuilder.rb
sublime_text_kit-13.5.0 lib/sublime_text_kit/sessions/rebuilder.rb
sublime_text_kit-13.4.0 lib/sublime_text_kit/sessions/rebuilder.rb
sublime_text_kit-13.3.0 lib/sublime_text_kit/sessions/rebuilder.rb
sublime_text_kit-13.2.0 lib/sublime_text_kit/sessions/rebuilder.rb
sublime_text_kit-13.1.0 lib/sublime_text_kit/sessions/rebuilder.rb
sublime_text_kit-13.0.1 lib/sublime_text_kit/sessions/rebuilder.rb
sublime_text_kit-13.0.0 lib/sublime_text_kit/sessions/rebuilder.rb