implement Page.version

This commit is contained in:
Tom Preston-Werner
2010-04-11 11:32:09 -06:00
parent c37204e42a
commit 6c1b65158a
3 changed files with 9 additions and 2 deletions
+1
View File
@@ -5,6 +5,7 @@ require 'github/markup'
# internal
require 'gollum/wiki'
require 'gollum/page'
require 'gollum/version'
module Gollum
VERSION = '0.0.1'
+7 -2
View File
@@ -2,7 +2,7 @@ module Gollum
class Page
VALID_PAGE_RE = /^(.+)\.(md|mkdn?|mdown|markdown|textile|rdoc|org|re?st(\.txt)?|asciidoc|pod|\d)$/i
attr_accessor :wiki, :blob
attr_accessor :wiki, :blob, :version
# Initialize a page.
#
@@ -79,7 +79,12 @@ module Gollum
# Returns a Gollum::Page or nil if the page could not be found.
def find(name)
commit = self.wiki.repo.commits.first
find_page_in_tree(commit.tree, name)
if page = find_page_in_tree(commit.tree, name)
page.version = Version.new(commit)
page
else
nil
end
end
# private
+1
View File
@@ -17,6 +17,7 @@ context "Page" do
assert page.raw_data =~ /^# Bilbo Baggins\n\nBilbo Baggins/
assert page.formatted_data =~ /<h1>Bilbo Baggins<\/h1>\n\n<p>Bilbo Baggins/
assert_equal :markdown, page.format
assert_equal 'df26e61e707116f81ebc6b935ec6d1676b7e96c4', page.version.id
end
test "no page match" do