Sha256: e7cf1d6e837c6859ed584aa134255cc4185634855a69e82a3313f58bcabd69a0
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
require "multi_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) ? MultiJson.load(File.read(self.class.session_path)) : {} end def save_session json File.open(self.class.session_path, "w") { |file| file.write MultiJson.dump(json, pretty: true) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sublime_text_kit-3.2.0 | lib/sublime_text_kit/session.rb |