Public: The String path of the file.
Public: The Grit::Commit version of the file.
Public: Initialize a file.
wiki - The Gollum::Wiki in question.
Returns a newly initialized Gollum::File.
# File lib/gollum-lib/file.rb, line 10 def initialize(wiki) @wiki = wiki @blob = nil @path = 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.
# File lib/gollum-lib/file.rb, line 89 def find(name, version) checked = name.downcase map = @wiki.tree_map_for(version) if entry = map.detect { |entry| entry.path.downcase == checked } @path = name @blob = entry.blob(@wiki.repo) @version = version.is_a?(Grit::Commit) ? version : @wiki.commit_for(version) self end end
Public: The String mime type of the file.
# File lib/gollum-lib/file.rb, line 61 def mime_type @blob.mime_type end
Public: The on-disk filename of the file.
Returns the String name.
# File lib/gollum-lib/file.rb, line 35 def name @blob && @blob.name end
Populate the File with information from the Blob.
blob - The Grit::Blob that contains the info. path - The String directory path of the file.
Returns the populated Gollum::File.
# File lib/gollum-lib/file.rb, line 71 def populate(blob, path=nil) @blob = blob @path = "#{path}/#{blob.name}"[1..-1] self end
Public: The raw contents of the page.
Returns the String data.
# File lib/gollum-lib/file.rb, line 43 def raw_data return nil unless @blob if !@wiki.repo.bare && @blob.is_symlink new_path = @blob.symlink_target(::File.join(@wiki.repo.path, '..', self.path)) return IO.read(new_path) if new_path end @blob.data end
Public: The url path required to reach this page within the repo.
Returns the String #url_path
# File lib/gollum-lib/file.rb, line 19 def url_path path = self.path path = path.sub(/\/[^\/]+$/, '/') if path.include?('/') path end