Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-04-02 23:37:20 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-04-02 23:37:20 +0400
commit03f41e2820d76d272aa7357cf726b5d131bb80e0 (patch)
tree8f9b317572899049d43de0d72194b9b50da1648e /lib/gitlab/git/blob.rb
parent0c5795a49726402d2f2751d8b05d5bbb9dd23511 (diff)
Gitlab::Git::Tree & Blob added
Diffstat (limited to 'lib/gitlab/git/blob.rb')
-rw-r--r--lib/gitlab/git/blob.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/gitlab/git/blob.rb b/lib/gitlab/git/blob.rb
new file mode 100644
index 00000000000..405cbddad90
--- /dev/null
+++ b/lib/gitlab/git/blob.rb
@@ -0,0 +1,30 @@
+module Gitlab
+ module Git
+ class Blob
+ include Linguist::BlobHelper
+
+ attr_accessor :raw_blob
+
+ delegate :name, to: :raw_blob
+
+ def initialize(repository, sha, ref, path)
+ @repository, @sha, @ref = repository, sha, ref
+
+ @commit = @repository.commit(sha)
+ @raw_blob = @repository.tree(@commit, path)
+ end
+
+ def data
+ if raw_blob
+ raw_blob.data
+ else
+ nil
+ end
+ end
+
+ def exists?
+ @raw_blob
+ end
+ end
+ end
+end