implement File finding

This commit is contained in:
Tom Preston-Werner
2010-04-11 13:08:16 -06:00
parent 9307900b09
commit 2e328e6a83
9 changed files with 36 additions and 6 deletions
+24 -1
View File
@@ -1,6 +1,6 @@
module Gollum
class File
attr_accessor :wiki
attr_accessor :wiki, :blob
# Initialize a file.
#
@@ -10,5 +10,28 @@ module Gollum
def initialize(wiki)
self.wiki = wiki
end
# The raw contents of the page.
#
# Returns the String data.
def raw_data
self.blob.data rescue nil
end
# Find a file in the given Gollum repo.
#
# name - The full String path.
# version - The String version ID to find.
#
# Returns a Gollum::File or nil if the file could not be found.
def find(name, version)
commit = self.wiki.repo.commit(version)
if blob = commit.tree / name
self.blob = blob
self
else
nil
end
end
end
end