Class: GitDump::Entry

Inherits:
PathObject show all
Defined in:
lib/git_dump/entry.rb

Overview

Entry at path

Instance Attribute Summary collapse

Attributes inherited from PathObject

#name, #path, #repo

Instance Method Summary collapse

Constructor Details

#initialize(repo, dir, name, sha, mode) ⇒ Entry

Returns a new instance of Entry.



9
10
11
12
# File 'lib/git_dump/entry.rb', line 9

def initialize(repo, dir, name, sha, mode)
  super(repo, dir, name)
  @sha, @mode = sha, (mode & 0o100) == 0 ? 0o644 : 0o755
end

Instance Attribute Details

#modeObject (readonly)

Returns the value of attribute mode.



8
9
10
# File 'lib/git_dump/entry.rb', line 8

def mode
  @mode
end

#shaObject (readonly)

Returns the value of attribute sha.



8
9
10
# File 'lib/git_dump/entry.rb', line 8

def sha
  @sha
end

Instance Method Details

#inspectObject



34
35
36
# File 'lib/git_dump/entry.rb', line 34

def inspect
  "#<#{self.class} sha=#{@sha} mode=#{format '%03o', @mode}>"
end

#open(&block) ⇒ Object

Pipe for reading data



20
21
22
# File 'lib/git_dump/entry.rb', line 20

def open(&block)
  repo.blob_pipe(sha, &block)
end

#readObject

Data



25
26
27
# File 'lib/git_dump/entry.rb', line 25

def read
  repo.blob_read(sha)
end

#sizeObject

Get size



15
16
17
# File 'lib/git_dump/entry.rb', line 15

def size
  @size ||= repo.size(sha)
end

#write_to(path) ⇒ Object

Write to path



30
31
32
# File 'lib/git_dump/entry.rb', line 30

def write_to(path)
  repo.blob_unpack(sha, path, mode)
end