class Dandelion::Tree

Constants

FILEMODE_BLOB

github.com/libgit2/libgit2/blob/development/include/git2/types.h

FILEMODE_BLOB_EXECUTABLE

Attributes

commit[R]

Public Class Methods

new(repo, commit) click to toggle source
# File lib/dandelion/tree.rb, line 10
def initialize(repo, commit)
  @repo = repo
  @commit = commit
end

Public Instance Methods

blob?(path) click to toggle source
# File lib/dandelion/tree.rb, line 19
def blob?(path)
  mode = filemode(path)
  mode == FILEMODE_BLOB || mode == FILEMODE_BLOB_EXECUTABLE
end
data(path) click to toggle source
# File lib/dandelion/tree.rb, line 24
def data(path)
  if blob?(path) || symlink?(path)
    obj = object(path)
    blob_content(obj)
  else
    # TODO
    nil
  end
end

Private Instance Methods

blob_content(object) click to toggle source
# File lib/dandelion/tree.rb, line 49
def blob_content(object)
  object.read_raw.data
end
filemode(path) click to toggle source
# File lib/dandelion/tree.rb, line 40
def filemode(path)
  info(path)[:filemode]
end
info(path) click to toggle source
# File lib/dandelion/tree.rb, line 36
def info(path)
  @commit.tree.path(path)
end
object(path) click to toggle source
# File lib/dandelion/tree.rb, line 44
def object(path)
  oid = info(path)[:oid]
  @repo.lookup(oid)
end