class Linguist::LazyBlob
Constants
- GIT_ATTR
- GIT_ATTR_FLAGS
- GIT_ATTR_OPTS
- MAX_SIZE
Attributes
mode[R]
name[R]
oid[R]
path[R]
repository[R]
Public Class Methods
new(repo, oid, path, mode = nil)
click to toggle source
# File lib/linguist/lazy_blob.rb, line 26 def initialize(repo, oid, path, mode = nil) @repository = repo @oid = oid @path = path @mode = mode @data = nil end
Public Instance Methods
cleanup!()
click to toggle source
# File lib/linguist/lazy_blob.rb, line 83 def cleanup! @data.clear if @data end
data()
click to toggle source
# File lib/linguist/lazy_blob.rb, line 73 def data load_blob! @data end
documentation?()
click to toggle source
Calls superclass method
Linguist::BlobHelper#documentation?
# File lib/linguist/lazy_blob.rb, line 39 def documentation? if attr = git_attributes['linguist-documentation'] boolean_attribute(attr) else super end end
generated?()
click to toggle source
Calls superclass method
Linguist::BlobHelper#generated?
# File lib/linguist/lazy_blob.rb, line 47 def generated? if attr = git_attributes['linguist-generated'] boolean_attribute(attr) else super end end
git_attributes()
click to toggle source
# File lib/linguist/lazy_blob.rb, line 34 def git_attributes @git_attributes ||= repository.fetch_attributes( name, GIT_ATTR, GIT_ATTR_FLAGS) end
language()
click to toggle source
Calls superclass method
Linguist::BlobHelper#language
# File lib/linguist/lazy_blob.rb, line 63 def language return @language if defined?(@language) @language = if lang = git_attributes['linguist-language'] Language.find_by_alias(lang) else super end end
size()
click to toggle source
# File lib/linguist/lazy_blob.rb, line 78 def size load_blob! @size end
vendored?()
click to toggle source
Calls superclass method
Linguist::BlobHelper#vendored?
# File lib/linguist/lazy_blob.rb, line 55 def vendored? if attr = git_attributes['linguist-vendored'] return boolean_attribute(attr) else super end end
Protected Instance Methods
boolean_attribute(attribute)
click to toggle source
Returns true if the attribute is present and not the string “false”.
# File lib/linguist/lazy_blob.rb, line 90 def boolean_attribute(attribute) attribute != "false" end
load_blob!()
click to toggle source
# File lib/linguist/lazy_blob.rb, line 94 def load_blob! @data, @size = Rugged::Blob.to_buffer(repository, oid, MAX_SIZE) if @data.nil? end