Class: Gollum::File
- Inherits:
-
Object
- Object
- Gollum::File
- Defined in:
- lib/gollum/file.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Public: The String path of the file.
-
#version ⇒ Object
readonly
Public: The Grit::Commit version of the file.
Instance Method Summary collapse
-
#find(name, version) ⇒ Object
Find a file in the given Gollum repo.
-
#initialize(wiki) ⇒ File
constructor
Public: Initialize a file.
-
#mime_type ⇒ Object
Public: The String mime type of the file.
-
#name ⇒ Object
Public: The on-disk filename of the file.
-
#raw_data ⇒ Object
Public: The raw contents of the page.
Constructor Details
#initialize(wiki) ⇒ File
Public: Initialize a file.
wiki - The Gollum::Wiki in question.
Returns a newly initialized Gollum::File.
10 11 12 13 14 |
# File 'lib/gollum/file.rb', line 10 def initialize(wiki) @wiki = wiki @blob = nil @path = nil end |
Instance Attribute Details
#path ⇒ Object (readonly)
Public: The String path of the file.
34 35 36 |
# File 'lib/gollum/file.rb', line 34 def path @path end |
#version ⇒ Object (readonly)
Public: The Grit::Commit version of the file.
31 32 33 |
# File 'lib/gollum/file.rb', line 31 def version @version end |
Instance Method Details
#find(name, version) ⇒ Object
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.
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/gollum/file.rb', line 53 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 |
#mime_type ⇒ Object
Public: The String mime type of the file.
37 38 39 |
# File 'lib/gollum/file.rb', line 37 def mime_type @blob.mime_type end |
#name ⇒ Object
Public: The on-disk filename of the file.
Returns the String name.
19 20 21 |
# File 'lib/gollum/file.rb', line 19 def name @blob && @blob.name end |
#raw_data ⇒ Object
Public: The raw contents of the page.
Returns the String data.
26 27 28 |
# File 'lib/gollum/file.rb', line 26 def raw_data @blob && @blob.data end |