decorators & tree model
This commit is contained in:
parent
6721ef01f4
commit
4bf4efe712
12 changed files with 120 additions and 29 deletions
2
app/models/commit.rb
Normal file
2
app/models/commit.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
class Commit
|
||||
end
|
24
app/models/tree.rb
Normal file
24
app/models/tree.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
class Tree
|
||||
attr_accessor :path, :tree, :project, :ref
|
||||
|
||||
delegate :contents,
|
||||
:basename,
|
||||
:name,
|
||||
:data,
|
||||
: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
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue