Add Wiki#files for list of non-page files.

This commit is contained in:
trans
2012-06-22 08:23:46 -04:00
parent 8fd11e8fdb
commit 754485c306
4 changed files with 62 additions and 3 deletions
+27
View File
@@ -446,6 +446,15 @@ module Gollum
tree_list(treeish || @ref)
end
# Public: Lists all non-page files for this wiki.
#
# treeish - The String commit ID or ref to find (default: @ref)
#
# Returns an Array of Gollum::File instances.
def files(treeish = nil)
file_list(treeish || @ref)
end
# Public: Returns the number of pages accessible from a commit
#
# ref - A String ref that is either a commit SHA or references one.
@@ -595,6 +604,24 @@ module Gollum
end
end
# Fill an array with a list of files.
#
# ref - A String ref that is either a commit SHA or references one.
#
# Returns a flat Array of Gollum::File instances.
def file_list(ref)
if sha = @access.ref_to_sha(ref)
commit = @access.commit(sha)
tree_map_for(sha).inject([]) do |list, entry|
next list if entry.name.start_with?('_')
next list if @page_class.valid_page_name?(entry.name)
list << entry.file(self, commit)
end
else
[]
end
end
# Creates a reverse diff for the given SHAs on the given Gollum::Page.
#
# page - The Gollum::Page to scope the patch to, or a String Path.