Class: Dandelion::Tree

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

Constant Summary collapse

FILEMODE_BLOB =
0100644
FILEMODE_BLOB_EXECUTABLE =
0100755
0120000

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo, commit) ⇒ Tree

Returns a new instance of Tree.



10
11
12
13
# File 'lib/dandelion/tree.rb', line 10

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

Instance Attribute Details

#commitObject (readonly)

Returns the value of attribute commit.



8
9
10
# File 'lib/dandelion/tree.rb', line 8

def commit
  @commit
end

Instance Method Details

#blob?(path) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
# File 'lib/dandelion/tree.rb', line 19

def blob?(path)
  mode = filemode(path)
  mode == FILEMODE_BLOB || mode == FILEMODE_BLOB_EXECUTABLE
end

#data(path) ⇒ Object



24
25
26
27
28
29
30
31
32
# 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

#symlink?(path) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/dandelion/tree.rb', line 15

def symlink?(path)
  filemode(path) == FILEMODE_SYMLINK
end