From 09d278906348a41bdbb1555051783afc0b7f64a0 Mon Sep 17 00:00:00 2001 From: Andrew Nesbitt Date: Sat, 9 Feb 2013 19:03:11 +0000 Subject: [PATCH] More consistent formatting of requests in clients To help the OCD in me, I've wrapped all requests with brackets (most already where) and made options merging more consistent. --- lib/octokit/client/authorizations.rb | 4 +- lib/octokit/client/commits.rb | 50 +++++++++++----------- lib/octokit/client/emojis.rb | 2 +- lib/octokit/client/gists.rb | 26 ++++++----- lib/octokit/client/github.rb | 2 +- lib/octokit/client/gitignore.rb | 4 +- lib/octokit/client/issues.rb | 2 +- lib/octokit/client/objects.rb | 9 ++-- lib/octokit/client/organizations.rb | 2 +- lib/octokit/client/refs.rb | 12 +++--- lib/octokit/client/repositories.rb | 64 ++++++++++++++++------------ lib/octokit/client/say.rb | 2 +- lib/octokit/client/statuses.rb | 3 +- lib/octokit/client/users.rb | 15 ++++--- 14 files changed, 105 insertions(+), 92 deletions(-) diff --git a/lib/octokit/client/authorizations.rb b/lib/octokit/client/authorizations.rb index 80e8061cb..f82d2e4a6 100644 --- a/lib/octokit/client/authorizations.rb +++ b/lib/octokit/client/authorizations.rb @@ -14,7 +14,7 @@ module Authorizations # client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret') # client.authorizations def authorizations(options={}) - get 'authorizations', options + get('authorizations', options) end @@ -29,7 +29,7 @@ def authorizations(options={}) # client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret') # client.authorization(999999) def authorization(number, options={}) - get "authorizations/#{number}", options + get("authorizations/#{number}", options) end # Create an authorization for the authenticated user. diff --git a/lib/octokit/client/commits.rb b/lib/octokit/client/commits.rb index 80f99442e..da13c2113 100644 --- a/lib/octokit/client/commits.rb +++ b/lib/octokit/client/commits.rb @@ -14,8 +14,7 @@ module Commits # @return [Array] An array of hashes representing commits # @see http://developer.github.com/v3/repos/commits/ def commits(repo, sha_or_branch="master", options={}) - params = { :sha => sha_or_branch, :per_page => 35 } - get("repos/#{Repository.new(repo)}/commits", params.merge(options)) + get("repos/#{Repository.new(repo)}/commits", options.merge({ :sha => sha_or_branch, :per_page => 35 })) end alias :list_commits :commits @@ -49,9 +48,12 @@ def commit(repo, sha, options={}) # commit.message # => "My commit message" # commit.committer # => { "name" => "Wynn Netherland", "email" => "wynn@github.com", ... } def create_commit(repo, message, tree, parents=nil, options={}) - params = { :message => message, :tree => tree } - params[:parents] = [parents].flatten if parents - post("repos/#{Repository.new(repo)}/git/commits", options.merge(params)) + options.merge!({ + :message => message, + :tree => tree + }) + options[:parents] = [parents].flatten if parents + post("repos/#{Repository.new(repo)}/git/commits", options) end # List all commit comments @@ -101,14 +103,14 @@ def commit_comment(repo, id, options={}) # commit.line # => 10 # commit.position # => 1 def create_commit_comment(repo, sha, body, path=nil, line=nil, position=nil, options={}) - params = { + options.merge!({ :body => body, :commit_id => sha, :path => path, :line => line, :position => position - } - post("repos/#{Repository.new(repo)}/commits/#{sha}/comments", options.merge(params)) + }) + post("repos/#{Repository.new(repo)}/commits/#{sha}/comments", options) end # Update a commit comment @@ -123,10 +125,7 @@ def create_commit_comment(repo, sha, body, path=nil, line=nil, position=nil, opt # commit.id # => 860296 # commit.body # => "Updated commit comment" def update_commit_comment(repo, id, body, options={}) - params = { - :body => body - } - patch("repos/#{Repository.new(repo)}/comments/#{id}", options.merge(params)) + patch("repos/#{Repository.new(repo)}/comments/#{id}", options.merge({:body => body})) end # Delete a commit comment @@ -159,11 +158,11 @@ def compare(repo, start, endd, options={}) # @return [Hashie::Mash] A hash representing the comparison # @see http://developer.github.com/v3/repos/merging/ def merge(repo, base, head, options={}) - params = { + options.merge!({ :base => base, :head => head - }.merge(options) - post("repos/#{Repository.new(repo)}/merges", params) + }) + post("repos/#{Repository.new(repo)}/merges", options) end # Get commits based on time windows @@ -178,8 +177,7 @@ def merge(repo, base, head, options={}) # @example # Octokit.commits_since('pengwynn/octokit', '2012-10-01') def commits_since(repo, date, sha_or_branch="master", options={}) - params = {:since => iso8601(parse_date(date))} - commits(repo, sha_or_branch, params.merge(options)) + commits(repo, sha_or_branch, options.merge({:since => iso8601(parse_date(date))})) end # Get commits before a specified date @@ -192,8 +190,7 @@ def commits_since(repo, date, sha_or_branch="master", options={}) # @example # Octokit.commits_before('pengwynn/octokit', '2012-10-01') def commits_before(repo, date, sha_or_branch="master", options={}) - params = {:until => iso8601(parse_date(date))} - commits(repo, sha_or_branch, params.merge(options)) + commits(repo, sha_or_branch, options.merge({:until => iso8601(parse_date(date))})) end # Get commits on a specified date @@ -214,8 +211,11 @@ def commits_on(repo, date, sha_or_branch="master", options={}) rescue ArgumentError raise ArgumentError, "#{date} is not a valid date" end - params = { :since => iso8601(start_date), :until => iso8601(end_date) } - commits(repo, sha_or_branch, params.merge(options)) + options.merge!({ + :since => iso8601(start_date), + :until => iso8601(end_date) + }) + commits(repo, sha_or_branch, options) end # Get commits made between two nominated dates @@ -246,9 +246,11 @@ def commits_between(repo, start_date, end_date, sha_or_branch="master", options= if _end_date < _start_date raise ArgumentError, "Start date #{start_date} does not precede #{end_date}" end - params = {:since => iso8601(_start_date), - :until => iso8601(_end_date) } - commits(repo, sha_or_branch, params.merge(options)) + options.merge!({ + :since => iso8601(_start_date), + :until => iso8601(_end_date) + }) + commits(repo, sha_or_branch, options) end protected diff --git a/lib/octokit/client/emojis.rb b/lib/octokit/client/emojis.rb index ed6f84d63..d92975623 100644 --- a/lib/octokit/client/emojis.rb +++ b/lib/octokit/client/emojis.rb @@ -7,7 +7,7 @@ module Emojis # @example List all emojis # Octokit.emojis def emojis - get "emojis" + get("emojis") end end end diff --git a/lib/octokit/client/gists.rb b/lib/octokit/client/gists.rb index 039bc7d6f..283438148 100644 --- a/lib/octokit/client/gists.rb +++ b/lib/octokit/client/gists.rb @@ -13,9 +13,9 @@ module Gists # @see http://developer.github.com/v3/gists/#list-gists def gists(username=nil, options={}) if username.nil? - get 'gists', options + get('gists', options) else - get "users/#{username}/gists", options + get("users/#{username}/gists", options) end end alias :list_gists :gists @@ -27,14 +27,14 @@ def gists(username=nil, options={}) # Octokit.public_gists # @see http://developer.github.com/v3/gists/#list-gists def public_gists(options={}) - get 'gists/public', options + get('gists/public', options) end # List the authenticated user’s starred gists # # @return [Array] A list of gists def starred_gists(options={}) - get 'gists/starred', options + get('gists/starred', options) end # Get a single gist @@ -43,7 +43,7 @@ def starred_gists(options={}) # @return [Hash::Mash] Gist information # @see http://developer.github.com/v3/gists/#get-a-single-gist def gist(gist, options={}) - get "gists/#{Gist.new gist}", options + get("gists/#{Gist.new gist}", options) end # Create a gist @@ -57,7 +57,7 @@ def gist(gist, options={}) # @return [Hashie::Mash] Newly created gist info # @see http://developer.github.com/v3/gists/#create-a-gist def create_gist(options={}) - post 'gists', options + post('gists', options) end # Edit a gist @@ -76,7 +76,7 @@ def create_gist(options={}) # [Hashie::Mash] Newly created gist info # @see http://developer.github.com/v3/gists/#edit-a-gist def edit_gist(gist, options={}) - patch "gists/#{Gist.new gist}", options + patch("gists/#{Gist.new gist}", options) end # @@ -113,7 +113,7 @@ def gist_starred?(gist, options={}) # @return [Hashie::Mash] Data for the new gist # @see http://developer.github.com/v3/gists/#fork-a-gist def fork_gist(gist, options={}) - post "gists/#{Gist.new gist}/forks", options + post("gists/#{Gist.new gist}/forks", options) end # Delete a gist @@ -133,7 +133,7 @@ def delete_gist(gist, options={}) # @example # Octokit.gist_comments('3528ae645') def gist_comments(gist_id, options={}) - get "gists/#{gist_id}/comments", options + get("gists/#{gist_id}/comments", options) end # Get gist comment @@ -145,7 +145,7 @@ def gist_comments(gist_id, options={}) # @example # Octokit.gist_comment('208sdaz3', 1451398) def gist_comment(gist_id, gist_comment_id, options={}) - get "gists/#{gist_id}/comments/#{gist_comment_id}", options + get("gists/#{gist_id}/comments/#{gist_comment_id}", options) end # Create gist comment @@ -160,8 +160,7 @@ def gist_comment(gist_id, gist_comment_id, options={}) # @example # @client.create_gist_comment('3528645', 'This is very helpful.') def create_gist_comment(gist_id, comment, options={}) - options.merge!({:body => comment}) - post "gists/#{gist_id}/comments", options + post("gists/#{gist_id}/comments", options.merge({:body => comment})) end # Update gist comment @@ -177,8 +176,7 @@ def create_gist_comment(gist_id, comment, options={}) # @example # @client.update_gist_comment('208sdaz3', '3528645', ':heart:') def update_gist_comment(gist_id, gist_comment_id, comment, options={}) - options.merge!({:body => comment}) - patch "gists/#{gist_id}/comments/#{gist_comment_id}", options + patch("gists/#{gist_id}/comments/#{gist_comment_id}", options.merge({:body => comment})) end # Delete gist comment diff --git a/lib/octokit/client/github.rb b/lib/octokit/client/github.rb index 051061aba..098b7c9c3 100644 --- a/lib/octokit/client/github.rb +++ b/lib/octokit/client/github.rb @@ -11,7 +11,7 @@ module GitHub # @example Get GitHub meta information # @client.github_meta def github_meta(options={}) - get "/meta", options + get("/meta", options) end end diff --git a/lib/octokit/client/gitignore.rb b/lib/octokit/client/gitignore.rb index 11274405d..22b6d4810 100644 --- a/lib/octokit/client/gitignore.rb +++ b/lib/octokit/client/gitignore.rb @@ -14,7 +14,7 @@ module Gitignore # @example Git all the gitignore templates # @client.gitignore_templates def gitignore_templates(options={}) - get "/gitignore/templates", options + get("/gitignore/templates", options) end # Get a gitignore template. @@ -33,7 +33,7 @@ def gitignore_templates(options={}) # @example Get the Ruby gitignore template # @client.gitignore_template('Ruby') def gitignore_template(template_name, options={}) - get "/gitignore/templates/#{template_name}", options + get("/gitignore/templates/#{template_name}", options) end end diff --git a/lib/octokit/client/issues.rb b/lib/octokit/client/issues.rb index 69474e705..d1bd841ea 100644 --- a/lib/octokit/client/issues.rb +++ b/lib/octokit/client/issues.rb @@ -139,7 +139,7 @@ def update_issue(repo, number, title, body, options={}) # :since => '2010-05-04T23:45:02Z' # }) def issues_comments(repo, options={}) - get "/repos/#{Repository.new repo}/issues/comments", options + get("/repos/#{Repository.new repo}/issues/comments", options) end # Get all comments attached to an issue diff --git a/lib/octokit/client/objects.rb b/lib/octokit/client/objects.rb index e07e968d8..8ee271040 100644 --- a/lib/octokit/client/objects.rb +++ b/lib/octokit/client/objects.rb @@ -32,8 +32,7 @@ def tree(repo, tree_sha, options={}) # tree.sha # => "cd8274d15fa3ae2ab983129fb037999f264ba9a7" # tree.tree.first.path # => "file.rb" def create_tree(repo, tree, options={}) - parameters = { :tree => tree } - post("repos/#{Repository.new(repo)}/git/trees", options.merge(parameters)) + post("repos/#{Repository.new(repo)}/git/trees", options.merge({:tree => tree})) end # Get a single blob, fetching its content and encoding @@ -69,11 +68,11 @@ def blob(repo, blob_sha, options={}) # require "base64" # Octokit.create_blob("octocat/Hello-World", Base64.encode64("foo bar baz"), "base64") def create_blob(repo, content, encoding="utf-8", options={}) - parameters = { + options.merge!({ :content => content, :encoding => encoding - } - post("repos/#{Repository.new(repo)}/git/blobs", options.merge(parameters)).sha + }) + post("repos/#{Repository.new(repo)}/git/blobs", options).sha end # Get a tag diff --git a/lib/octokit/client/organizations.rb b/lib/octokit/client/organizations.rb index 7e221ed9a..44f6fd117 100644 --- a/lib/octokit/client/organizations.rb +++ b/lib/octokit/client/organizations.rb @@ -366,7 +366,7 @@ def team_repositories(team_id, options={}) # @example # @client.add_team_repo(100000, 'github/developer.github.com') def add_team_repository(team_id, repo, options={}) - boolean_from_response(:put, "teams/#{team_id}/repos/#{Repository.new(repo)}", options.merge(:name => Repository.new(repo))) + boolean_from_response(:put, "teams/#{team_id}/repos/#{Repository.new(repo)}", options.merge({:name => Repository.new(repo)})) end alias :add_team_repo :add_team_repository diff --git a/lib/octokit/client/refs.rb b/lib/octokit/client/refs.rb index c250a3e66..c651fde74 100644 --- a/lib/octokit/client/refs.rb +++ b/lib/octokit/client/refs.rb @@ -40,11 +40,11 @@ def ref(repo, ref, options={}) # @example Create refs/heads/master for octocat/Hello-World with sha 827efc6d56897b048c772eb4087f854f46256132 # Octokit.create_ref("octocat/Hello-World","heads/master", "827efc6d56897b048c772eb4087f854f46256132") def create_ref(repo, ref, sha, options={}) - parameters = { + options.merge!({ :ref => "refs/#{ref}", :sha => sha - } - post("repos/#{Repository.new(repo)}/git/refs", options.merge(parameters)) + }) + post("repos/#{Repository.new(repo)}/git/refs", options) end alias :create_reference :create_ref @@ -59,11 +59,11 @@ def create_ref(repo, ref, sha, options={}) # @example Force update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd # Octokit.update_ref("octocat/Hello-World","heads/sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd") def update_ref(repo, ref, sha, force=true, options={}) - parameters = { + options.merge!({ :sha => sha, :force => force - } - patch("repos/#{Repository.new(repo)}/git/refs/#{ref}", options.merge(parameters)) + }) + patch("repos/#{Repository.new(repo)}/git/refs/#{ref}", options) end alias :update_reference :update_ref diff --git a/lib/octokit/client/repositories.rb b/lib/octokit/client/repositories.rb index 3ad6a5dc1..ad5ed2a2e 100644 --- a/lib/octokit/client/repositories.rb +++ b/lib/octokit/client/repositories.rb @@ -18,7 +18,7 @@ def search_repositories(q, options={}) # @param repo [String, Hash, Repository] A GitHub repository # @return [Hashie::Mash] Repository information def repository(repo, options={}) - get "repos/#{Repository.new repo}", options + get("repos/#{Repository.new repo}", options) end alias :repo :repository @@ -53,9 +53,9 @@ def edit_repository(repo, options={}) # @return [Array] List of repositories def repositories(username=nil, options={}) if username.nil? - get 'user/repos', options + get('user/repos', options) else - get "users/#{username}/repos", options + get("users/#{username}/repos", options) end end alias :list_repositories :repositories @@ -75,7 +75,7 @@ def repositories(username=nil, options={}) # # @return [Array] List of repositories. def all_repositories(options={}) - get '/repositories', options + get('/repositories', options) end # Star a repository @@ -117,7 +117,7 @@ def unwatch(repo, options={}) # @param repo [String, Hash, Repository] A GitHub repository # @return [Hashie::Mash] Repository info for the new fork def fork(repo, options={}) - post "repos/#{Repository.new repo}/forks", options + post("repos/#{Repository.new repo}/forks", options) end # Create a repository for a user or organization @@ -140,9 +140,9 @@ def create_repository(name, options={}) options.merge! :name => name if organization.nil? - post 'user/repos', options + post('user/repos', options) else - post "orgs/#{organization}/repos", options + post("orgs/#{organization}/repos", options) end end alias :create_repo :create_repository @@ -191,7 +191,7 @@ def set_public(repo, options={}) # @example # @client.list_deploy_keys('pengwynn/octokit') def deploy_keys(repo, options={}) - get "repos/#{Repository.new repo}/keys", options + get("repos/#{Repository.new repo}/keys", options) end alias :list_deploy_keys :deploy_keys @@ -208,7 +208,7 @@ def deploy_keys(repo, options={}) # @example # @client.add_deploy_key('pengwynn/octokit', 'Staging server', 'ssh-rsa AAA...') def add_deploy_key(repo, title, key, options={}) - post "repos/#{Repository.new repo}/keys", options.merge(:title => title, :key => key) + post("repos/#{Repository.new repo}/keys", options.merge({:title => title, :key => key})) end # Remove deploy key from a repo @@ -241,7 +241,7 @@ def remove_deploy_key(repo, id, options={}) # @example # @client.collabs('pengwynn/octokit') def collaborators(repo, options={}) - get "repos/#{Repository.new repo}/collaborators", options + get("repos/#{Repository.new repo}/collaborators", options) end alias :collabs :collaborators @@ -296,7 +296,7 @@ def remove_collaborator(repo, collaborator, options={}) # @example # @client.teams('octokit/pengwynn') def repository_teams(repo, options={}) - get "repos/#{Repository.new repo}/teams", options + get("repos/#{Repository.new repo}/teams", options) end alias :repo_teams :repository_teams alias :teams :repository_teams @@ -317,7 +317,7 @@ def repository_teams(repo, options={}) # @example # @client.contribs('pengwynn/octokit') def contributors(repo, anon=false, options={}) - get "repos/#{Repository.new repo}/contributors", options.merge(:anon => anon) + get("repos/#{Repository.new repo}/contributors", options.merge({:anon => anon})) end alias :contribs :contributors @@ -334,7 +334,7 @@ def contributors(repo, anon=false, options={}) # @example # @client.stargazers('pengwynn/octokit') def stargazers(repo, options={}) - get "repos/#{Repository.new repo}/stargazers", options + get("repos/#{Repository.new repo}/stargazers", options) end # @deprecated Use #stargazers instead @@ -353,7 +353,7 @@ def stargazers(repo, options={}) # @example # @client.watchers('pengwynn/octokit') def watchers(repo, options={}) - get "repos/#{Repository.new repo}/watchers", options + get("repos/#{Repository.new repo}/watchers", options) end # List forks @@ -371,7 +371,7 @@ def watchers(repo, options={}) # @example # @client.forks('pengwynn/octokit') def forks(repo, options={}) - get "repos/#{Repository.new repo}/forks", options + get("repos/#{Repository.new repo}/forks", options) end alias :network :forks @@ -388,7 +388,7 @@ def forks(repo, options={}) # @example # @client.languages('pengwynn/octokit') def languages(repo, options={}) - get "repos/#{Repository.new repo}/languages", options + get("repos/#{Repository.new repo}/languages", options) end # List tags @@ -404,7 +404,7 @@ def languages(repo, options={}) # @example # @client.tags('pengwynn/octokit') def tags(repo, options={}) - get "repos/#{Repository.new repo}/tags", options + get("repos/#{Repository.new repo}/tags", options) end # List branches @@ -420,7 +420,7 @@ def tags(repo, options={}) # @example # @client.branches('pengwynn/octokit') def branches(repo, options={}) - get "repos/#{Repository.new repo}/branches", options + get("repos/#{Repository.new repo}/branches", options) end # Get a single branch from a repository @@ -432,7 +432,7 @@ def branches(repo, options={}) # @example Get branch 'master` from pengwynn/octokit # Octokit.issue("pengwynn/octokit", "master") def branch(repo, branch, options={}) - get "repos/#{Repository.new repo}/branches/#{branch}", options + get("repos/#{Repository.new repo}/branches/#{branch}", options) end alias :get_branch :branch @@ -447,7 +447,7 @@ def branch(repo, branch, options={}) # @example # @client.hooks('pengwynn/octokit') def hooks(repo, options={}) - get "repos/#{Repository.new repo}/hooks", options + get("repos/#{Repository.new repo}/hooks", options) end # Get single hook @@ -462,7 +462,7 @@ def hooks(repo, options={}) # @example # @client.hook('pengwynn/octokit', 100000) def hook(repo, id, options={}) - get "repos/#{Repository.new repo}/hooks/#{id}", options + get("repos/#{Repository.new repo}/hooks/#{id}", options) end # Create a hook @@ -497,8 +497,13 @@ def hook(repo, id, options={}) # } # ) def create_hook(repo, name, config, options={}) - options = {:name => name, :config => config, :events => ["push"], :active => true}.merge(options) - post "repos/#{Repository.new repo}/hooks", options + options.merge!({ + :name => name, + :config => config, + :events => ["push"], + :active => true + }) + post("repos/#{Repository.new repo}/hooks", options) end # Edit a hook @@ -539,8 +544,13 @@ def create_hook(repo, name, config, options={}) # } # ) def edit_hook(repo, id, name, config, options={}) - options = {:name => name, :config => config, :events => ["push"], :active => true}.merge(options) - patch "repos/#{Repository.new repo}/hooks/#{id}", options + options.merge!({ + :name => name, + :config => config, + :events => ["push"], + :active => true + }) + patch("repos/#{Repository.new repo}/hooks/#{id}", options) end # Delete hook @@ -582,7 +592,7 @@ def test_hook(repo, id, options={}) # @example Get all Issue Events for Octokit # Octokit.repository_issue_events("pengwynn/octokit") def repository_issue_events(repo, options={}) - get "repos/#{Repository.new repo}/issues/events", options + get("repos/#{Repository.new repo}/issues/events", options) end alias :repo_issue_events :repository_issue_events @@ -601,7 +611,7 @@ def repository_issue_events(repo, options={}) # @example # @client.repository_assignees('pengwynn/octokit') def repository_assignees(repo, options={}) - get "repos/#{Repository.new repo}/assignees", options + get("repos/#{Repository.new repo}/assignees", options) end alias :repo_assignees :repository_assignees diff --git a/lib/octokit/client/say.rb b/lib/octokit/client/say.rb index 0b3e4cb41..b69b16c27 100644 --- a/lib/octokit/client/say.rb +++ b/lib/octokit/client/say.rb @@ -5,7 +5,7 @@ module Say def say(text=nil) options = {} options[:s] = text if text - get "/octocat", options + get("/octocat", options) end alias :octocat :say diff --git a/lib/octokit/client/statuses.rb b/lib/octokit/client/statuses.rb index 46f83aad0..c2a40885a 100644 --- a/lib/octokit/client/statuses.rb +++ b/lib/octokit/client/statuses.rb @@ -21,8 +21,7 @@ def statuses(repo, sha, options={}) # @return [Hash] A status # @see http://developer.github.com/v3/repos/status def create_status(repo, sha, state, options={}) - options.merge!(:state => state) - post("repos/#{Repository.new(repo)}/statuses/#{sha}", options) + post("repos/#{Repository.new(repo)}/statuses/#{sha}", options.merge({:state => state})) end # Returns the current system status diff --git a/lib/octokit/client/users.rb b/lib/octokit/client/users.rb index 582ef9d08..1e4755f6d 100644 --- a/lib/octokit/client/users.rb +++ b/lib/octokit/client/users.rb @@ -26,7 +26,7 @@ def search_users(search, options={}) # # @return [Array] List of GitHub users. def all_users(options={}) - get "users", options + get("users", options) end # Get a single user @@ -38,9 +38,9 @@ def all_users(options={}) # Octokit.user("sferik") def user(user=nil) if user - get "users/#{user}" + get("users/#{user}") else - get 'user' + get('user') end end @@ -55,8 +55,13 @@ def user(user=nil) # @example # @client.access_token('aaaa', 'xxxx', 'yyyy', {:accept => 'application/json'}) def access_token(code, app_id, app_secret, options = {}) - post("login/oauth/access_token", options.merge({:endpoint => Octokit.web_endpoint, :code => code, - :client_id => app_id, :client_secret => app_secret})) + options.merge!({ + :endpoint => Octokit.web_endpoint, + :code => code, + :client_id => app_id, + :client_secret => app_secret + }) + post("login/oauth/access_token", options) end # Validate user username and password