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.



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

def initialize(repo, dir, name, sha, mode)
  super(repo, dir, name)
  @sha, @mode = sha, (mode & 0100) == 0 ? 0644 : 0755
end

Instance Attribute Details

#modeObject (readonly)

Returns the value of attribute mode.



6
7
8
# File 'lib/git_dump/entry.rb', line 6

def mode
  @mode
end

#shaObject (readonly)

Returns the value of attribute sha.



6
7
8
# File 'lib/git_dump/entry.rb', line 6

def sha
  @sha
end

Instance Method Details

#inspectObject



27
28
29
# File 'lib/git_dump/entry.rb', line 27

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

#open(&block) ⇒ Object

Pipe for reading data



13
14
15
# File 'lib/git_dump/entry.rb', line 13

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

#readObject

Data



18
19
20
# File 'lib/git_dump/entry.rb', line 18

def read
  repo.blob_read(sha)
end

#write_to(path) ⇒ Object

Write to path



23
24
25
# File 'lib/git_dump/entry.rb', line 23

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