Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Commit

Permalink
Merge pull request #23 from sstephenson/avoid-index-creations
Browse files Browse the repository at this point in the history
Avoid index creations
  • Loading branch information
josh committed Apr 9, 2013
2 parents c0ffe84 + 63cea24 commit 0f298b1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/hike/trail.rb
Expand Up @@ -156,15 +156,19 @@ def index
# `Trail#entries` is equivalent to `Dir#entries`. It is not
# recommend to use this method for general purposes. It exists for
# parity with `Index#entries`.
def entries(*args)
index.entries(*args)
def entries(path)
Pathname.new(path).entries.reject { |entry| entry.to_s =~ /^\.|~$|^\#.*\#$/ }.sort
rescue Errno::ENOENT
[]
end

# `Trail#stat` is equivalent to `File#stat`. It is not
# recommend to use this method for general purposes. It exists for
# parity with `Index#stat`.
def stat(*args)
index.stat(*args)
def stat(path)
File.stat(path.to_s)
rescue Errno::ENOENT
nil
end

private
Expand Down

0 comments on commit 0f298b1

Please sign in to comment.