Sha256: b29444002a0a816f138a9eb829a1f8f7295e0a6b6a1fcc512be1c68b41feed95
Contents?: true
Size: 1.52 KB
Versions: 36
Compression:
Stored size: 1.52 KB
Contents
module Gollum class File Wiki.file_class = self # Public: Initialize a file. # # wiki - The Gollum::Wiki in question. # # Returns a newly initialized Gollum::File. def initialize(wiki) @wiki = wiki @blob = nil @path = nil end # Public: The on-disk filename of the file. # # Returns the String name. def name @blob && @blob.name end # Public: The raw contents of the page. # # Returns the String data. def raw_data @blob && @blob.data end # Public: The Grit::Commit version of the file. attr_reader :version # Public: The String path of the file. attr_reader :path # Public: The String mime type of the file. def mime_type @blob.mime_type end ######################################################################### # # Internal Methods # ######################################################################### # 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) 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 end end
Version data entries
36 entries across 36 versions & 6 rubygems