Class: Fuselage::Blob

Inherits:
Base
  • Object
show all
Defined in:
lib/fuselage/blob.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#api

Class Method Summary collapse

Methods inherited from Base

delete_method, get, #initialize, post

Constructor Details

This class inherits a constructor from Fuselage::Base

Instance Attribute Details

#contentObject

Returns the value of attribute content.



4
5
6
# File 'lib/fuselage/blob.rb', line 4

def content
  @content
end

#encodingObject

Returns the value of attribute encoding.



4
5
6
# File 'lib/fuselage/blob.rb', line 4

def encoding
  @encoding
end

#shaObject

Returns the value of attribute sha.



4
5
6
# File 'lib/fuselage/blob.rb', line 4

def sha
  @sha
end

Class Method Details

.create(repo, content) ⇒ Object

Create a blob

Content must be in utf-8 encoding. TODO: Add suport for base-64.

examples:
  Blob.create('cockpit', 'Some really cool data.')


23
24
25
26
27
28
# File 'lib/fuselage/blob.rb', line 23

def self.create(repo, content)
  raise AuthenticationRequired unless Api.authenticated
  params = {:content => content, :encoding => 'utf-8'}
  user = User.current.
  Blob.new(post("/repos/#{user}/#{repo}/git/blobs", params))
end

.find(repo, sha, user = nil) ⇒ Object

Find a blob

examples:
  Blob.find('cockpit', '45f6d8e74e145b910be4e15f67ef3892fe7abb26')


10
11
12
13
14
# File 'lib/fuselage/blob.rb', line 10

def self.find(repo, sha, user=nil)
  raise AuthenticationRequired unless Api.authenticated
  user ||= User.current.
  Blob.new(get("/repos/#{user}/#{repo}/git/blobs/#{sha}").merge(:sha => sha))
end