Sha256: f4e10b5aa8dfa761dc2ed63fbaacfe8f7c5c9c049b3608ce278d4ee0042a52c2
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
require "multi_json" module SublimeTextKit class Session attr_accessor :workspaces_path def self.home_path ENV["HOME"] end def self.session_path "#{home_path}/Library/Application Support/Sublime Text 2/Settings/Session.sublime_session" end def initialize options = {} @workspaces_path = options.fetch :workspaces_path, '' end def workspaces_absolute_path File.expand_path workspaces_path end def workspaces Dir["#{workspaces_absolute_path}/*.sublime-project"].sort end def rebuild_recent_workspaces session = load_session if session && session["workspaces"] && session["workspaces"]["recent_workspaces"] session["workspaces"]["recent_workspaces"] = workspaces save_session session end end private def load_session File.exists?(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) } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sublime_text_kit-0.4.0 | lib/sublime_text_kit/session.rb |
sublime_text_kit-0.3.0 | lib/sublime_text_kit/session.rb |