Class: Gitlab::Git::Tree
- Inherits:
-
Object
- Object
- Gitlab::Git::Tree
- Defined in:
- lib/gitlab_git/tree.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#path ⇒ Object
Returns the value of attribute path.
-
#raw_tree ⇒ Object
Returns the value of attribute raw_tree.
-
#ref ⇒ Object
Returns the value of attribute ref.
-
#repository ⇒ Object
Returns the value of attribute repository.
-
#sha ⇒ Object
Returns the value of attribute sha.
Instance Method Summary collapse
- #blobs ⇒ Object
- #empty? ⇒ Boolean
- #exists? ⇒ Boolean
-
#initialize(repository, sha, ref = nil, path = nil) ⇒ Tree
constructor
A new instance of Tree.
- #is_blob? ⇒ Boolean
- #readme ⇒ Object
- #trees ⇒ Object
- #up_dir? ⇒ Boolean
Constructor Details
#initialize(repository, sha, ref = nil, path = nil) ⇒ Tree
Returns a new instance of Tree.
6 7 8 9 10 11 12 13 14 |
# File 'lib/gitlab_git/tree.rb', line 6 def initialize(repository, sha, ref = nil, path = nil) @repository, @sha, @ref, @path = repository, sha, ref, path @path = nil if !@path || @path == '' # Load tree from repository @commit = @repository.commit(@sha) @raw_tree = @repository.tree(@commit, @path) end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/gitlab_git/tree.rb', line 4 def id @id end |
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/gitlab_git/tree.rb', line 4 def path @path end |
#raw_tree ⇒ Object
Returns the value of attribute raw_tree.
4 5 6 |
# File 'lib/gitlab_git/tree.rb', line 4 def raw_tree @raw_tree end |
#ref ⇒ Object
Returns the value of attribute ref.
4 5 6 |
# File 'lib/gitlab_git/tree.rb', line 4 def ref @ref end |
#repository ⇒ Object
Returns the value of attribute repository.
4 5 6 |
# File 'lib/gitlab_git/tree.rb', line 4 def repository @repository end |
#sha ⇒ Object
Returns the value of attribute sha.
4 5 6 |
# File 'lib/gitlab_git/tree.rb', line 4 def sha @sha end |
Instance Method Details
#blobs ⇒ Object
28 29 30 |
# File 'lib/gitlab_git/tree.rb', line 28 def blobs entries.select { |t| t.is_a?(Grit::Blob) } end |
#empty? ⇒ Boolean
20 21 22 |
# File 'lib/gitlab_git/tree.rb', line 20 def empty? trees.empty? && blobs.empty? end |
#exists? ⇒ Boolean
16 17 18 |
# File 'lib/gitlab_git/tree.rb', line 16 def exists? raw_tree end |
#is_blob? ⇒ Boolean
32 33 34 |
# File 'lib/gitlab_git/tree.rb', line 32 def is_blob? raw_tree.is_a?(Grit::Blob) end |
#readme ⇒ Object
40 41 42 |
# File 'lib/gitlab_git/tree.rb', line 40 def readme @readme ||= blobs.find { |c| c.name =~ /^readme/i } end |
#trees ⇒ Object
24 25 26 |
# File 'lib/gitlab_git/tree.rb', line 24 def trees entries.select { |t| t.is_a?(Grit::Tree) } end |
#up_dir? ⇒ Boolean
36 37 38 |
# File 'lib/gitlab_git/tree.rb', line 36 def up_dir? path && path != '' end |