Class: Dandelion::Tree

Inherits:
Object
  • Object
show all
Defined in:
lib/dandelion/tree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo, commit) ⇒ Tree

Returns a new instance of Tree.



5
6
7
8
# File 'lib/dandelion/tree.rb', line 5

def initialize(repo, commit)
  @repo = repo
  @commit = commit
end

Instance Attribute Details

#commitObject (readonly)

Returns the value of attribute commit.



3
4
5
# File 'lib/dandelion/tree.rb', line 3

def commit
  @commit
end

Instance Method Details

#data(path) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/dandelion/tree.rb', line 10

def data(path)
  object = @commit.tree
  info = {}

  path.split('/').each do |name|
    info = object[name]
    return nil unless info
    return nil unless info[:type]

    object = @repo.lookup(info[:oid])
    return nil unless object
  end

  content(info, object)
end