2011-11-20 15:32:12 -05:00
|
|
|
class Tree
|
|
|
|
attr_accessor :path, :tree, :project, :ref
|
|
|
|
|
|
|
|
delegate :contents,
|
|
|
|
:basename,
|
|
|
|
:name,
|
|
|
|
:data,
|
2011-11-21 01:16:10 -05:00
|
|
|
:mime_type,
|
2011-11-20 15:32:12 -05:00
|
|
|
:text?,
|
|
|
|
:colorize,
|
|
|
|
:to => :tree
|
|
|
|
|
|
|
|
def initialize(raw_tree, project, ref = nil, path = nil)
|
|
|
|
@project, @ref, @path = project, ref, path,
|
|
|
|
@tree = if path
|
|
|
|
raw_tree / path
|
|
|
|
else
|
|
|
|
raw_tree
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def is_blob?
|
|
|
|
tree.is_a?(Grit::Blob)
|
|
|
|
end
|
2011-11-22 07:50:47 -05:00
|
|
|
|
|
|
|
def empty?
|
|
|
|
data.blank?
|
|
|
|
end
|
2011-11-20 15:32:12 -05:00
|
|
|
end
|