Module: SiteMap

Defined in:
lib/site_map.rb,
lib/site_map/map.rb,
lib/site_map/version.rb,
lib/site_map/view_node.rb,
lib/site_map/exceptions.rb,
lib/site_map/view_helpers.rb,
lib/site_map/helpers/mapping.rb,
lib/site_map/helpers/action_controller.rb

Defined Under Namespace

Modules: Exceptions, Helpers, Version, ViewHelpers Classes: Map, ViewNode

Constant Summary collapse

DEFAULT_FILE =
File.join('config', 'site_map.rb')

Class Method Summary collapse

Class Method Details

.[](view_node_index) ⇒ Object



28
29
30
# File 'lib/site_map.rb', line 28

def [](view_node_index)
  self.map.find(view_node_index.to_sym)
end

.define {|@@map| ... } ⇒ Object

Yields:



45
46
47
# File 'lib/site_map.rb', line 45

def define(&block)
  yield @@map
end

.loggerObject



49
50
51
# File 'lib/site_map.rb', line 49

def logger
  @@logger ||= Logger.new(STDOUT)
end

.logger=(new_logger) ⇒ Object



52
53
54
# File 'lib/site_map.rb', line 52

def logger=(new_logger)
  @@logger = new_logger
end

.mapObject



41
42
43
# File 'lib/site_map.rb', line 41

def map
  @@map
end

.setup(*files) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/site_map.rb', line 13

def setup(*files)
  files = files.first if files.first.is_a?(Array)
  files << DEFAULT_FILE if files.empty?
  self.logger = Rails.logger if defined?(Rails)
  @@map ||= SiteMap::Map.new
  @@map.clear_nodes!
  files.each do |file|
    begin
      load file
    rescue LoadError => exception
      self.logger.info("SiteMap config file: #{file} could not be loaded.") unless file == DEFAULT_FILE
    end
  end
end

.view_nodesObject Also known as: views



32
33
34
# File 'lib/site_map.rb', line 32

def view_nodes
  self.map.view_nodes
end

.visible_viewsObject



37
38
39
# File 'lib/site_map.rb', line 37

def visible_views
  self.map.visible_views
end