cc-terminal 0.1.2 → 0.1.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 824b6749992e88f74e46ca0a771d3b3a5e4737a5
4
- data.tar.gz: 2680c8d7ba9f1b40f58d771a28ae250b40c9da8b
3
+ metadata.gz: c71d0775cae380647cc20dce33fd9c1fe2beec53
4
+ data.tar.gz: c1a4e0d4b11f552df0c942d4d263193db27869f9
5
5
  SHA512:
6
- metadata.gz: 8d26804f2f147a260d9520103e7f17a050d2beada6ed5d7a14980c9a90631b7bc39f608a6b9ef05ee816f66e9c4f090b60989e6695eaeae3d467da00a302b682
7
- data.tar.gz: cfbce493620884723fdf480033e24a249b5e80fe67efc1668e75d40ae4408253a1bfa19b5f5ce0ee865757c7a7c036262e275d5816082908b05d453db6b08c4e
6
+ metadata.gz: 01757889515a571efdf93ff738f0ed4747ea582d251d6619a6ddb1eb3655c8d4b5df1d43bf84f3b2c762d89da7cb2b23c53988fe2c83ac3913ab551dff76354f
7
+ data.tar.gz: 89e6830f988afe96d4d7da7943f65ed6668664cbb7bbfe1b9f4efc6e570d7ee634e121fb3be961eadae60d592ece04cd0d5eb150f6719dea5af0207fcb3e34ad
@@ -4,12 +4,10 @@ module Terminal
4
4
  include Terminal::API
5
5
 
6
6
  API_VERSION = "v0.1"
7
- API_URL = 'https://api.terminal.com'
8
- API_PREFIX = API_URL + "/" + API_VERSION + "/"
9
7
 
10
- attr_accessor :user_token, :access_token
8
+ attr_accessor :user_token, :access_token, :api_url, :api_prefix
11
9
 
12
- def initialize( options = {})
10
+ def initialize(options = {})
13
11
  options.each do | k, v |
14
12
  if v.is_a?(Integer)
15
13
  raise Terminal::APIConfigurationError
@@ -17,6 +15,8 @@ module Terminal
17
15
  send(:"#{k}=", v)
18
16
  end
19
17
  yield(self) if block_given?
18
+
19
+ @api_prefix = options[:api_url] + "/" + API_VERSION + "/"
20
20
  end
21
21
 
22
22
  def post(path, params = {} )
@@ -26,7 +26,7 @@ module Terminal
26
26
  private
27
27
 
28
28
  def connection(options = {} )
29
- @connection ||= Faraday.new(API_URL, options) do | conn |
29
+ @connection ||= Faraday.new(@api_url, options) do | conn |
30
30
  conn.request :encode_json
31
31
  conn.adapter :net_http
32
32
 
@@ -40,7 +40,7 @@ module Terminal
40
40
  def request(method, path, params = {})
41
41
  auth = params.delete(:auth)
42
42
  params = params.merge(auth_params) if auth
43
- connection.send(method.to_sym, API_PREFIX + path, params)
43
+ connection.send(method.to_sym, @api_prefix + path, params)
44
44
  rescue Faraday::Error::TimeoutError, Timeout::Error => error
45
45
  raise(Terminal::APITimeoutError.new(error))
46
46
  end
@@ -1,3 +1,3 @@
1
1
  module Terminal
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -8,11 +8,11 @@ if ENV['CIRCLE_ARTIFACTS']
8
8
  end
9
9
 
10
10
  def a_post(path)
11
- a_request(:post, Terminal::Client::API_PREFIX + path)
11
+ a_request(:post, path)
12
12
  end
13
13
 
14
14
  def stub_post(path)
15
- stub_request(:post, Terminal::Client::API_PREFIX + path)
15
+ stub_request(:post, path)
16
16
  end
17
17
 
18
18
  def fixture(file)
@@ -2,7 +2,7 @@ require 'helper'
2
2
 
3
3
  describe Terminal::Client do
4
4
  before do
5
- @client = Terminal::Client.new(:access_token => 'blah', :user_token => 'blah2')
5
+ @client = Terminal::Client.new(:access_token => 'blah', :user_token => 'blah2', :api_url => "https://localhost")
6
6
  end
7
7
 
8
8
  describe 'new instance of the client is defined' do
@@ -14,7 +14,7 @@ describe Terminal::Client do
14
14
  end
15
15
  context 'when no access_token,user_token are provided' do
16
16
  it 'does not raise an exception' do
17
- expect { Terminal::Client.new }.not_to raise_error
17
+ expect { Terminal::Client.new(:api_url => "https://localhost") }.not_to raise_error
18
18
  end
19
19
  end
20
20
  end
@@ -32,7 +32,7 @@ describe Terminal::Client do
32
32
  end
33
33
 
34
34
  it 'raises an API error from a response containing error JSON' do
35
- stub_post('/path').to_return(:body => fixture('error_response.json'), :headers => {:content_type => 'application/json'})
35
+ stub_post(@client.api_prefix + '/path').to_return(:body => fixture('error_response.json'), :headers => {:content_type => 'application/json'})
36
36
  expect { @client.send(:request, :post, '/path') }.to raise_error { |e|
37
37
  e.should be_a(Terminal::APIResponseError)
38
38
  e.response.body[:status].should equal?('failed')
@@ -2,17 +2,17 @@ require 'helper'
2
2
 
3
3
  describe Terminal::Modules::BrowseSnapshotsAndUsers do
4
4
  before do
5
- @client = Terminal::Client.new(:access_token => 'blah', :user_token => 'blah2')
5
+ @client = Terminal::Client.new(:access_token => 'blah', :user_token => 'blah2', :api_url => "https://localhost")
6
6
  end
7
7
 
8
8
  describe "get_snapshot" do
9
9
  before do
10
- stub_post('get_snapshot').to_return(:body => fixture('get_snapshot.json'), :headers => {:content_type => 'application/json'})
10
+ stub_post(@client.api_prefix + 'get_snapshot').to_return(:body => fixture('get_snapshot.json'), :headers => {:content_type => 'application/json'})
11
11
  end
12
12
 
13
13
  it 'calls the proper endpoint' do
14
14
  @client.get_snapshot('some_id')
15
- expect(a_post('get_snapshot')).to have_been_made
15
+ expect(a_post(@client.api_prefix + 'get_snapshot')).to have_been_made
16
16
  end
17
17
 
18
18
  it 'returns a hash with some snapshot information' do
@@ -2,17 +2,17 @@ require 'helper'
2
2
 
3
3
  describe Terminal::Modules::CreateAndManageSnapshots do
4
4
  before do
5
- @client = Terminal::Client.new(:access_token => 'blah', :user_token => 'blah2')
5
+ @client = Terminal::Client.new(:access_token => 'blah', :user_token => 'blah2', :api_url => "https://localhost")
6
6
  end
7
7
 
8
8
  describe "get a list of snapshots" do
9
9
  before do
10
- stub_post('list_snapshots').to_return(:body => fixture('list_snapshots.json'), :headers => {:content_type => 'application/json'})
10
+ stub_post(@client.api_prefix + 'list_snapshots').to_return(:body => fixture('list_snapshots.json'), :headers => {:content_type => 'application/json'})
11
11
  end
12
12
 
13
13
  it 'posts to the proper endpoint' do
14
14
  @client.list_snapshots
15
- expect(a_post('list_snapshots')).to have_been_made
15
+ expect(a_post(@client.api_prefix + 'list_snapshots')).to have_been_made
16
16
  end
17
17
 
18
18
  it 'contains a response that has some snapshots' do
@@ -2,17 +2,17 @@ require 'helper'
2
2
 
3
3
  describe Terminal::Modules::CreateAndManageTerminals do
4
4
  before do
5
- @client = Terminal::Client.new(:access_token => 'blah', :user_token => 'blah2')
5
+ @client = Terminal::Client.new(:access_token => 'blah', :user_token => 'blah2', :api_url => "https://localhost")
6
6
  end
7
7
 
8
8
  describe "get a list of terminals" do
9
9
  before do
10
- stub_post('list_terminals').to_return(:body => fixture('list_terminals.json'), :headers => {:content_type => 'application/json'})
10
+ stub_post(@client.api_prefix + 'list_terminals').to_return(:body => fixture('list_terminals.json'), :headers => {:content_type => 'application/json'})
11
11
  end
12
12
 
13
13
  it 'posts to the proper endpoint' do
14
14
  @client.list_terminals
15
- expect(a_post('list_terminals')).to have_been_made
15
+ expect(a_post(@client.api_prefix + 'list_terminals')).to have_been_made
16
16
  end
17
17
 
18
18
  it 'contains a response that has some terminals' do
@@ -2,17 +2,17 @@ require 'helper'
2
2
 
3
3
  describe Terminal::Modules::RequestProgress do
4
4
  before do
5
- @client = Terminal::Client.new(:access_token => 'blah', :user_token => 'blah2')
5
+ @client = Terminal::Client.new(:access_token => 'blah', :user_token => 'blah2', :api_url => "https://localhost")
6
6
  end
7
7
 
8
8
  describe "Request progress endpoint called" do
9
9
  before do
10
- stub_post('request_progress').to_return(:body => fixture('request_progress.json'), :headers => {:content_type => 'application/json'})
10
+ stub_post(@client.api_prefix + 'request_progress').to_return(:body => fixture('request_progress.json'), :headers => {:content_type => 'application/json'})
11
11
  end
12
12
 
13
13
  it 'posts to the proper endpoint' do
14
14
  @client.request_progress(:request_id => "testestest")
15
- expect(a_post('request_progress')).to have_been_made
15
+ expect(a_post(@client.api_prefix + 'request_progress')).to have_been_made
16
16
  end
17
17
 
18
18
  it 'returns a hash that is properly formed' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cc-terminal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timor Tsentsiper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-15 00:00:00.000000000 Z
11
+ date: 2016-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json