Skip to content

Commit

Permalink
Merge branch 'contributors' into integration
Browse files Browse the repository at this point in the history
  • Loading branch information
pengwynn committed May 4, 2010
2 parents 55ed98b + 535d0ca commit 3346e37
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/octopussy.rb
Expand Up @@ -43,7 +43,7 @@ def self.client; Client.new end
def_delegators :client, :search_issues, :issues, :issue

# Repos
def_delegators :client, :branches, :collaborators, :languages, :list_repos,
def_delegators :client, :branches, :collaborators, :contributors, :languages, :list_repos,
:network, :repo, :search_repos, :tags

# Network Meta
Expand Down
6 changes: 6 additions & 0 deletions lib/octopussy/client.rb
Expand Up @@ -239,6 +239,12 @@ def collaborators(repo)
Hashie::Mash.new(response).collaborators
end

def contributors(repo)
repo = Repo.new(repo)
response = self.class.get("/repos/show/#{repo.username}/#{repo.name}/contributors")
Hashie::Mash.new(response).contributors
end

def repo(repo)
repo = Repo.new(repo)
response = self.class.get("/repos/show/#{repo.username}/#{repo.name}")
Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/contributors.json
@@ -0,0 +1,6 @@
{
"contributors": [
["pengwynn", 39],
["holman", 1]
]
}
6 changes: 6 additions & 0 deletions test/octopussy_test.rb
Expand Up @@ -318,6 +318,12 @@ class OctopussyTest < Test::Unit::TestCase
repo = Octopussy.repo({:username => "pengwynn", :repo => "linkedin"})
repo.homepage.should == "http://bit.ly/ruby-linkedin"
end

should "return a repo's contributors list" do
stub_get("/repos/show/pengwynn/linkedin/contributors", "contributors.json")
contributors_list = Octopussy.contributors({:username => "pengwynn", :repo => "linkedin"})
assert contributors_list.include?(["holman", 1])
end

should "list repos for a user" do
stub_get("/repos/show/pengwynn", "repos.json")
Expand Down

0 comments on commit 3346e37

Please sign in to comment.