Add Wiki#size to efficiently count pages without loading them.

This commit is contained in:
rick
2010-08-30 17:52:20 -07:00
parent 6dab4f7fe6
commit 646c8e21b2
3 changed files with 16 additions and 0 deletions
+11
View File
@@ -210,6 +210,17 @@ module Gollum
tree_list(treeish || 'master')
end
# Fill an array with a list of pages.
#
# ref - A String ref that is either a commit SHA or references one.
#
# Returns a flat Array of Gollum::Page instances.
def size(ref = nil)
tree_map_for(ref || 'master').inject(0) do |num, entry|
num + (@page_class.valid_page_name?(entry.name) ? 1 : 0)
end
end
# Public: All of the versions that have touched the Page.
#
# options - The options Hash: