Class: GitDataReferences
- Inherits:
-
Object
- Object
- GitDataReferences
- Defined in:
- lib/github/gitdata/gitdata_references.rb
Instance Attribute Summary collapse
-
#github ⇒ Object
Returns the value of attribute github.
Instance Method Summary collapse
- #createReference(repo, ref, sha, user = nil) ⇒ Object
- #editReference(repo, sha, force = FALSE, user = nil) ⇒ Object
- #getReference(repo, ref, user = nil) ⇒ Object
- #getReferences(repo, subnamespace = nil, user = nil) ⇒ Object
-
#initialize(github) ⇒ GitDataReferences
constructor
A new instance of GitDataReferences.
Constructor Details
#initialize(github) ⇒ GitDataReferences
Returns a new instance of GitDataReferences.
4 5 6 |
# File 'lib/github/gitdata/gitdata_references.rb', line 4 def initialize(github) @github = github end |
Instance Attribute Details
#github ⇒ Object
Returns the value of attribute github.
2 3 4 |
# File 'lib/github/gitdata/gitdata_references.rb', line 2 def github @github end |
Instance Method Details
#createReference(repo, ref, sha, user = nil) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/github/gitdata/gitdata_references.rb', line 23 def createReference(repo, ref, sha, user=nil) username = user == nil ? @github.username : user params = { :ref => ref, :sha => sha } data = params.to_json @github.post('repos/%s/%s/git/refs' % [username, repo], data) end |
#editReference(repo, sha, force = FALSE, user = nil) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/github/gitdata/gitdata_references.rb', line 33 def editReference(repo, sha, force=FALSE, user=nil) username = user == nil ? @github.username : user params = { :sha => sha, :force => force } data = params.to_json @github.patch('repos/%s/%s/git/refs' % [username, repo], data) end |
#getReference(repo, ref, user = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/github/gitdata/gitdata_references.rb', line 8 def getReference(repo, ref, user=nil) username = user == nil ? @github.username : user @github.get( 'repos/%s/%s/git/refs/%s' % [username, repo, ref]) def getReferences(repo, subnamespace=nil, user=nil) username = user == nil ? @github.username : user url = 'repos/%s/%s/git/refs' % [repo, username] if subnamespace url = subnamespace[0] == '/' ? '%s/%s' % [url, subnamespace] : '%s/%s/' % [url, subnamespace] end @github.get(url) end def createReference(repo, ref, sha, user=nil) username = user == nil ? @github.username : user params = { :ref => ref, :sha => sha } data = params.to_json @github.post('repos/%s/%s/git/refs' % [username, repo], data) end def editReference(repo, sha, force=FALSE, user=nil) username = user == nil ? @github.username : user params = { :sha => sha, :force => force } data = params.to_json @github.patch('repos/%s/%s/git/refs' % [username, repo], data) end end |
#getReferences(repo, subnamespace = nil, user = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/github/gitdata/gitdata_references.rb', line 13 def getReferences(repo, subnamespace=nil, user=nil) username = user == nil ? @github.username : user url = 'repos/%s/%s/git/refs' % [repo, username] if subnamespace url = subnamespace[0] == '/' ? '%s/%s' % [url, subnamespace] : '%s/%s/' % [url, subnamespace] end @github.get(url) end |