Skip to content

Commit

Permalink
add repo watchers
Browse files Browse the repository at this point in the history
  • Loading branch information
John Ledbetter committed Jan 14, 2012
1 parent 5d7bd58 commit 410a847
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/github_v3_api/repo.rb
Expand Up @@ -15,6 +15,10 @@ def collaborators
api.list_collaborators(owner_login, name)
end

def watchers
api.list_watchers(owner_login, name)
end

private

def natural_key
Expand Down
12 changes: 12 additions & 0 deletions lib/github_v3_api/repos_api.rb
Expand Up @@ -54,5 +54,17 @@ def list_collaborators(user, repo_name)
GitHubV3API::User.new(@connection.users, user_data)
end
end

# Returns an array of GitHubV3API::User instances containing the users who are
# watching the repository specified by +user+ and +repo_name+.
#
# +user+:: the string ID of the user, e.g. "octocat"
# +repo_name+:: the string ID of the repository, e.g. "hello-world"
def list_watchers(user, repo_name)
@connection.get("/repos/#{user}/#{repo_name}/watchers").map do |user_data|
GitHubV3API::User.new(@connection.users, user_data)
end
end

end
end

0 comments on commit 410a847

Please sign in to comment.