Class: Fuselage::Reference
Instance Attribute Summary collapse
-
#object ⇒ Object
Returns the value of attribute object.
-
#ref ⇒ Object
Returns the value of attribute ref.
-
#url ⇒ Object
Returns the value of attribute url.
Attributes inherited from Base
Class Method Summary collapse
- .create(repo, ref, sha) ⇒ Object
- .delete(repo, ref) ⇒ Object
-
.find(repo, ref, user = nil) ⇒ Object
Find a reference ref must have ‘heads/’ in front of branch name.
-
.find_all(repo, user = nil) ⇒ Object
Finds all the refs for a given repo.
- .update(repo, ref, sha, force = true, user = nil) ⇒ Object
Instance 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
#object ⇒ Object
Returns the value of attribute object.
4 5 6 |
# File 'lib/fuselage/reference.rb', line 4 def object @object end |
#ref ⇒ Object
Returns the value of attribute ref.
4 5 6 |
# File 'lib/fuselage/reference.rb', line 4 def ref @ref end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/fuselage/reference.rb', line 4 def url @url end |
Class Method Details
.create(repo, ref, sha) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/fuselage/reference.rb', line 27 def self.create(repo, ref, sha) raise AuthenticationRequired unless Api.authenticated params = {:ref => ref, :sha => sha} user = User.current.login Reference.new(post("/repos/#{user}/#{repo}/git/refs", params)) end |
.delete(repo, ref) ⇒ Object
41 42 43 44 45 |
# File 'lib/fuselage/reference.rb', line 41 def self.delete(repo, ref) raise AuthenticationRequired unless Api.authenticated user ||= User.current.login delete_method("/repos/#{user}/#{repo}/git/refs/#{ref}") end |
.find(repo, ref, user = nil) ⇒ Object
Find a reference
ref must have 'heads/' in front of branch name
examples:
Reference.find('cockpit', 'heads/master')
12 13 14 15 16 |
# File 'lib/fuselage/reference.rb', line 12 def self.find(repo, ref, user=nil) raise AuthenticationRequired unless Api.authenticated user ||= User.current.login Reference.new(get("/repos/#{user}/#{repo}/git/refs/#{ref}")) end |
.find_all(repo, user = nil) ⇒ Object
Finds all the refs for a given repo.
19 20 21 22 23 24 25 |
# File 'lib/fuselage/reference.rb', line 19 def self.find_all(repo, user=nil) raise AuthenticationRequired unless Api.authenticated user ||= User.current.login refs = [] get("/repos/#{user}/#{repo}/git/refs").each { |r| refs << Reference.new(r) } refs end |
.update(repo, ref, sha, force = true, user = nil) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/fuselage/reference.rb', line 34 def self.update(repo, ref, sha, force=true, user=nil) raise AuthenticationRequired unless Api.authenticated params = {:force => force, :sha => sha} user ||= User.current.login Reference.new(post("/repos/#{user}/#{repo}/git/refs/#{ref}", params)) end |
Instance Method Details
#sha ⇒ Object
47 48 49 |
# File 'lib/fuselage/reference.rb', line 47 def sha object['sha'] if object end |
#to_s ⇒ Object
51 52 53 |
# File 'lib/fuselage/reference.rb', line 51 def to_s ref end |