class DtkCommon::GitRepo::Adapter::Rugged::Tree

Public Class Methods

new(repo_branch,rugged_tree) click to toggle source
# File lib/git_repo/adapters/rugged/tree.rb, line 21
def initialize(repo_branch,rugged_tree)
  super(repo_branch)
  @rugged_tree = rugged_tree
end

Public Instance Methods

get_file_content(path) click to toggle source
# File lib/git_repo/adapters/rugged/tree.rb, line 26
def get_file_content(path)
  if blob = get_blob(path)
    blob.content
  end
end
list_files() click to toggle source
# File lib/git_repo/adapters/rugged/tree.rb, line 32
def list_files()
  ret = Array.new
  @rugged_tree.walk_blobs do |root,entry|
    ret << "#{root}#{entry[:name]}"
  end
  ret
end

Private Instance Methods

get_blob(path) click to toggle source
# File lib/git_repo/adapters/rugged/tree.rb, line 41
def get_blob(path)
  ret = nil
  dir = ""; file_part = path
  if path =~ /(.+\/)([^\/]+$)/
    dir = $1; file_part = $2
  end
  @rugged_tree.walk_blobs do |root,entry|
    if root == dir and entry[:name] == file_part
      return Blob.new(@repo_branch,entry)
    end
  end
  ret
end