Class: Gitlab::Git::LfsPointerFile

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/git/lfs_pointer_file.rb

Constant Summary collapse

VERSION =
"https://git-lfs.github.com/spec/v1"
VERSION_LINE =
"version #{VERSION}"

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ LfsPointerFile

Returns a new instance of LfsPointerFile.


9
10
11
# File 'lib/gitlab/git/lfs_pointer_file.rb', line 9

def initialize(data)
  @data = data
end

Instance Method Details

#inspectObject


29
30
31
# File 'lib/gitlab/git/lfs_pointer_file.rb', line 29

def inspect
  "#<#{self.class}:#{object_id} @size=#{size}, @sha256=#{sha256.inspect}>"
end

#pointerObject


13
14
15
16
17
18
19
# File 'lib/gitlab/git/lfs_pointer_file.rb', line 13

def pointer
  @pointer ||= <<~FILE
    #{VERSION_LINE}
    oid sha256:#{sha256}
    size #{size}
  FILE
end

#sha256Object


25
26
27
# File 'lib/gitlab/git/lfs_pointer_file.rb', line 25

def sha256
  @sha256 ||= Digest::SHA256.hexdigest(@data)
end

#sizeObject


21
22
23
# File 'lib/gitlab/git/lfs_pointer_file.rb', line 21

def size
  @size ||= @data.bytesize
end