Sha256: dcfab5afe406fe8a397040d242b236d34685f2dd38827d9760cc5a79146c6971
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 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 ######################################################################### # # 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) sha = @wiki.ref_map[version] || version if pair = map.detect { |(path, _)| path.downcase == checked } @path = name @blob = Grit::Blob.create(@wiki.repo, :id => pair.last, :name => ::File.basename(@path)) @version = Grit::Commit.create(@wiki.repo, :id => sha) self end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tecnh-gollum-1.0.2.auth2 | lib/gollum/file.rb |
tecnh-gollum-1.0.2.auth | lib/gollum/file.rb |