Sha256: 4d9ca8344df4920d958758ffdc050f961593200931d9333113819b1785f8dcb4

Contents?: true

Size: 1.09 KB

Versions: 94

Compression:

Stored size: 1.09 KB

Contents

class Navigation
  IGNORED_PATHS = ['..', '.', '.DS_Store'].freeze
  NAVIGATION    = LoadConfig.load_file('config/navigation.yml')
  WEIGHT        = NAVIGATION['navigation_weight']
  OVERRIDES     = NAVIGATION['navigation_overrides']

  def initialize(folder)
    @folder = folder
  end

  def options
    @options ||= begin
      path_to_url.tr('/', '.').split('.').inject(OVERRIDES) { |h, k| h[k] || {} }
    end
  end

  def path_to_url
    @path_to_url ||= begin
      if @folder[:is_task?]
        path = @folder[:path].sub(@folder[:root], '')
        path.sub(%r{^/\w+/}, '').chomp('.yml')
      else
        path = @folder[:path].gsub("#{Rails.configuration.docs_base_path}/", '')
        path.sub(%r{^\w+/\w+/}, '').chomp('.md')
      end
    end
  end

  def product
    @product ||= begin
      if @folder[:path].starts_with?('app/views')
        path_to_url.split('/').first
      else
        DocumentationConstraint.products_for_routes.find do |p|
          path_to_url.starts_with? p
        end
      end
    end
  end

  def document
    @document ||= path_to_url.sub("#{product}/", '')
  end
end

Version data entries

94 entries across 94 versions & 1 rubygems

Version Path
station-0.5.16 lib/nexmo_developer/app/presenters/navigation.rb
station-0.5.15 lib/nexmo_developer/app/presenters/navigation.rb
station-0.5.14 lib/nexmo_developer/app/presenters/navigation.rb
station-0.5.13 lib/nexmo_developer/app/presenters/navigation.rb
station-0.5.12 lib/nexmo_developer/app/presenters/navigation.rb
station-0.5.11 lib/nexmo_developer/app/presenters/navigation.rb
station-0.5.10 lib/nexmo_developer/app/presenters/navigation.rb
station-0.5.9 lib/nexmo_developer/app/presenters/navigation.rb
station-0.5.8 lib/nexmo_developer/app/presenters/navigation.rb
station-0.5.7 lib/nexmo_developer/app/presenters/navigation.rb
station-0.5.6 lib/nexmo_developer/app/presenters/navigation.rb
station-0.5.5 lib/nexmo_developer/app/presenters/navigation.rb
station-0.5.4 lib/nexmo_developer/app/presenters/navigation.rb
station-0.5.3 lib/nexmo_developer/app/presenters/navigation.rb
station-0.5.2 lib/nexmo_developer/app/presenters/navigation.rb
station-0.5.1 lib/nexmo_developer/app/presenters/navigation.rb
station-0.5.0 lib/nexmo_developer/app/presenters/navigation.rb
station-0.4.9 lib/nexmo_developer/app/presenters/navigation.rb
station-0.4.8 lib/nexmo_developer/app/presenters/navigation.rb
station-0.4.7 lib/nexmo_developer/app/presenters/navigation.rb