properly define the public api
This commit is contained in:
+9
-7
@@ -1,23 +1,25 @@
|
||||
module Gollum
|
||||
class File
|
||||
attr_accessor :wiki, :blob, :version
|
||||
|
||||
# Initialize a file.
|
||||
#
|
||||
# wiki - The Gollum::Wiki in question.
|
||||
#
|
||||
# Returns a newly initialized Gollum::File.
|
||||
def initialize(wiki)
|
||||
self.wiki = wiki
|
||||
@wiki = wiki
|
||||
@blob = nil
|
||||
end
|
||||
|
||||
# The raw contents of the page.
|
||||
#
|
||||
# Returns the String data.
|
||||
def raw_data
|
||||
self.blob.data rescue nil
|
||||
@blob.data rescue nil
|
||||
end
|
||||
|
||||
# The Grit::Commit version of the file.
|
||||
attr_reader :version
|
||||
|
||||
#########################################################################
|
||||
#
|
||||
# Private
|
||||
@@ -31,10 +33,10 @@ module Gollum
|
||||
#
|
||||
# Returns a Gollum::File or nil if the file could not be found.
|
||||
def find(name, version)
|
||||
commit = self.wiki.repo.commit(version)
|
||||
commit = @wiki.repo.commit(version)
|
||||
if blob = commit.tree / name
|
||||
self.blob = blob
|
||||
self.version = commit
|
||||
@blob = blob
|
||||
@version = commit
|
||||
self
|
||||
else
|
||||
nil
|
||||
|
||||
Reference in New Issue
Block a user