Class: Linguist::LazyBlob
- Inherits:
-
Object
- Object
- Linguist::LazyBlob
show all
- Includes:
- BlobHelper
- Defined in:
- lib/linguist/lazy_blob.rb
Constant Summary
collapse
- GIT_ATTR =
['linguist-documentation',
'linguist-language',
'linguist-vendored',
'linguist-generated']
- GIT_ATTR_OPTS =
{ :priority => [:index], :skip_system => true }
- GIT_ATTR_FLAGS =
Rugged::Repository::Attributes.parse_opts(GIT_ATTR_OPTS)
- MAX_SIZE =
128 * 1024
Constants included
from BlobHelper
BlobHelper::DETECTABLE_TYPES, BlobHelper::DocumentationRegexp, BlobHelper::MEGABYTE, BlobHelper::VendoredRegexp
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from BlobHelper
#_mime_type, #binary?, #binary_mime_type?, #content_type, #csv?, #detect_encoding, #disposition, #empty?, #encoding, #extname, #high_ratio_of_long_lines?, #image?, #include_in_language_stats?, #large?, #likely_binary?, #lines, #loc, #mime_type, #pdf?, #ruby_encoding, #safe_to_colorize?, #sloc, #solid?, #text?, #tm_scope, #viewable?
Constructor Details
#initialize(repo, oid, path, mode = nil) ⇒ LazyBlob
Returns a new instance of LazyBlob.
26
27
28
29
30
31
32
|
# 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
|
Instance Attribute Details
#mode ⇒ Object
Returns the value of attribute mode.
22
23
24
|
# File 'lib/linguist/lazy_blob.rb', line 22
def mode
@mode
end
|
#oid ⇒ Object
Returns the value of attribute oid.
20
21
22
|
# File 'lib/linguist/lazy_blob.rb', line 20
def oid
@oid
end
|
#path ⇒ Object
Also known as:
name
Returns the value of attribute path.
21
22
23
|
# File 'lib/linguist/lazy_blob.rb', line 21
def path
@path
end
|
#repository ⇒ Object
Returns the value of attribute repository.
19
20
21
|
# File 'lib/linguist/lazy_blob.rb', line 19
def repository
@repository
end
|
Instance Method Details
#cleanup! ⇒ Object
83
84
85
|
# File 'lib/linguist/lazy_blob.rb', line 83
def cleanup!
@data.clear if @data
end
|
#data ⇒ Object
73
74
75
76
|
# File 'lib/linguist/lazy_blob.rb', line 73
def data
load_blob!
@data
end
|
#documentation? ⇒ Boolean
39
40
41
42
43
44
45
|
# File 'lib/linguist/lazy_blob.rb', line 39
def documentation?
if attr = git_attributes['linguist-documentation']
boolean_attribute(attr)
else
super
end
end
|
#generated? ⇒ Boolean
47
48
49
50
51
52
53
|
# 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 ⇒ Object
34
35
36
37
|
# File 'lib/linguist/lazy_blob.rb', line 34
def git_attributes
@git_attributes ||= repository.fetch_attributes(
name, GIT_ATTR, GIT_ATTR_FLAGS)
end
|
#language ⇒ Object
63
64
65
66
67
68
69
70
71
|
# 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 ⇒ Object
78
79
80
81
|
# File 'lib/linguist/lazy_blob.rb', line 78
def size
load_blob!
@size
end
|
#vendored? ⇒ Boolean
55
56
57
58
59
60
61
|
# File 'lib/linguist/lazy_blob.rb', line 55
def vendored?
if attr = git_attributes['linguist-vendored']
return boolean_attribute(attr)
else
super
end
end
|