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

Instance Method Details

#load_preferences(force_reload = false) ⇒ Object

Loads preferences. By default, preferences are only loaded once.



18
19
20
21
# File 'lib/ise/project_navigator.rb', line 18

def load_preferences(force_reload=false)
  @preferences = nil if force_reload
  @preferences ||= PreferenceFile.load
end

#most_recent_projectObject

Returns a project object representing the most recently open project.



68
69
70
# File 'lib/ise/project_navigator.rb', line 68

def most_recent_project
  Project.load(most_recent_project_path)
end

#most_recent_project_pathObject

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.



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/ise/project_navigator.rb', line 52

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.



42
43
44
# File 'lib/ise/project_navigator.rb', line 42

def preference(path, prefix="#{version}/")
  return @preferences.get_by_path(prefix + path)
end

#preferencesObject



34
35
36
37
# File 'lib/ise/project_navigator.rb', line 34

def preferences
  load_preferences
  return @preferences[version]
end

#versionObject

Returns the current ISE version.



26
27
28
29
# File 'lib/ise/project_navigator.rb', line 26

def version
  load_preferences
  @preferences.sections.first
end