Class: Gitlab::Git::Blob
- Inherits:
-
Object
- Object
- Gitlab::Git::Blob
- Includes:
- Linguist::BlobHelper
- Defined in:
- lib/gitlab_git/blob.rb
Instance Attribute Summary collapse
-
#commit_id ⇒ Object
Returns the value of attribute commit_id.
-
#data ⇒ Object
Returns the value of attribute data.
-
#id ⇒ Object
Returns the value of attribute id.
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#name ⇒ Object
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
-
#size ⇒ Object
Returns the value of attribute size.
Class Method Summary collapse
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(options) ⇒ Blob
constructor
A new instance of Blob.
Constructor Details
#initialize(options) ⇒ Blob
Returns a new instance of Blob.
27 28 29 30 31 |
# File 'lib/gitlab_git/blob.rb', line 27 def initialize() %w(id name path size data mode commit_id).each do |key| self.send("#{key}=", [key.to_sym]) end end |
Instance Attribute Details
#commit_id ⇒ Object
Returns the value of attribute commit_id.
6 7 8 |
# File 'lib/gitlab_git/blob.rb', line 6 def commit_id @commit_id end |
#data ⇒ Object
Returns the value of attribute data.
6 7 8 |
# File 'lib/gitlab_git/blob.rb', line 6 def data @data end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/gitlab_git/blob.rb', line 6 def id @id end |
#mode ⇒ Object
Returns the value of attribute mode.
6 7 8 |
# File 'lib/gitlab_git/blob.rb', line 6 def mode @mode end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/gitlab_git/blob.rb', line 6 def name @name end |
#path ⇒ Object
Returns the value of attribute path.
6 7 8 |
# File 'lib/gitlab_git/blob.rb', line 6 def path @path end |
#size ⇒ Object
Returns the value of attribute size.
6 7 8 |
# File 'lib/gitlab_git/blob.rb', line 6 def size @size end |
Class Method Details
.find(repository, sha, path) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gitlab_git/blob.rb', line 9 def find(repository, sha, path) commit = Commit.find(repository, sha) grit_blob = commit.tree / path if grit_blob.kind_of?(Grit::Blob) Blob.new( id: grit_blob.id, name: grit_blob.name, size: grit_blob.size, data: grit_blob.data, mode: grit_blob.mode, path: path, commit_id: sha, ) end end |
Instance Method Details
#empty? ⇒ Boolean
33 34 35 |
# File 'lib/gitlab_git/blob.rb', line 33 def empty? !data || data == '' end |