qtc-sdk 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/qtc-sdk.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'qtc/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'qtc-sdk'
8
+ spec.version = Qtc::VERSION
9
+ spec.authors = ['Jari Kolehmainen']
10
+ spec.email = ['jari.kolehmainen@digia.com']
11
+ spec.summary = %q{Qt Cloud Services SDK for Ruby}
12
+ spec.description = %q{Qt Cloud Services SDK for Ruby}
13
+ spec.homepage = 'https://github.com/jakolehm/qtc-sdk-ruby'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.5'
22
+ spec.add_development_dependency 'rake'
23
+ spec.add_development_dependency 'rspec', '~> 2.14.0'
24
+ spec.add_development_dependency 'webmock'
25
+ spec.add_development_dependency 'vcr'
26
+ spec.add_runtime_dependency 'httpclient', '~> 2.3'
27
+ spec.add_runtime_dependency 'faye-websocket'
28
+ spec.add_runtime_dependency 'commander'
29
+ spec.add_runtime_dependency 'inifile'
30
+ end
File without changes
@@ -0,0 +1,148 @@
1
+ require 'qtc-sdk'
2
+
3
+
4
+ describe Qtc::Client do
5
+
6
+ let(:test_client) do
7
+ Qtc::Client.new('https://api.qtc.io')
8
+ end
9
+
10
+ describe '#initialize' do
11
+ it 'accepts single parameter (api_url)' do
12
+ expect {
13
+ Qtc::Client.new('https://api.qtc.io')
14
+ }.not_to raise_exception
15
+ end
16
+
17
+ it 'accepts optional second parameter (headers)' do
18
+ expect {
19
+ client = Qtc::Client.new('https://api.qtc.io', {'Foo' => 'Bar'})
20
+ expect(client.default_headers['Foo']).to eq('Bar')
21
+ }.not_to raise_exception
22
+ end
23
+ end
24
+
25
+ describe '#get' do
26
+ it 'sends GET request with correct parameters' do
27
+ params = {test: 1}
28
+ headers = {'X-Test-Header' => 'some_value'}
29
+ test_client.http_client.should_receive(:get).with(
30
+ 'https://api.qtc.io/v1/ping',
31
+ params,
32
+ hash_including(headers)
33
+ ).and_return(double(:response, status: 200).as_null_object)
34
+ test_client.get('/v1/ping', params, headers)
35
+ end
36
+
37
+ it 'raises exception when response is an error' do
38
+ data = {name: 'Test'}
39
+ test_client.http_client.should_receive(:get).and_return(double(:response, status: 400).as_null_object)
40
+ expect {
41
+ test_client.get('/v1/instances', data)
42
+ }.to raise_error(Qtc::Errors::StandardError)
43
+ end
44
+
45
+ it 'returns parsed json responses' do
46
+ data = {'name' => 'Test'}
47
+ test_client.http_client.should_receive(:get).and_return(double(:response, status: 200, body: data.to_json).as_null_object)
48
+ resp = test_client.get('/v1/instances', data)
49
+ expect(resp).to eq(data)
50
+ end
51
+ end
52
+
53
+ describe '#post' do
54
+ it 'sends POST request with correct parameters' do
55
+ data = {name: 'Test'}
56
+ params = {test: 1}
57
+ headers = {'Authorization' => 'Bearer token'}
58
+ test_client.http_client.should_receive(:post).with(
59
+ 'https://api.qtc.io/v1/accounts',
60
+ {
61
+ header: hash_including(headers),
62
+ body: data.to_json,
63
+ query: params
64
+ }
65
+ ).and_return(double(:response, status: 201).as_null_object)
66
+ test_client.post('/v1/accounts', data, params, headers)
67
+ end
68
+
69
+ it 'raises exception when response is an error' do
70
+ data = {name: 'Test'}
71
+ test_client.http_client.should_receive(:post).and_return(double(:response, status: 400).as_null_object)
72
+ expect {
73
+ test_client.post('/v1/accounts', data)
74
+ }.to raise_error(Qtc::Errors::StandardError)
75
+ end
76
+
77
+ it 'returns parsed json responses' do
78
+ data = {'name' => 'Test'}
79
+ test_client.http_client.should_receive(:post).and_return(double(:response, status: 201, body: data.to_json).as_null_object)
80
+ resp = test_client.post('/v1/accounts', data)
81
+ expect(resp).to eq(data)
82
+ end
83
+ end
84
+
85
+ describe '#put' do
86
+ it 'sends PUT request with correct parameters' do
87
+ data = {name: 'Test'}
88
+ params = {test: 1}
89
+ headers = {'Authorization' => 'Bearer token'}
90
+ test_client.http_client.should_receive(:put).with(
91
+ 'https://api.qtc.io/v1/accounts',
92
+ {
93
+ header: hash_including(headers),
94
+ body: data.to_json,
95
+ query: params
96
+ }
97
+ ).and_return(double(:response, status: 201).as_null_object)
98
+ test_client.put('/v1/accounts', data, params, headers)
99
+ end
100
+
101
+ it 'raises exception when response is an error' do
102
+ data = {name: 'Test'}
103
+ test_client.http_client.should_receive(:put).and_return(double(:response, status: 400).as_null_object)
104
+ expect {
105
+ test_client.put('/v1/accounts', data)
106
+ }.to raise_error(Qtc::Errors::StandardError)
107
+ end
108
+
109
+ it 'returns parsed json responses' do
110
+ data = {'name' => 'Test'}
111
+ test_client.http_client.should_receive(:put).and_return(double(:response, status: 201, body: data.to_json).as_null_object)
112
+ resp = test_client.put('/v1/accounts', data)
113
+ expect(resp).to eq(data)
114
+ end
115
+ end
116
+
117
+ describe '#delete' do
118
+ it 'sends DELETE request with correct parameters' do
119
+ data = {name: 'Test'}
120
+ params = {test: 1}
121
+ headers = {'Authorization' => 'Bearer token'}
122
+ test_client.http_client.should_receive(:delete).with(
123
+ 'https://api.qtc.io/v1/accounts',
124
+ {
125
+ header: hash_including(headers),
126
+ body: data.to_json,
127
+ query: params
128
+ }
129
+ ).and_return(double(:response, status: 200).as_null_object)
130
+ test_client.delete('/v1/accounts', data, params, headers)
131
+ end
132
+
133
+ it 'raises exception when response is an error' do
134
+ data = {name: 'Test'}
135
+ test_client.http_client.should_receive(:delete).and_return(double(:response, status: 400).as_null_object)
136
+ expect {
137
+ test_client.delete('/v1/accounts', data)
138
+ }.to raise_error(Qtc::Errors::StandardError)
139
+ end
140
+
141
+ it 'returns parsed json responses' do
142
+ data = {'name' => 'Test'}
143
+ test_client.http_client.should_receive(:delete).and_return(double(:response, status: 200, body: data.to_json).as_null_object)
144
+ resp = test_client.delete('/v1/accounts', data)
145
+ expect(resp).to eq(data)
146
+ end
147
+ end
148
+ end
metadata ADDED
@@ -0,0 +1,204 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: qtc-sdk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jari Kolehmainen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.14.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.14.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: vcr
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: httpclient
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.3'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: faye-websocket
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: commander
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: inifile
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: Qt Cloud Services SDK for Ruby
140
+ email:
141
+ - jari.kolehmainen@digia.com
142
+ executables:
143
+ - qtc-cli
144
+ extensions: []
145
+ extra_rdoc_files: []
146
+ files:
147
+ - ".gitignore"
148
+ - Gemfile
149
+ - LICENSE.txt
150
+ - README.md
151
+ - Rakefile
152
+ - bin/qtc-cli
153
+ - lib/qtc-sdk.rb
154
+ - lib/qtc/cli/clouds.rb
155
+ - lib/qtc/cli/commands.rb
156
+ - lib/qtc/cli/common.rb
157
+ - lib/qtc/cli/eds/base.rb
158
+ - lib/qtc/cli/eds/commands.rb
159
+ - lib/qtc/cli/eds/instances.rb
160
+ - lib/qtc/cli/mar/apps.rb
161
+ - lib/qtc/cli/mar/base.rb
162
+ - lib/qtc/cli/mar/commands.rb
163
+ - lib/qtc/cli/mar/domains.rb
164
+ - lib/qtc/cli/mar/env.rb
165
+ - lib/qtc/cli/mar/ssl_certificates.rb
166
+ - lib/qtc/client.rb
167
+ - lib/qtc/eds/client.rb
168
+ - lib/qtc/eds/collection.rb
169
+ - lib/qtc/eds/user_collection.rb
170
+ - lib/qtc/eds/usergroup_collection.rb
171
+ - lib/qtc/errors.rb
172
+ - lib/qtc/mws/client.rb
173
+ - lib/qtc/version.rb
174
+ - lib/qtc_cli.rb
175
+ - qtc-sdk.gemspec
176
+ - spec/spec_helper.rb
177
+ - spec/unit/qtc/client_spec.rb
178
+ homepage: https://github.com/jakolehm/qtc-sdk-ruby
179
+ licenses:
180
+ - MIT
181
+ metadata: {}
182
+ post_install_message:
183
+ rdoc_options: []
184
+ require_paths:
185
+ - lib
186
+ required_ruby_version: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - ">="
189
+ - !ruby/object:Gem::Version
190
+ version: '0'
191
+ required_rubygems_version: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - ">="
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
196
+ requirements: []
197
+ rubyforge_project:
198
+ rubygems_version: 2.2.2
199
+ signing_key:
200
+ specification_version: 4
201
+ summary: Qt Cloud Services SDK for Ruby
202
+ test_files:
203
+ - spec/spec_helper.rb
204
+ - spec/unit/qtc/client_spec.rb