Skip to content

Commit

Permalink
HTTP proxy support - closes #52
Browse files Browse the repository at this point in the history
Delegates to the HTTParty.http_proxy method
  • Loading branch information
chrisdambrosio committed Dec 4, 2014
1 parent 104ebbd commit 727780b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ Gitlab.endpoint = 'http://example.net/api/v3'
Gitlab.private_token = 'qEsq1pt6HJPaNciie3MG'
# => "qEsq1pt6HJPaNciie3MG"

# configure a proxy server
Gitlab.http_proxy('proxyhost', 8888)
# proxy server w/ basic auth
Gitlab.http_proxy('proxyhost', 8888, 'proxyuser', 'strongpasswordhere')

# list projects
Gitlab.projects(:per_page => 5)
# => [#<Gitlab::ObjectifiedHash:0x000000023326e0 @data={"id"=>1, "code"=>"brute", "name"=>"Brute", "description"=>nil, "path"=>"brute", "default_branch"=>nil, "owner"=>#<Gitlab::ObjectifiedHash:0x00000002331600 @data={"id"=>1, "email"=>"john@example.com", "name"=>"John Smith", "blocked"=>false, "created_at"=>"2012-09-17T09:41:56Z"}>, "private"=>true, "issues_enabled"=>true, "merge_requests_enabled"=>true, "wall_enabled"=>true, "wiki_enabled"=>true, "created_at"=>"2012-09-17T09:41:56Z"}>, #<Gitlab::ObjectifiedHash:0x000000023450d8 @data={"id"=>2, "code"=>"mozart", "name"=>"Mozart", "description"=>nil, "path"=>"mozart", "default_branch"=>nil, "owner"=>#<Gitlab::ObjectifiedHash:0x00000002344ca0 @data={"id"=>1, "email"=>"john@example.com", "name"=>"John Smith", "blocked"=>false, "created_at"=>"2012-09-17T09:41:56Z"}>, "private"=>true, "issues_enabled"=>true, "merge_requests_enabled"=>true, "wall_enabled"=>true, "wiki_enabled"=>true, "created_at"=>"2012-09-17T09:41:57Z"}>, #<Gitlab::ObjectifiedHash:0x00000002344958 @data={"id"=>3, "code"=>"gitlab", "name"=>"Gitlab", "description"=>nil, "path"=>"gitlab", "default_branch"=>nil, "owner"=>#<Gitlab::ObjectifiedHash:0x000000023447a0 @data={"id"=>1, "email"=>"john@example.com", "name"=>"John Smith", "blocked"=>false, "created_at"=>"2012-09-17T09:41:56Z"}>, "private"=>true, "issues_enabled"=>true, "merge_requests_enabled"=>true, "wall_enabled"=>true, "wiki_enabled"=>true, "created_at"=>"2012-09-17T09:41:58Z"}>]
Expand Down
5 changes: 5 additions & 0 deletions lib/gitlab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ def self.respond_to?(method)
return client.respond_to?(method) || super
end

# Delegate to HTTParty.http_proxy
def self.http_proxy(address = nil, port = nil, username = nil, password = nil)
Gitlab::Request.http_proxy(address, port, username, password)
end

# Returns an unsorted array of available client methods.
#
# @return [Array<Symbol>]
Expand Down
10 changes: 10 additions & 0 deletions spec/gitlab_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,14 @@
end
end
end

describe ".http_proxy" do
it "delegates the method to Gitlab::Request" do
Gitlab::Request = spy('request')
Gitlab.http_proxy('fazbearentertainment.com', 1987, 'ffazbear', 'itsme')

expect(Gitlab::Request).to have_received(:http_proxy).
with('fazbearentertainment.com', 1987, 'ffazbear', 'itsme')
end
end
end

0 comments on commit 727780b

Please sign in to comment.