Sha256: 18aaf3315d26cccb9b77425d526531af17cf50cf6438fc5784b6bf2902cb1267
Contents?: true
Size: 1.03 KB
Versions: 26
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true require "json" module SublimeTextKit # Manages Sublime Text session data. class Session attr_reader :metadata_dir def self.home_path ENV.fetch "HOME" end def self.session_path "#{home_path}/Library/Application Support/Sublime Text 3/Local/Session.sublime_session" end def initialize metadata_directory @metadata_dir = File.expand_path metadata_directory end def workspaces Dir["#{metadata_dir}/*.sublime-workspace"].sort end def rebuild_recent_workspaces session = load_session return unless session && session["workspaces"] && session["workspaces"]["recent_workspaces"] session["workspaces"]["recent_workspaces"] = workspaces save_session session end private def load_session File.exist?(self.class.session_path) ? JSON.parse(File.read(self.class.session_path)) : {} end def save_session json File.open(self.class.session_path, "w") { |file| file.write JSON.dump(json) } end end end
Version data entries
26 entries across 26 versions & 1 rubygems