Class: Gitlab::Git::Blob

Inherits:
Object
  • Object
show all
Includes:
Linguist::BlobHelper
Defined in:
lib/gitlab_git/blob.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository, sha, ref, path) ⇒ Blob

Returns a new instance of Blob.



8
9
10
11
12
13
# File 'lib/gitlab_git/blob.rb', line 8

def initialize(repository, sha, ref, path)
  @repository, @sha, @ref = repository, sha, ref

  @commit = @repository.commit(sha)
  @raw_blob = @repository.tree(@commit, path)
end

Instance Attribute Details

#raw_blobObject

Returns the value of attribute raw_blob.



6
7
8
# File 'lib/gitlab_git/blob.rb', line 6

def raw_blob
  @raw_blob
end

Instance Method Details

#dataObject



15
16
17
18
19
20
21
# File 'lib/gitlab_git/blob.rb', line 15

def data
  if raw_blob and raw_blob.respond_to?('data')
    raw_blob.data
  else
    nil
  end
end

#empty?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/gitlab_git/blob.rb', line 31

def empty?
  !data || data == ''
end

#exists?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/gitlab_git/blob.rb', line 27

def exists?
  raw_blob
end

#modeObject



35
36
37
# File 'lib/gitlab_git/blob.rb', line 35

def mode
  raw_blob.mode
end

#nameObject



23
24
25
# File 'lib/gitlab_git/blob.rb', line 23

def name
  raw_blob.name
end

#sizeObject



39
40
41
# File 'lib/gitlab_git/blob.rb', line 39

def size
  raw_blob.size
end