Class Hike::Index
In: lib/hike/index.rb
Parent: Object

`Index` is an internal cached variant of `Trail`. It assumes the file system does not change between `find` calls. All `stat` and `entries` calls are cached for the lifetime of the `Index` object.

Methods

Attributes

aliases  [R]  `Index#aliases` is an immutable `Hash` mapping an extension to an `Array` of aliases.
extensions  [R]  `Index#extensions` is an immutable `Extensions` collection.
paths  [R]  `Index#paths` is an immutable `Paths` collection.

Public Class methods

`Index.new` is an internal method. Instead of constructing it directly, create a `Trail` and call `Trail#index`.

Public Instance methods

A cached version of `Dir.entries` that filters out `.` files and `~` swap files. Returns an empty `Array` if the directory does not exist.

The real implementation of `find`. `Trail#find` generates a one time index and delegates here.

See `Trail#find` for usage.

`Index#index` returns `self` to be compatable with the `Trail` interface.

`Index#root` returns root path as a `String`. This attribute is immutable.

A cached version of `File.stat`. Returns nil if the file does not exist.

Protected Instance methods

Returns a `Regexp` that matches the allowed extensions.

    pattern_for("index.html") #=> /^index(.html|.htm)(.builder|.erb)*$/

Finds relative logical path, `../test/test_trail`. Requires a `base_path` for reference.

Finds logical path across all `paths`

Checks if the path is actually on the file system and performs any syscalls if necessary.

Returns true if `dirname` is a subdirectory of any of the `paths`

Sorts candidate matches by their extension priority. Extensions in the front of the `extensions` carry more weight.

[Validate]