mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Missing file. Duh.
This commit is contained in:
37
lib/linguist/lazy_blob.rb
Normal file
37
lib/linguist/lazy_blob.rb
Normal file
@@ -0,0 +1,37 @@
|
||||
require 'linguist/blob_helper'
|
||||
require 'rugged'
|
||||
|
||||
module Linguist
|
||||
class LazyBlob
|
||||
include BlobHelper
|
||||
|
||||
MAX_SIZE = 128 * 1024
|
||||
|
||||
attr_reader :repository
|
||||
attr_reader :oid
|
||||
attr_reader :name
|
||||
attr_reader :mode
|
||||
|
||||
def initialize(repo, oid, name, mode = nil)
|
||||
@repository = repo
|
||||
@oid = oid
|
||||
@name = name
|
||||
@mode = mode
|
||||
end
|
||||
|
||||
def data
|
||||
load_blob!
|
||||
@data
|
||||
end
|
||||
|
||||
def size
|
||||
load_blob!
|
||||
@size
|
||||
end
|
||||
|
||||
protected
|
||||
def load_blob!
|
||||
@data, @size = Rugged::Blob.to_buffer(repository, oid, MAX_SIZE) if @data.nil?
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user