Class: GitHub::Repo

Inherits:
Base
  • Object
show all
Defined in:
lib/git_hub/repo.rb

Constant Summary collapse

GITHUB_SERVICES =
{
#[github]
#	user = user
#	token = token
#	:donate => {:path => '/edit/donate',  :inputs => ['paypal']}
#	homepage = homepage_url
#	webhooks => {:path => '/edit/postreceive_urls', :fields => []
#http://rdoc.info/projects/update, http://runcoderun.com/github, http://api.devver.net/github
#	basecamp = url, username, password, project, category
#	cia = true
#	campfire = subdomain, username, password, room, ssl, play_sound
#	email = [email protected]
#	fogbugz = cvssubmit_url, fb_version, fb_repoid
#	friendfeed = nickname, remotekey
#	irc = server, port, room, password, nick, ssl
#	jabber = user
#	lighthouse = subdomain, project_id, token, private
#	presently = subdomain, group_name, username, password
#	rubyforge = username, password, grupid
#	runcoderun = true
#	trac = url, token
#	twitter = username, password, digest
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

aliases_for, base_uri, #get, get, post, #post, request, #set_attributes, set_resource, #to_s

Constructor Details

#initialize(opts) ⇒ Repo

Returns a new instance of Repo.



35
36
37
38
39
40
41
42
# File 'lib/git_hub/repo.rb', line 35

def initialize(opts)
  super
  raise "Unable to initialize #{self.class} without user and name" unless @user && @name
  @url ||= "http://github.com/#{@user}/#{@name}"
  @type ||= "repo"
  @created = Time.parse(@created) unless !@created || @created.is_a?(Time)
  @pushed = Time.parse(@pushed) unless !@pushed ||@pushed.is_a?(Time)
end

Instance Attribute Details

#createdObject

Returns the value of attribute created.



29
30
31
# File 'lib/git_hub/repo.rb', line 29

def created
  @created
end

#descriptionObject

Returns the value of attribute description.



29
30
31
# File 'lib/git_hub/repo.rb', line 29

def description
  @description
end

#followersObject

Returns the value of attribute followers.



29
30
31
# File 'lib/git_hub/repo.rb', line 29

def followers
  @followers
end

#forkObject

Returns the value of attribute fork.



29
30
31
# File 'lib/git_hub/repo.rb', line 29

def fork
  @fork
end

#forksObject

Returns the value of attribute forks.



29
30
31
# File 'lib/git_hub/repo.rb', line 29

def forks
  @forks
end

#homepageObject

Returns the value of attribute homepage.



29
30
31
# File 'lib/git_hub/repo.rb', line 29

def homepage
  @homepage
end

#idObject

Returns the value of attribute id.



29
30
31
# File 'lib/git_hub/repo.rb', line 29

def id
  @id
end

#languageObject

Returns the value of attribute language.



29
30
31
# File 'lib/git_hub/repo.rb', line 29

def language
  @language
end

#nameObject

Returns the value of attribute name.



29
30
31
# File 'lib/git_hub/repo.rb', line 29

def name
  @name
end

#open_issuesObject

Returns the value of attribute open_issues.



29
30
31
# File 'lib/git_hub/repo.rb', line 29

def open_issues
  @open_issues
end

#privateObject

Returns the value of attribute private.



29
30
31
# File 'lib/git_hub/repo.rb', line 29

def private
  @private
end

#pushedObject

Returns the value of attribute pushed.



29
30
31
# File 'lib/git_hub/repo.rb', line 29

def pushed
  @pushed
end

#scoreObject

Returns the value of attribute score.



29
30
31
# File 'lib/git_hub/repo.rb', line 29

def score
  @score
end

#sizeObject

Returns the value of attribute size.



29
30
31
# File 'lib/git_hub/repo.rb', line 29

def size
  @size
end

#typeObject

Returns the value of attribute type.



29
30
31
# File 'lib/git_hub/repo.rb', line 29

def type
  @type
end

#urlObject

Returns the value of attribute url.



29
30
31
# File 'lib/git_hub/repo.rb', line 29

def url
  @url
end

#userObject

Returns the value of attribute user.



29
30
31
# File 'lib/git_hub/repo.rb', line 29

def user
  @user
end

Class Method Details

.create!(*args) ⇒ Object

Create new github repo, accepts Hash with :repo, :description, :homepage, :public/:private



97
98
99
100
101
102
# File 'lib/git_hub/repo.rb', line 97

def create!(*args)
  repo, desc, homepage, public = extract args, :repo, :desc, :homepage, :public
  API.ensure_auth
  instantiate post("/create", 'name' => repo, 'description' => desc,
                   'homepage' => homepage, 'public' => (public ? 1 : 0))
end

.find(*args) ⇒ Object Also known as: show, search

Find repo(s) of a (valid) github user, accepts Hash with keys:

:owner/:user/:username

Github user name

:repo/:repository/:project/:name

Repo name

:query/:search

Array of search terms as Strings or Symbols



79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/git_hub/repo.rb', line 79

def find( *args )
  user, repo, query = extract args, :user, :repo, :query
  path = if query
    "/search/#{query.map(&:to_s).join('+')}"
  elsif user && repo
    "/show/#{user}/#{repo}"
  elsif user
    "/show/#{user}"
  else
    raise "Unable to find #{self.class}(s) for #{opts}"
  end
  instantiate get(path)
end

Instance Method Details

#add_collaboratorObject



124
125
# File 'lib/git_hub/repo.rb', line 124

def add_collaborator
end

#add_serviceObject



114
115
# File 'lib/git_hub/repo.rb', line 114

def add_service
end

#branchesObject



61
62
63
# File 'lib/git_hub/repo.rb', line 61

def branches
  hash_of_commits(:branches)
end

#clone_urlObject



52
53
54
55
# File 'lib/git_hub/repo.rb', line 52

def clone_url
  url = private? || API.auth['login'] == user ? "[email protected]:" : "git://github.com/"
  url += "#{@user}/#{@name}.git"
end

#collaboratorsObject



120
121
122
# File 'lib/git_hub/repo.rb', line 120

def collaborators
  'repos/show/:user/:repo/collaborators'
end

#commits(opts = {}) ⇒ Object

Returns commits for this repo, accepts options:

:branch

Only commits for specific branch - default ‘master’

:path

Only commits for specific path

:sha/:id

Only one commit with specific id (sha)



69
70
71
# File 'lib/git_hub/repo.rb', line 69

def commits opts = {}
  Commit.find opts.merge(:user => @user, :repo => @name)
end

#delete!Object

Delete github repo, accepts optional Hash with authentication



106
107
108
109
110
111
112
# File 'lib/git_hub/repo.rb', line 106

def delete!
  API.ensure_auth
  result = post("/delete/#{@name}")
  token = result['delete_token']
  return result unless token
  post("/delete/#{@name}", 'delete_token' => token)
end

#fork?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/git_hub/repo.rb', line 44

def fork?;
  !!fork
end

#private?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/git_hub/repo.rb', line 48

def private?;
  !!self.private
end

#remove_collaboratorObject



127
128
# File 'lib/git_hub/repo.rb', line 127

def remove_collaborator
end

#remove_serviceObject



117
118
# File 'lib/git_hub/repo.rb', line 117

def remove_service
end

#tagsObject



57
58
59
# File 'lib/git_hub/repo.rb', line 57

def tags
  hash_of_commits(:tags)
end