class Gollum::Git::Blob
Attributes
id[R]
mode[R]
name[R]
Public Class Methods
create(repo, options)
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 55 def self.create(repo, options) blob = repo.git.lookup(options[:id]) self.new(blob, options) end
new(blob, options = {})
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 60 def initialize(blob, options = {}) @blob = blob @mode = options[:mode] @name = options[:name] @size = options[:size] @id = blob.oid end
Public Instance Methods
data()
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 68 def data @content ||= @blob.content end
is_symlink()
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 72 def is_symlink @mode == 0120000 end
mime_type()
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 76 def mime_type guesses = MIME::Types.type_for(self.name) rescue [] guesses.first ? guesses.first.simplified : DEFAULT_MIME_TYPE end
size()
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 81 def size @size || @blob.size end
symlink_target(base_path = nil)
click to toggle source
# File lib/rugged_adapter/git_layer_rugged.rb, line 85 def symlink_target(base_path = nil) target = data new_path = ::File.expand_path(::File.join('..', target), base_path) return new_path if ::File.file? new_path nil end