add Gollum::File
This commit is contained in:
@@ -267,18 +267,18 @@ Get a specific version of a given canonical page file:
|
|||||||
|
|
||||||
Get the latest version of a given static file:
|
Get the latest version of a given static file:
|
||||||
|
|
||||||
file = gollum.static_file('asset.js')
|
file = gollum.file('asset.js')
|
||||||
# => <Gollum::File>
|
# => <Gollum::File>
|
||||||
|
|
||||||
file.data
|
file.raw_data
|
||||||
# => "alert('hello');"
|
# => "alert('hello');"
|
||||||
|
|
||||||
file.version
|
file.version
|
||||||
# => <Gollum::Version>
|
# => <Grit::Commit>
|
||||||
|
|
||||||
Get a specific version of a given static file:
|
Get a specific version of a given static file:
|
||||||
|
|
||||||
gollum.static_file('asset.js', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
|
gollum.file('asset.js', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
|
||||||
|
|
||||||
Write a new version of a given canonical page file (the file will be created
|
Write a new version of a given canonical page file (the file will be created
|
||||||
if it does not already exist) and commit the change.
|
if it does not already exist) and commit the change.
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ require 'github/markup'
|
|||||||
# internal
|
# internal
|
||||||
require 'gollum/wiki'
|
require 'gollum/wiki'
|
||||||
require 'gollum/page'
|
require 'gollum/page'
|
||||||
|
require 'gollum/file'
|
||||||
|
|
||||||
module Gollum
|
module Gollum
|
||||||
VERSION = '0.0.1'
|
VERSION = '0.0.1'
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
module Gollum
|
||||||
|
class File
|
||||||
|
attr_accessor :wiki
|
||||||
|
|
||||||
|
# Initialize a file.
|
||||||
|
#
|
||||||
|
# wiki - The Gollum::Wiki in question.
|
||||||
|
#
|
||||||
|
# Returns a newly initialized Gollum::File.
|
||||||
|
def initialize(wiki)
|
||||||
|
self.wiki = wiki
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -21,5 +21,14 @@ module Gollum
|
|||||||
def page(name, version = 'master')
|
def page(name, version = 'master')
|
||||||
Page.new(self).find(name, version)
|
Page.new(self).find(name, version)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Get the static file for a given name.
|
||||||
|
#
|
||||||
|
# name - The full String pathname to the file.
|
||||||
|
#
|
||||||
|
# Returns a Gollum::File or nil if no matching file was found.
|
||||||
|
def file(name)
|
||||||
|
File.new(self).find(name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
require File.join(File.dirname(__FILE__), *%w[helper])
|
||||||
|
|
||||||
|
context "File" do
|
||||||
|
setup do
|
||||||
|
@wiki = Gollum::Wiki.new(testpath("examples/lotr.git"))
|
||||||
|
end
|
||||||
|
|
||||||
|
test "new file" do
|
||||||
|
file = Gollum::File.new(@wiki)
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user