This file is indexed.

/usr/lib/ruby/vendor_ruby/simple_navigation.rb is in ruby-simple-navigation 3.11.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# cherry picking active_support stuff
require 'active_support/core_ext/array'
require 'active_support/core_ext/hash'
require 'active_support/core_ext/module/attribute_accessors'

require 'simple_navigation/core'
require 'simple_navigation/rendering'
require 'simple_navigation/adapters'

require 'forwardable'

# A plugin for generating a simple navigation. See README for resources on usage instructions.
module SimpleNavigation
  
  mattr_accessor :adapter_class, :adapter, :config_files, :config_file_paths, :default_renderer, :registered_renderers, :root, :environment

  # Cache for loaded config files
  self.config_files = {}

  # Allows for multiple config_file_paths. Needed if a plugin itself uses simple-navigation and therefore has its own config file
  self.config_file_paths = []
  
  # Maps renderer keys to classes. The keys serve as shortcut in the render_navigation calls (:renderer => :list)
  self.registered_renderers = {
    :list         => SimpleNavigation::Renderer::List,
    :links        => SimpleNavigation::Renderer::Links,
    :breadcrumbs  => SimpleNavigation::Renderer::Breadcrumbs,
    :text         => SimpleNavigation::Renderer::Text,
    :json         => SimpleNavigation::Renderer::Json
  }
  
  class << self
    extend Forwardable
    
    def_delegators :adapter, :request, :request_uri, :request_path, :context_for_eval, :current_page?
    def_delegators :adapter_class, :register

    # Sets the root path and current environment as specified. Also sets the default config_file_path.
    def set_env(root, environment)
      self.root = root
      self.environment = environment
      self.config_file_paths << SimpleNavigation.default_config_file_path
    end

    # Returns the current framework in which the plugin is running.
    def framework
      return :rails if defined?(Rails)
      return :padrino if defined?(Padrino)
      return :sinatra if defined?(Sinatra)
      return :nanoc if defined?(Nanoc3)
      raise 'simple_navigation currently only works for Rails, Sinatra and Padrino apps'
    end
    
    # Loads the adapter for the current framework
    def load_adapter
      self.adapter_class = case framework
      when :rails
        SimpleNavigation::Adapters::Rails
      when :sinatra
        SimpleNavigation::Adapters::Sinatra
      when :padrino
        SimpleNavigation::Adapters::Padrino
      when :nanoc
        SimpleNavigation::Adapters::Nanoc
      end
    end

    # Creates a new adapter instance based on the context in which render_navigation has been called.
    def init_adapter_from(context)
      self.adapter = self.adapter_class.new(context)
    end
  
    def default_config_file_path
      File.join(SimpleNavigation.root, 'config')
    end

    # Returns true if the config_file for specified context does exist.
    def config_file?(navigation_context = :default)
      !!config_file(navigation_context)
    end

    # Returns the path to the config file for the given navigation context or nil if no matching config file can be found.
    # If multiple config_paths are set, it returns the first matching path.
    def config_file(navigation_context = :default)
      config_file_paths.collect { |path| File.join(path, config_file_name(navigation_context)) }.detect {|full_path| File.exists?(full_path)}
    end

    # Returns the name of the config file for the given navigation_context
    def config_file_name(navigation_context = :default)
      prefix = navigation_context == :default ? '' : "#{navigation_context.to_s.underscore}_"
      "#{prefix}navigation.rb"      
    end
    
    # Resets the list of config_file_paths to the specified path
    def config_file_path=(path)
      self.config_file_paths = [path]
    end

    # Reads the config_file for the specified navigation_context and stores it for later evaluation.
    def load_config(navigation_context = :default)
      raise "Config file '#{config_file_name(navigation_context)}' not found in path(s) #{config_file_paths.join(', ')}!" unless config_file?(navigation_context)      
      if self.environment == 'production'
        self.config_files[navigation_context] ||= IO.read(config_file(navigation_context))
      else
        self.config_files[navigation_context] = IO.read(config_file(navigation_context))
      end
    end

    # Returns the singleton instance of the SimpleNavigation::Configuration
    def config
      SimpleNavigation::Configuration.instance
    end

    # Returns the ItemContainer that contains the items for the primary navigation
    def primary_navigation
      config.primary_navigation
    end

    # Returns the active item container for the specified level. Valid levels are
    # * :all - in this case the primary_navigation is returned.
    # * :leaves - the 'deepest' active item_container will be returned
    # * a specific level - the active item_container for the specified level will be returned
    # * a range of levels - the active item_container for the range's minimum will be returned
    #
    # Returns nil if there is no active item_container for the specified level.
    def active_item_container_for(level)
      case level
      when :all
        self.primary_navigation
      when :leaves
        self.primary_navigation.active_leaf_container
      when Integer
        self.primary_navigation.active_item_container_for(level)
      when Range
        self.primary_navigation.active_item_container_for(level.min)
      else
        raise ArgumentError, "Invalid navigation level: #{level}"
      end
    end
        
    # Registers a renderer.
    #
    # === Example
    # To register your own renderer:
    #
    #   SimpleNavigation.register_renderer :my_renderer => My::RendererClass
    #
    # Then in the view you can call:
    #
    #   render_navigation(:renderer => :my_renderer)
    def register_renderer(renderer_hash)
      self.registered_renderers.merge!(renderer_hash)
    end
    
    private
    
    def apply_defaults(options)
      options[:level] = options.delete(:levels) if options[:levels]
      {:context => :default, :level => :all}.merge(options)
    end
    

  end

end

SimpleNavigation.load_adapter