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',
'linguist-detectable']
- GIT_ATTR_OPTS =
DEPRECATED: use Linguist::Source::RuggedRepository::GIT_ATTR_OPTS instead
Linguist::Source::RuggedRepository::GIT_ATTR_OPTS
- GIT_ATTR_FLAGS =
DEPRECATED: use Linguist::Source::RuggedRepository::GIT_ATTR_FLAGS instead
Linguist::Source::RuggedRepository::GIT_ATTR_FLAGS
- 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?, #encoded_newlines_re, #encoding, #extname, #first_lines, #high_ratio_of_long_lines?, #image?, #include_in_language_stats?, #large?, #last_lines, #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.
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/linguist/lazy_blob.rb', line 31
def initialize(repo, oid, path, mode = nil)
@repository = if repo.is_a? Linguist::Source::Repository
repo
else
Linguist::Source::RuggedRepository.new(repo)
end
@oid = oid
@path = path
@mode = mode
@data = nil
end
|
Instance Attribute Details
#mode ⇒ Object
Returns the value of attribute mode.
27
28
29
|
# File 'lib/linguist/lazy_blob.rb', line 27
def mode
@mode
end
|
#oid ⇒ Object
Returns the value of attribute oid.
25
26
27
|
# File 'lib/linguist/lazy_blob.rb', line 25
def oid
@oid
end
|
#path ⇒ Object
Also known as:
name
Returns the value of attribute path.
26
27
28
|
# File 'lib/linguist/lazy_blob.rb', line 26
def path
@path
end
|
#repository ⇒ Object
Returns the value of attribute repository.
24
25
26
|
# File 'lib/linguist/lazy_blob.rb', line 24
def repository
@repository
end
|
Instance Method Details
#cleanup! ⇒ Object
105
106
107
|
# File 'lib/linguist/lazy_blob.rb', line 105
def cleanup!
@data.clear if @data
end
|
#data ⇒ Object
90
91
92
93
|
# File 'lib/linguist/lazy_blob.rb', line 90
def data
load_blob!
@data
end
|
#detectable? ⇒ Boolean
82
83
84
85
86
87
88
|
# File 'lib/linguist/lazy_blob.rb', line 82
def detectable?
if not git_attributes['linguist-detectable'].nil?
boolean_attribute(git_attributes['linguist-detectable'])
else
nil
end
end
|
#documentation? ⇒ Boolean
48
49
50
51
52
53
54
|
# File 'lib/linguist/lazy_blob.rb', line 48
def documentation?
if not git_attributes['linguist-documentation'].nil?
boolean_attribute(git_attributes['linguist-documentation'])
else
super
end
end
|
#generated? ⇒ Boolean
56
57
58
59
60
61
62
|
# File 'lib/linguist/lazy_blob.rb', line 56
def generated?
if not git_attributes['linguist-generated'].nil?
boolean_attribute(git_attributes['linguist-generated'])
else
super
end
end
|
#git_attributes ⇒ Object
44
45
46
|
# File 'lib/linguist/lazy_blob.rb', line 44
def git_attributes
@git_attributes ||= repository.load_attributes_for_path(name, GIT_ATTR)
end
|
#language ⇒ Object
72
73
74
75
76
77
78
79
80
|
# File 'lib/linguist/lazy_blob.rb', line 72
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
95
96
97
98
|
# File 'lib/linguist/lazy_blob.rb', line 95
def size
load_blob!
@size
end
|
#symlink? ⇒ Boolean
100
101
102
103
|
# File 'lib/linguist/lazy_blob.rb', line 100
def symlink?
false
end
|
#vendored? ⇒ Boolean
64
65
66
67
68
69
70
|
# File 'lib/linguist/lazy_blob.rb', line 64
def vendored?
if not git_attributes['linguist-vendored'].nil?
boolean_attribute(git_attributes['linguist-vendored'])
else
super
end
end
|