Sha256: 3b54ebe3c18631d23f57d9347b0515a3602b13a9134d6e4b99ae0ff6434c74a6
Contents?: true
Size: 1.21 KB
Versions: 4
Compression:
Stored size: 1.21 KB
Contents
module Redcar class Project # Purpose of this class is to have a menu that shows the 5 most recent opened directories # This way users can quickly go to directories they have recently opened, or use frequently class RecentDirectories MAX_LENGTH = 10 # Create menus for recent directories def self.storage @storage ||= begin storage = Plugin::Storage.new('recent_directories') storage.set_default('list', []) storage end end def self.generate_menu(builder) directories = storage['list'] directories.each do |dir| builder.item(File.basename(dir)) do Project.open_dir(dir) end end end # Stores the given path to the text file, to appear in the recent directories menu. # # @param [String] path the path of a directory to be saved def self.store_path(path) path = File.expand_path(path) storage["list"].delete(path) storage["list"].unshift(path) if storage["list"].length == MAX_LENGTH + 1 storage["list"].pop end storage.save Redcar.app.refresh_menu! end end end end
Version data entries
4 entries across 4 versions & 1 rubygems