Class: GitHub::Repo
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
-
#created ⇒ Object
Returns the value of attribute created.
-
#description ⇒ Object
Returns the value of attribute description.
-
#followers ⇒ Object
Returns the value of attribute followers.
-
#fork ⇒ Object
Returns the value of attribute fork.
-
#forks ⇒ Object
Returns the value of attribute forks.
-
#homepage ⇒ Object
Returns the value of attribute homepage.
-
#id ⇒ Object
Returns the value of attribute id.
-
#language ⇒ Object
Returns the value of attribute language.
-
#name ⇒ Object
Returns the value of attribute name.
-
#open_issues ⇒ Object
Returns the value of attribute open_issues.
-
#private ⇒ Object
Returns the value of attribute private.
-
#pushed ⇒ Object
Returns the value of attribute pushed.
-
#score ⇒ Object
Returns the value of attribute score.
-
#size ⇒ Object
Returns the value of attribute size.
-
#type ⇒ Object
Returns the value of attribute type.
-
#url ⇒ Object
Returns the value of attribute url.
-
#user ⇒ Object
Returns the value of attribute user.
Class Method Summary collapse
-
.create!(*args) ⇒ Object
Create new github repo, accepts Hash with :repo, :description, :homepage, :public/:private.
-
.find(*args) ⇒ Object
(also: 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.
Instance Method Summary collapse
- #add_collaborator ⇒ Object
- #add_service ⇒ Object
- #branches ⇒ Object
- #clone_url ⇒ Object
- #collaborators ⇒ Object
-
#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).
-
#delete! ⇒ Object
Delete github repo, accepts optional Hash with authentication.
- #fork? ⇒ Boolean
-
#initialize(opts) ⇒ Repo
constructor
A new instance of Repo.
- #private? ⇒ Boolean
- #remove_collaborator ⇒ Object
- #remove_service ⇒ Object
- #tags ⇒ Object
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
#created ⇒ Object
Returns the value of attribute created.
29 30 31 |
# File 'lib/git_hub/repo.rb', line 29 def created @created end |
#description ⇒ Object
Returns the value of attribute description.
29 30 31 |
# File 'lib/git_hub/repo.rb', line 29 def description @description end |
#followers ⇒ Object
Returns the value of attribute followers.
29 30 31 |
# File 'lib/git_hub/repo.rb', line 29 def followers @followers end |
#fork ⇒ Object
Returns the value of attribute fork.
29 30 31 |
# File 'lib/git_hub/repo.rb', line 29 def fork @fork end |
#forks ⇒ Object
Returns the value of attribute forks.
29 30 31 |
# File 'lib/git_hub/repo.rb', line 29 def forks @forks end |
#homepage ⇒ Object
Returns the value of attribute homepage.
29 30 31 |
# File 'lib/git_hub/repo.rb', line 29 def homepage @homepage end |
#id ⇒ Object
Returns the value of attribute id.
29 30 31 |
# File 'lib/git_hub/repo.rb', line 29 def id @id end |
#language ⇒ Object
Returns the value of attribute language.
29 30 31 |
# File 'lib/git_hub/repo.rb', line 29 def language @language end |
#name ⇒ Object
Returns the value of attribute name.
29 30 31 |
# File 'lib/git_hub/repo.rb', line 29 def name @name end |
#open_issues ⇒ Object
Returns the value of attribute open_issues.
29 30 31 |
# File 'lib/git_hub/repo.rb', line 29 def open_issues @open_issues end |
#private ⇒ Object
Returns the value of attribute private.
29 30 31 |
# File 'lib/git_hub/repo.rb', line 29 def private @private end |
#pushed ⇒ Object
Returns the value of attribute pushed.
29 30 31 |
# File 'lib/git_hub/repo.rb', line 29 def pushed @pushed end |
#score ⇒ Object
Returns the value of attribute score.
29 30 31 |
# File 'lib/git_hub/repo.rb', line 29 def score @score end |
#size ⇒ Object
Returns the value of attribute size.
29 30 31 |
# File 'lib/git_hub/repo.rb', line 29 def size @size end |
#type ⇒ Object
Returns the value of attribute type.
29 30 31 |
# File 'lib/git_hub/repo.rb', line 29 def type @type end |
#url ⇒ Object
Returns the value of attribute url.
29 30 31 |
# File 'lib/git_hub/repo.rb', line 29 def url @url end |
#user ⇒ Object
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_collaborator ⇒ Object
124 125 |
# File 'lib/git_hub/repo.rb', line 124 def add_collaborator end |
#add_service ⇒ Object
114 115 |
# File 'lib/git_hub/repo.rb', line 114 def add_service end |
#branches ⇒ Object
61 62 63 |
# File 'lib/git_hub/repo.rb', line 61 def branches hash_of_commits(:branches) end |
#clone_url ⇒ Object
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 |
#collaborators ⇒ Object
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
44 45 46 |
# File 'lib/git_hub/repo.rb', line 44 def fork?; !!fork end |
#private? ⇒ Boolean
48 49 50 |
# File 'lib/git_hub/repo.rb', line 48 def private?; !!self.private end |
#remove_collaborator ⇒ Object
127 128 |
# File 'lib/git_hub/repo.rb', line 127 def remove_collaborator end |
#remove_service ⇒ Object
117 118 |
# File 'lib/git_hub/repo.rb', line 117 def remove_service end |
#tags ⇒ Object
57 58 59 |
# File 'lib/git_hub/repo.rb', line 57 def hash_of_commits(:tags) end |