Add TreeController and spec
This commit is contained in:
parent
884eb73297
commit
e33cbb9b42
4 changed files with 100 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue