Class: GitDataTrees
- Inherits:
-
Object
- Object
- GitDataTrees
- Defined in:
- lib/github/gitdata/gitdata_trees.rb
Instance Attribute Summary collapse
-
#github ⇒ Object
Returns the value of attribute github.
Instance Method Summary collapse
- #createTree(repo, tree, baseTree = nil, user = nil) ⇒ Object
- #getTree(repo, sha, recursive = FALSE, user = nil) ⇒ Object
-
#initialize(github) ⇒ GitDataTrees
constructor
A new instance of GitDataTrees.
Constructor Details
#initialize(github) ⇒ GitDataTrees
Returns a new instance of GitDataTrees.
4 5 6 |
# File 'lib/github/gitdata/gitdata_trees.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_trees.rb', line 2 def github @github end |
Instance Method Details
#createTree(repo, tree, baseTree = nil, user = nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/github/gitdata/gitdata_trees.rb', line 15 def createTree(repo, tree, baseTree=nil, user=nil) username = user == nil ? @github.username : user params = { :base_tree => baseTree, :tree => tree } params = @github.removeEmptyParams(params) data = params.to_json @github.post('repos/%s/%s/git/trees' % [username, repo], data) end |
#getTree(repo, sha, recursive = FALSE, user = nil) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/github/gitdata/gitdata_trees.rb', line 8 def getTree(repo, sha, recursive=FALSE, user=nil) username = user == nil ? @github.username : user url = 'repos/%s/%s/git/trees/%s' % [username, repo, sha] url = recursive ? '%s?recursive=1' % url : url @github.get(url) end |