Class: Fuselage::Tree

Inherits:
Base
  • Object
show all
Defined in:
lib/fuselage/tree.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

#modeObject

Returns the value of attribute mode.



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

def mode
  @mode
end

#pathObject

Returns the value of attribute path.



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

def path
  @path
end

#shaObject

Returns the value of attribute sha.



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

def sha
  @sha
end

#treeObject

Returns the value of attribute tree.



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

def tree
  @tree
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

Class Method Details

.create(repo, tree_hashes = [], options = {}) ⇒ Object

Create a tree

Tree Hash:

:path => 'file',
:mode => '100644',    refer to http://developer.github.com/v3/git/trees/ for modes.
:type => 'commit',    values: 'commit', 'tree', and 'blob'. 
:sha => '45f6d8e74e145b910be4e15f67ef3892fe7abb26'
  or 
:content => 'Some UTF-8 Encoded Content'

Options:

:type,    values: 'commit', 'tree', and 'blob'. default is commit
:tagger
   :name
   :date
   :email


39
40
41
42
43
44
# File 'lib/fuselage/tree.rb', line 39

def self.create(repo, tree_hashes=[], options={})
  raise AuthenticationRequired unless Api.authenticated
  params = {:tree => tree_hashes }.merge(options)
  user = User.current.
  Tree.new(post("/repos/#{user}/#{repo}/git/trees", params))
end

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

Find a tree

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


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

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

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



16
17
18
19
20
# File 'lib/fuselage/tree.rb', line 16

def self.find_recursive(repo, sha, user=nil)
  raise AuthenticationRequired unless Api.authenticated
  user ||= User.current.
  Commit.new(get("/repos/#{user}/#{repo}/git/trees/#{sha}", {:recursive => 1}))
end