Add TreeController and spec

This commit is contained in:
Robert Speicher 2012-09-17 12:38:59 -04:00
parent 884eb73297
commit e33cbb9b42
4 changed files with 100 additions and 3 deletions

View file

@ -1,5 +1,5 @@
class Tree
include Linguist::BlobHelper
include Linguist::BlobHelper
attr_accessor :path, :tree, :project, :ref
delegate :contents,
@ -14,8 +14,8 @@ class Tree
to: :tree
def initialize(raw_tree, project, ref = nil, path = nil)
@project, @ref, @path = project, ref, path,
@tree = if path
@project, @ref, @path = project, ref, path
@tree = if path.present?
raw_tree / path.dup.force_encoding('ascii-8bit')
else
raw_tree
@ -26,6 +26,10 @@ class Tree
tree.is_a?(Grit::Blob)
end
def invalid?
tree.nil?
end
def empty?
data.blank?
end