Class: Linguist::LazyBlob
- Inherits:
-
Object
- Object
- Linguist::LazyBlob
- Includes:
- BlobHelper
- Defined in:
- lib/linguist/lazy_blob.rb
Constant Summary collapse
- GIT_ATTR =
['linguist-documentation', 'linguist-language', 'linguist-vendored']
- 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
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#oid ⇒ Object
readonly
Returns the value of attribute oid.
-
#path ⇒ Object
(also: #name)
readonly
Returns the value of attribute path.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
Instance Method Summary collapse
- #data ⇒ Object
- #documentation? ⇒ Boolean
- #git_attributes ⇒ Object
-
#initialize(repo, oid, path, mode = nil) ⇒ LazyBlob
constructor
A new instance of LazyBlob.
- #language ⇒ Object
- #size ⇒ Object
- #vendored? ⇒ Boolean
Methods included from BlobHelper
#_mime_type, #binary?, #binary_mime_type?, #content_type, #csv?, #detect_encoding, #disposition, #empty?, #encoding, #extname, #generated?, #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
22 23 24 25 26 27 |
# File 'lib/linguist/lazy_blob.rb', line 22 def initialize(repo, oid, path, mode = nil) @repository = repo @oid = oid @path = path @mode = mode end |
Instance Attribute Details
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
18 19 20 |
# File 'lib/linguist/lazy_blob.rb', line 18 def mode @mode end |
#oid ⇒ Object (readonly)
Returns the value of attribute oid.
16 17 18 |
# File 'lib/linguist/lazy_blob.rb', line 16 def oid @oid end |
#path ⇒ Object (readonly) Also known as: name
Returns the value of attribute path.
17 18 19 |
# File 'lib/linguist/lazy_blob.rb', line 17 def path @path end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
15 16 17 |
# File 'lib/linguist/lazy_blob.rb', line 15 def repository @repository end |
Instance Method Details
#data ⇒ Object
60 61 62 63 |
# File 'lib/linguist/lazy_blob.rb', line 60 def data load_blob! @data end |
#documentation? ⇒ Boolean
42 43 44 45 46 47 48 |
# File 'lib/linguist/lazy_blob.rb', line 42 def documentation? if attr = git_attributes['linguist-documentation'] boolean_attribute(attr) else super end end |
#git_attributes ⇒ Object
29 30 31 32 |
# File 'lib/linguist/lazy_blob.rb', line 29 def git_attributes @git_attributes ||= repository.fetch_attributes( name, GIT_ATTR, GIT_ATTR_FLAGS) end |
#language ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/linguist/lazy_blob.rb', line 50 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
65 66 67 68 |
# File 'lib/linguist/lazy_blob.rb', line 65 def size load_blob! @size end |
#vendored? ⇒ Boolean
34 35 36 37 38 39 40 |
# File 'lib/linguist/lazy_blob.rb', line 34 def vendored? if attr = git_attributes['linguist-vendored'] return boolean_attribute(attr) else return super end end |