2011-11-20 21:32:12 +01:00
|
|
|
class Tree
|
2012-04-21 00:26:22 +02:00
|
|
|
include Linguist::BlobHelper
|
2011-11-20 21:32:12 +01:00
|
|
|
attr_accessor :path, :tree, :project, :ref
|
|
|
|
|
|
|
|
delegate :contents,
|
|
|
|
:basename,
|
|
|
|
:name,
|
|
|
|
:data,
|
2011-11-21 07:16:10 +01:00
|
|
|
:mime_type,
|
2011-12-20 21:47:09 +01:00
|
|
|
:mode,
|
|
|
|
:size,
|
2011-11-20 21:32:12 +01:00
|
|
|
:text?,
|
|
|
|
:colorize,
|
2012-08-11 00:07:50 +02:00
|
|
|
to: :tree
|
2011-11-20 21:32:12 +01:00
|
|
|
|
|
|
|
def initialize(raw_tree, project, ref = nil, path = nil)
|
|
|
|
@project, @ref, @path = project, ref, path,
|
|
|
|
@tree = if path
|
2012-09-11 13:18:14 +02:00
|
|
|
raw_tree / path.dup.force_encoding('ascii-8bit')
|
2011-11-20 21:32:12 +01:00
|
|
|
else
|
|
|
|
raw_tree
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def is_blob?
|
|
|
|
tree.is_a?(Grit::Blob)
|
|
|
|
end
|
2011-11-22 13:50:47 +01:00
|
|
|
|
|
|
|
def empty?
|
|
|
|
data.blank?
|
|
|
|
end
|
2011-11-20 21:32:12 +01:00
|
|
|
end
|