Skip to content

Sub-URI support #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/copycopter_client/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Client
# @option options [Logger] :logger where to log transactions
# @option options [String] :ca_file path to root certificate file for ssl verification
def initialize(options)
[:api_key, :host, :port, :public, :http_read_timeout,
[:api_key, :host, :path, :port, :public, :http_read_timeout,
:http_open_timeout, :secure, :logger, :ca_file].each do |option|
instance_variable_set "@#{option}", options[option]
end
Expand Down Expand Up @@ -82,15 +82,15 @@ def deploy

private

attr_reader :host, :port, :api_key, :http_read_timeout,
attr_reader :host, :path, :port, :api_key, :http_read_timeout,
:http_open_timeout, :secure, :logger, :ca_file

def public?
@public
end

def uri(resource)
"/api/v2/projects/#{api_key}/#{resource}"
"#{path}/api/v2/projects/#{api_key}/#{resource}"
end

def download_resource
Expand Down
6 changes: 5 additions & 1 deletion lib/copycopter_client/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module CopycopterClient
class Configuration

# These options will be present in the Hash returned by {#to_hash}.
OPTIONS = [:api_key, :development_environments, :environment_name, :host,
OPTIONS = [:api_key, :development_environments, :environment_name, :host, :path,
:http_open_timeout, :http_read_timeout, :client_name, :client_url,
:client_version, :port, :protocol, :proxy_host, :proxy_pass,
:proxy_port, :proxy_user, :secure, :polling_delay, :logger,
Expand All @@ -24,6 +24,9 @@ class Configuration
# @return [String] The host to connect to (defaults to +copycopter.com+).
attr_accessor :host

# @return [String] A sub-URI/relative path for all requests (defaults to empty string).
attr_accessor :path

# @return [Fixnum] The port on which your Copycopter server runs (defaults to +443+ for secure connections, +80+ for insecure connections).
attr_accessor :port

Expand Down Expand Up @@ -96,6 +99,7 @@ def initialize
self.client_version = VERSION
self.development_environments = %w(development staging)
self.host = 'copycopter.com'
self.path = ''
self.http_open_timeout = 2
self.http_read_timeout = 5
self.logger = Logger.new($stdout)
Expand Down
1 change: 1 addition & 0 deletions spec/copycopter_client/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
it { should have_config_option(:client_url).overridable.default('https://rubygems.org/gems/copycopter_client') }
it { should have_config_option(:secure).overridable.default(false) }
it { should have_config_option(:host).overridable.default('copycopter.com') }
it { should have_config_option(:path).overridable.default('') }
it { should have_config_option(:http_open_timeout).overridable.default(2) }
it { should have_config_option(:http_read_timeout).overridable.default(5) }
it { should have_config_option(:port).overridable }
Expand Down