xn-octokit 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +4 -0
- data/.gemtest +0 -0
- data/.gitignore +24 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.markdown +73 -0
- data/Rakefile +8 -0
- data/changelog.markdown +42 -0
- data/lib/faraday/response/raise_error.rb +33 -0
- data/lib/octokit.rb +53 -0
- data/lib/octokit/client.rb +40 -0
- data/lib/octokit/client/authentication.rb +23 -0
- data/lib/octokit/client/commits.rb +16 -0
- data/lib/octokit/client/connection.rb +34 -0
- data/lib/octokit/client/issues.rb +60 -0
- data/lib/octokit/client/network.rb +15 -0
- data/lib/octokit/client/objects.rb +33 -0
- data/lib/octokit/client/organizations.rb +90 -0
- data/lib/octokit/client/pulls.rb +25 -0
- data/lib/octokit/client/repositories.rb +138 -0
- data/lib/octokit/client/request.rb +41 -0
- data/lib/octokit/client/timelines.rb +22 -0
- data/lib/octokit/client/users.rb +75 -0
- data/lib/octokit/configuration.rb +61 -0
- data/lib/octokit/repository.rb +39 -0
- data/lib/octokit/version.rb +3 -0
- data/octokit.gemspec +33 -0
- data/spec/faraday/response_spec.rb +34 -0
- data/spec/fixtures/blob.json +1 -0
- data/spec/fixtures/blob_metadata.json +1 -0
- data/spec/fixtures/blobs.json +1 -0
- data/spec/fixtures/branches.json +1 -0
- data/spec/fixtures/collaborators.json +1 -0
- data/spec/fixtures/comment.json +1 -0
- data/spec/fixtures/comments.json +1 -0
- data/spec/fixtures/commit.json +1 -0
- data/spec/fixtures/commits.json +1 -0
- data/spec/fixtures/contributors.json +1 -0
- data/spec/fixtures/delete_token.json +1 -0
- data/spec/fixtures/emails.json +1 -0
- data/spec/fixtures/followers.json +1 -0
- data/spec/fixtures/following.json +1 -0
- data/spec/fixtures/issue.json +1 -0
- data/spec/fixtures/issues.json +1 -0
- data/spec/fixtures/labels.json +1 -0
- data/spec/fixtures/languages.json +1 -0
- data/spec/fixtures/network.json +1 -0
- data/spec/fixtures/network_data.json +1 -0
- data/spec/fixtures/network_meta.json +1 -0
- data/spec/fixtures/organization.json +1 -0
- data/spec/fixtures/organizations.json +1 -0
- data/spec/fixtures/public_keys.json +1 -0
- data/spec/fixtures/pull.json +1 -0
- data/spec/fixtures/pulls.json +1 -0
- data/spec/fixtures/raw.txt +7 -0
- data/spec/fixtures/repositories.json +1 -0
- data/spec/fixtures/repository.json +1 -0
- data/spec/fixtures/tags.json +1 -0
- data/spec/fixtures/team.json +1 -0
- data/spec/fixtures/teams.json +1 -0
- data/spec/fixtures/timeline.json +1237 -0
- data/spec/fixtures/tree.json +1 -0
- data/spec/fixtures/tree_metadata.json +1 -0
- data/spec/fixtures/user.json +1 -0
- data/spec/fixtures/users.json +1 -0
- data/spec/fixtures/watchers.json +1 -0
- data/spec/helper.rb +64 -0
- data/spec/octokit/client/commits_spec.rb +32 -0
- data/spec/octokit/client/issues_spec.rb +154 -0
- data/spec/octokit/client/network_spec.rb +32 -0
- data/spec/octokit/client/objects_spec.rb +81 -0
- data/spec/octokit/client/organizations_spec.rb +234 -0
- data/spec/octokit/client/pulls_spec.rb +44 -0
- data/spec/octokit/client/repositories_spec.rb +331 -0
- data/spec/octokit/client/timelines_spec.rb +42 -0
- data/spec/octokit/client/users_spec.rb +274 -0
- data/spec/octokit/client_spec.rb +12 -0
- data/spec/octokit_spec.rb +15 -0
- data/spec/repository_spec.rb +54 -0
- metadata +336 -0
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            module Octokit
         | 
| 2 | 
            +
              class Client
         | 
| 3 | 
            +
                module Network
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                  def network_meta(repo, options={})
         | 
| 6 | 
            +
                    get("#{Repository.new(repo)}/network_meta", options, false, false)
         | 
| 7 | 
            +
                  end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  def network_data(repo, options={})
         | 
| 10 | 
            +
                    get("#{Repository.new(repo)}/network_data_chunk", options, false, false)['commits']
         | 
| 11 | 
            +
                  end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
            end
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            module Octokit
         | 
| 2 | 
            +
              class Client
         | 
| 3 | 
            +
                module Objects
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                  def tree(repo, tree_sha, options={})
         | 
| 6 | 
            +
                    get("tree/show/#{Repository.new(repo)}/#{tree_sha}", options)['tree']
         | 
| 7 | 
            +
                  end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  def blob(repo, tree_sha, path, options={})
         | 
| 10 | 
            +
                    get("blob/show/#{Repository.new(repo)}/#{tree_sha}/#{path}", options)['blob']
         | 
| 11 | 
            +
                  end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  def blobs(repo, tree_sha, options={})
         | 
| 14 | 
            +
                    get("blob/all/#{Repository.new(repo)}/#{tree_sha}", options)['blobs']
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  def blob_metadata(repo, tree_sha, options={})
         | 
| 18 | 
            +
                    get("blob/full/#{Repository.new(repo)}/#{tree_sha}", options)['blobs']
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
                  alias :blob_meta :blob_metadata
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  def tree_metadata(repo, tree_sha, options={})
         | 
| 23 | 
            +
                    get("tree/full/#{Repository.new(repo)}/#{tree_sha}", options)['tree']
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
                  alias :tree_meta :tree_metadata
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                  def raw(repo, sha, options={})
         | 
| 28 | 
            +
                    get("blob/show/#{Repository.new(repo)}/#{sha}", options, true).body
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
            end
         | 
| @@ -0,0 +1,90 @@ | |
| 1 | 
            +
            module Octokit
         | 
| 2 | 
            +
              class Client
         | 
| 3 | 
            +
                module Organizations
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                  def organization(org, options={})
         | 
| 6 | 
            +
                    get("organizations/#{org}", options)['organization']
         | 
| 7 | 
            +
                  end
         | 
| 8 | 
            +
                  alias :org :organization
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  def update_organization(org, values, options={})
         | 
| 11 | 
            +
                    put("organizations/#{org}", options.merge({:organization => values}))['organization']
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
                  alias :update_org :update_organization
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  def organizations(user=nil, options={})
         | 
| 16 | 
            +
                    if user
         | 
| 17 | 
            +
                      get("user/show/#{user}/organizations", options)
         | 
| 18 | 
            +
                    else
         | 
| 19 | 
            +
                      get("organizations", options)
         | 
| 20 | 
            +
                    end['organizations']
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
                  alias :list_organizations :organizations
         | 
| 23 | 
            +
                  alias :list_orgs :organizations
         | 
| 24 | 
            +
                  alias :orgs :organizations
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  def organization_repositories(org=nil, options={})
         | 
| 27 | 
            +
                    if org
         | 
| 28 | 
            +
                      get("organizations/#{org}/public_repositories", options)
         | 
| 29 | 
            +
                    else
         | 
| 30 | 
            +
                      get("organizations/repositories", options)
         | 
| 31 | 
            +
                    end['repositories']
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
                  alias :org_repositories :organization_repositories
         | 
| 34 | 
            +
                  alias :org_repos :organization_repositories
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  def organization_members(org, options={})
         | 
| 37 | 
            +
                    get("organizations/#{org}/public_members", options)['users']
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
                  alias :org_members :organization_members
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  def organization_teams(org, options={})
         | 
| 42 | 
            +
                    get("organizations/#{org}/teams", options)['teams']
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
                  alias :org_teams :organization_teams
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                  def create_team(org, values, options={})
         | 
| 47 | 
            +
                    post("organizations/#{org}/teams", options.merge({:team => values}))['team']
         | 
| 48 | 
            +
                  end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                  def team(team_id, options={})
         | 
| 51 | 
            +
                    get("teams/#{team_id}", options)['team']
         | 
| 52 | 
            +
                  end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                  def update_team(team_id, values, options={})
         | 
| 55 | 
            +
                    put("teams/#{team_id}", options.merge({:team => values}))['team']
         | 
| 56 | 
            +
                  end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                  def delete_team(team_id, options={})
         | 
| 59 | 
            +
                    delete("teams/#{team_id}", options)['team']
         | 
| 60 | 
            +
                  end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                  def team_members(team_id, options={})
         | 
| 63 | 
            +
                    get("teams/#{team_id}/members", options)['users']
         | 
| 64 | 
            +
                  end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                  def add_team_member(team_id, user, options={})
         | 
| 67 | 
            +
                    post("teams/#{team_id}/members", options.merge({:name => user}))['user']
         | 
| 68 | 
            +
                  end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                  def remove_team_member(team_id, user, options={})
         | 
| 71 | 
            +
                    delete("teams/#{team_id}/members", options.merge({:name => user}))['user']
         | 
| 72 | 
            +
                  end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                  def team_repositories(team_id, options={})
         | 
| 75 | 
            +
                    get("teams/#{team_id}/repositories", options)['repositories']
         | 
| 76 | 
            +
                  end
         | 
| 77 | 
            +
                  alias :team_repos :team_repositories
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                  def add_team_repository(team_id, repo, options={})
         | 
| 80 | 
            +
                    post("teams/#{team_id}/repositories", options.merge(:name => Repository.new(repo)))['repositories']
         | 
| 81 | 
            +
                  end
         | 
| 82 | 
            +
                  alias :add_team_repo :add_team_repository
         | 
| 83 | 
            +
             | 
| 84 | 
            +
                  def remove_team_repository(team_id, repo, options={})
         | 
| 85 | 
            +
                    delete("teams/#{team_id}/repositories", options.merge(:name => Repository.new(repo)))['repositories']
         | 
| 86 | 
            +
                  end
         | 
| 87 | 
            +
                  alias :remove_team_repo :remove_team_repository
         | 
| 88 | 
            +
                end
         | 
| 89 | 
            +
              end
         | 
| 90 | 
            +
            end
         | 
| @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            module Octokit
         | 
| 2 | 
            +
              class Client
         | 
| 3 | 
            +
                module Pulls
         | 
| 4 | 
            +
                  def create_pull_request(repo, base, head, title, body, options={})
         | 
| 5 | 
            +
                    pull = {
         | 
| 6 | 
            +
                      :base  => base,
         | 
| 7 | 
            +
                      :head  => head,
         | 
| 8 | 
            +
                      :title => title,
         | 
| 9 | 
            +
                      :body  => body,
         | 
| 10 | 
            +
                    }
         | 
| 11 | 
            +
                    post("pulls/#{Repository.new(repo)}", options.merge({:pull => pull}))['pulls']
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def pull_requests(repo, state='open', options={})
         | 
| 15 | 
            +
                    get("pulls/#{Repository.new(repo)}/#{state}", options)['pulls']
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
                  alias :pulls :pull_requests
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  def pull_request(repo, number, options={})
         | 
| 20 | 
            +
                    get("pulls/#{Repository.new(repo)}/#{number}", options)['pull']
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
                  alias :pull :pull_request
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
            end
         | 
| @@ -0,0 +1,138 @@ | |
| 1 | 
            +
            module Octokit
         | 
| 2 | 
            +
              class Client
         | 
| 3 | 
            +
                module Repositories
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                  def search_repositories(q, options={})
         | 
| 6 | 
            +
                    get("repos/search/#{q}", options)['repositories']
         | 
| 7 | 
            +
                  end
         | 
| 8 | 
            +
                  alias :search_repos :search_repositories
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  def repository(repo, options={})
         | 
| 11 | 
            +
                    get("repos/show/#{Repository.new(repo)}", options)['repository']
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
                  alias :repo :repository
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  def update_repository(repo, values, options={})
         | 
| 16 | 
            +
                    post("repos/show/#{Repository.new(repo)}", options.merge({:values => values}))['repository']
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
                  alias :update_repo :update_repository
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  def repositories(username=login, options={})
         | 
| 21 | 
            +
                    get(["repos/show", username].compact.join('/'), options)['repositories']
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                  alias :list_repositories :repositories
         | 
| 24 | 
            +
                  alias :list_repos :repositories
         | 
| 25 | 
            +
                  alias :repos :repositories
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                  def watch(repo, options={})
         | 
| 28 | 
            +
                    post("repos/watch/#{Repository.new(repo)}", options)['repository']
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  def unwatch(repo, options={})
         | 
| 32 | 
            +
                    post("repos/unwatch/#{Repository.new(repo)}", options)['repository']
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  def fork(repo, options={})
         | 
| 36 | 
            +
                    post("repos/fork/#{Repository.new(repo)}", options)['repository']
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                  def create_repository(name, options={})
         | 
| 40 | 
            +
                    post("repos/create", options.merge(:name => name))['repository']
         | 
| 41 | 
            +
                  end
         | 
| 42 | 
            +
                  alias :create_repo :create_repository
         | 
| 43 | 
            +
                  alias :create :create_repository
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  def delete_repository(repo, options={})
         | 
| 46 | 
            +
                    response = post("repos/delete/#{Repository.new(repo)}", options)
         | 
| 47 | 
            +
                    if response.respond_to?(:delete_token)
         | 
| 48 | 
            +
                      response['delete_token']
         | 
| 49 | 
            +
                    else
         | 
| 50 | 
            +
                      response['repository']
         | 
| 51 | 
            +
                    end
         | 
| 52 | 
            +
                  end
         | 
| 53 | 
            +
                  alias :delete_repo :delete_repository
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                  def delete_repository!(repo, options={})
         | 
| 56 | 
            +
                    response = post("repos/delete/#{Repository.new(repo)}", options)
         | 
| 57 | 
            +
                    post("repos/delete/#{Repository.new(repo)}", options.merge(:delete_token => response['delete_token']))['repository']
         | 
| 58 | 
            +
                  end
         | 
| 59 | 
            +
                  alias :delete_repo! :delete_repository!
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                  def set_private(repo, options={})
         | 
| 62 | 
            +
                    post("repos/set/private/#{Repository.new(repo)}", options)['repository']
         | 
| 63 | 
            +
                  end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                  def set_public(repo, options={})
         | 
| 66 | 
            +
                    post("repos/set/public/#{Repository.new(repo)}", options)['repository']
         | 
| 67 | 
            +
                  end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                  def deploy_keys(repo, options={})
         | 
| 70 | 
            +
                    get("repos/keys/#{Repository.new(repo)}", options)['public_keys']
         | 
| 71 | 
            +
                  end
         | 
| 72 | 
            +
                  alias :list_deploy_keys :deploy_keys
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                  def add_deploy_key(repo, title, key, options={})
         | 
| 75 | 
            +
                    post("repos/key/#{Repository.new(repo)}/add", options)['public_keys']
         | 
| 76 | 
            +
                  end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                  def remove_deploy_key(repo, id, options={})
         | 
| 79 | 
            +
                    post("repos/key/#{Repository.new(repo)}/remove", options.merge(:id => id))['public_keys']
         | 
| 80 | 
            +
                  end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                  def collaborators(repo, options={})
         | 
| 83 | 
            +
                    get("repos/show/#{Repository.new(repo)}/collaborators", options)['collaborators']
         | 
| 84 | 
            +
                  end
         | 
| 85 | 
            +
                  alias :collabs :collaborators
         | 
| 86 | 
            +
             | 
| 87 | 
            +
                  def add_collaborator(repo, collaborator, options={})
         | 
| 88 | 
            +
                    post("repos/collaborators/#{Repository.new(repo)}/add/#{collaborator}")['collaborators']
         | 
| 89 | 
            +
                  end
         | 
| 90 | 
            +
                  alias :add_collab :add_collaborator
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                  def remove_collaborator(repo, collaborator, options={})
         | 
| 93 | 
            +
                    post("repos/collaborators/#{Repository.new(repo)}/remove/#{collaborator}")['collaborators']
         | 
| 94 | 
            +
                  end
         | 
| 95 | 
            +
                  alias :remove_collab :remove_collaborator
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                  def pushable(options={})
         | 
| 98 | 
            +
                    get("repos/pushable", options)['repositories']
         | 
| 99 | 
            +
                  end
         | 
| 100 | 
            +
             | 
| 101 | 
            +
                  def repository_teams(repo, options={})
         | 
| 102 | 
            +
                    get("repos/show/#{Repository.new(repo)}/teams", options)['teams']
         | 
| 103 | 
            +
                  end
         | 
| 104 | 
            +
                  alias :repo_teams :repository_teams
         | 
| 105 | 
            +
                  alias :teams :repository_teams
         | 
| 106 | 
            +
             | 
| 107 | 
            +
                  def contributors(repo, anon=false, options={})
         | 
| 108 | 
            +
                    if anon
         | 
| 109 | 
            +
                      get("repos/show/#{Repository.new(repo)}/contributors/anon", options)
         | 
| 110 | 
            +
                    else
         | 
| 111 | 
            +
                      get("repos/show/#{Repository.new(repo)}/contributors", options)
         | 
| 112 | 
            +
                    end['contributors']
         | 
| 113 | 
            +
                  end
         | 
| 114 | 
            +
                  alias :contribs :contributors
         | 
| 115 | 
            +
             | 
| 116 | 
            +
                  def watchers(repo, options={})
         | 
| 117 | 
            +
                    get("repos/show/#{Repository.new(repo)}/watchers", options)['watchers']
         | 
| 118 | 
            +
                  end
         | 
| 119 | 
            +
             | 
| 120 | 
            +
                  def network(repo, options={})
         | 
| 121 | 
            +
                    get("repos/show/#{Repository.new(repo)}/network", options)['network']
         | 
| 122 | 
            +
                  end
         | 
| 123 | 
            +
             | 
| 124 | 
            +
                  def languages(repo, options={})
         | 
| 125 | 
            +
                    get("repos/show/#{Repository.new(repo)}/languages", options)['languages']
         | 
| 126 | 
            +
                  end
         | 
| 127 | 
            +
             | 
| 128 | 
            +
                  def tags(repo, options={})
         | 
| 129 | 
            +
                    get("repos/show/#{Repository.new(repo)}/tags", options)['tags']
         | 
| 130 | 
            +
                  end
         | 
| 131 | 
            +
             | 
| 132 | 
            +
                  def branches(repo, options={})
         | 
| 133 | 
            +
                    get("repos/show/#{Repository.new(repo)}/branches", options)['branches']
         | 
| 134 | 
            +
                  end
         | 
| 135 | 
            +
             | 
| 136 | 
            +
                end
         | 
| 137 | 
            +
              end
         | 
| 138 | 
            +
            end
         | 
| @@ -0,0 +1,41 @@ | |
| 1 | 
            +
            module Octokit
         | 
| 2 | 
            +
              class Client
         | 
| 3 | 
            +
                module Request
         | 
| 4 | 
            +
                  def get(path, options={}, raw=false, format_path=true, authenticate=true)
         | 
| 5 | 
            +
                    request(:get, path, options, raw, format_path, authenticate)
         | 
| 6 | 
            +
                  end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  def post(path, options={}, raw=false, format_path=true, authenticate=true)
         | 
| 9 | 
            +
                    request(:post, path, options, raw, format_path, authenticate)
         | 
| 10 | 
            +
                  end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  def put(path, options={}, raw=false, format_path=true, authenticate=true)
         | 
| 13 | 
            +
                    request(:put, path, options, raw, format_path, authenticate)
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  def delete(path, options={}, raw=false, format_path=true, authenticate=true)
         | 
| 17 | 
            +
                    request(:delete, path, options, raw, format_path, authenticate)
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  private
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  def request(method, path, options, raw, format_path, authenticate)
         | 
| 23 | 
            +
                    response = connection(raw, authenticate).send(method) do |request|
         | 
| 24 | 
            +
                      path = formatted_path(path) if format_path
         | 
| 25 | 
            +
                      case method
         | 
| 26 | 
            +
                        when :get, :delete
         | 
| 27 | 
            +
                          request.url(path, options)
         | 
| 28 | 
            +
                        when :post, :put
         | 
| 29 | 
            +
                          request.path = path
         | 
| 30 | 
            +
                          request.body = options unless options.empty?
         | 
| 31 | 
            +
                      end
         | 
| 32 | 
            +
                    end
         | 
| 33 | 
            +
                    raw ? response : response.body
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  def formatted_path(path)
         | 
| 37 | 
            +
                    ['api', ['v', version].join, format, path].compact.join('/')
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
              end
         | 
| 41 | 
            +
            end
         | 
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            module Octokit
         | 
| 2 | 
            +
              class Client
         | 
| 3 | 
            +
                module Timelines
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                  def timeline(options={})
         | 
| 6 | 
            +
                    path = "https://github.com/timeline.json"
         | 
| 7 | 
            +
                    get(path, options, false, false, false)
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  def user_timeline(username=login, options={})
         | 
| 11 | 
            +
                    if token
         | 
| 12 | 
            +
                      path = "https://github.com/#{username}.private.json"
         | 
| 13 | 
            +
                      options[:token] = token
         | 
| 14 | 
            +
                    else
         | 
| 15 | 
            +
                      path = "https://github.com/#{username}.json"
         | 
| 16 | 
            +
                    end
         | 
| 17 | 
            +
                    get(path, options, false, false, false)
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
            end
         | 
| @@ -0,0 +1,75 @@ | |
| 1 | 
            +
            module Octokit
         | 
| 2 | 
            +
              class Client
         | 
| 3 | 
            +
                module Users
         | 
| 4 | 
            +
                  EMAIL_RE = /[\w.!#\$%+-]+@[\w-]+(?:\.[\w-]+)+/
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  def search_users(search, options={})
         | 
| 7 | 
            +
                    if search.match(EMAIL_RE)
         | 
| 8 | 
            +
                      get("user/email/#{search}", options)['user']
         | 
| 9 | 
            +
                    else
         | 
| 10 | 
            +
                      get("user/search/#{search}", options)['users']
         | 
| 11 | 
            +
                    end
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def user(username=nil, options={})
         | 
| 15 | 
            +
                    get(["user/show", username].compact.join('/'), options)['user']
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  def update_user(values, options={})
         | 
| 19 | 
            +
                    post("user/show/#{login}", options.merge({:values => values}))['user']
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  def followers(user=login, options={})
         | 
| 23 | 
            +
                    get("user/show/#{user}/followers", options)['users']
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  def following(user=login, options={})
         | 
| 27 | 
            +
                    get("user/show/#{user}/following", options)['users']
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  def follows?(*args)
         | 
| 31 | 
            +
                    target = args.pop
         | 
| 32 | 
            +
                    user = args.first
         | 
| 33 | 
            +
                    user ||= login
         | 
| 34 | 
            +
                    return if user.nil?
         | 
| 35 | 
            +
                    following(user).include?(target)
         | 
| 36 | 
            +
                  end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                  def follow(user, options={})
         | 
| 39 | 
            +
                    post("user/follow/#{user}", options)['users']
         | 
| 40 | 
            +
                  end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                  def unfollow(user, options={})
         | 
| 43 | 
            +
                    post("user/unfollow/#{user}", options)['users']
         | 
| 44 | 
            +
                  end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                  def watched(user=login, options={})
         | 
| 47 | 
            +
                    get("repos/watched/#{user}", options)['repositories']
         | 
| 48 | 
            +
                  end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                  def keys(options={})
         | 
| 51 | 
            +
                    get("user/keys", options)['public_keys']
         | 
| 52 | 
            +
                  end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                  def add_key(title, key, options={})
         | 
| 55 | 
            +
                    post("user/key/add", options.merge({:title => title, :key => key}))['public_keys']
         | 
| 56 | 
            +
                  end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                  def remove_key(id, options={})
         | 
| 59 | 
            +
                    post("user/key/remove", options.merge({:id => id}))['public_keys']
         | 
| 60 | 
            +
                  end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                  def emails(options={})
         | 
| 63 | 
            +
                    get("user/emails", options)['emails']
         | 
| 64 | 
            +
                  end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                  def add_email(email, options={})
         | 
| 67 | 
            +
                    post("user/email/add", options.merge({:email => email}))['emails']
         | 
| 68 | 
            +
                  end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                  def remove_email(email, options={})
         | 
| 71 | 
            +
                    post("user/email/remove", options.merge({:email => email}))['emails']
         | 
| 72 | 
            +
                  end
         | 
| 73 | 
            +
                end
         | 
| 74 | 
            +
              end
         | 
| 75 | 
            +
            end
         |