Module: ISE::ProjectNavigator
- Extended by:
- ProjectNavigator
- Included in:
- ProjectNavigator
- Defined in:
- lib/ise/project_navigator.rb
Overview
Module which handles manipulating the ISE Project Navigator.
Constant Summary collapse
- RecentProjectsPath =
'Project Navigator/Recent Project List1'
Instance Method Summary collapse
-
#load_preferences(force_reload = false) ⇒ Object
Loads preferences.
-
#most_recent_project ⇒ Object
Returns a project object representing the most recently open project.
-
#most_recent_project_path ⇒ Object
Returns most recently open project.
-
#preference(path, prefix = "#{version}/") ⇒ Object
Returns the preference with the given path.
- #preferences ⇒ Object
-
#set_preference_file(preference_file = nil) ⇒ Object
Sets the path of the preference file to look for.
-
#version ⇒ Object
Returns the current ISE version.
Instance Method Details
#load_preferences(force_reload = false) ⇒ Object
Loads preferences. By default, preferences are only loaded once.
25 26 27 28 |
# File 'lib/ise/project_navigator.rb', line 25 def load_preferences(force_reload=false) @preferences = nil if force_reload @preferences ||= PreferenceFile.load(@preference_file) end |
#most_recent_project ⇒ Object
Returns a project object representing the most recently open project.
78 79 80 81 |
# File 'lib/ise/project_navigator.rb', line 78 def most_recent_project path = most_recent_project_path path ? Project.load(path) : nil end |
#most_recent_project_path ⇒ Object
Returns most recently open project. If Project Navigator has a project open, that project will be used. This function re-loads the preferences file upon each call, to ensure we don’t have stale data.
TODO: When more than one ISE version is loaded, parse all of the recent projects, and then return the project with the latest timestamp.
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/ise/project_navigator.rb', line 62 def most_recent_project_path #Re-load the preference file, so we have the most recent project. @preferences = PreferenceFile.load #And retrieve the first project in the recent projects list. project = preference(RecentProjectsPath).split(', ').first #If the project exists, return it; otherwise, return nil. File::exists?(project) ? project : nil end |
#preference(path, prefix = "#{version}/") ⇒ Object
Returns the preference with the given path.
49 50 51 |
# File 'lib/ise/project_navigator.rb', line 49 def preference(path, prefix="#{version}/") return @preferences.get_by_path(prefix + path) end |
#preferences ⇒ Object
41 42 43 44 |
# File 'lib/ise/project_navigator.rb', line 41 def preferences load_preferencers return @preferences[version] end |
#set_preference_file(preference_file = nil) ⇒ Object
Sets the path of the preference file to look for.
17 18 19 |
# File 'lib/ise/project_navigator.rb', line 17 def set_preference_file(preference_file=nil) @preference_file = preference_file end |
#version ⇒ Object
Returns the current ISE version.
33 34 35 36 |
# File 'lib/ise/project_navigator.rb', line 33 def version load_preferences @preferences.sections.last end |