mortar-api-ruby 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -1
- data/lib/mortar/api.rb +1 -0
- data/lib/mortar/api/config.rb +53 -0
- data/lib/mortar/api/version.rb +1 -1
- data/spec/mortar/api/config_spec.rb +69 -0
- metadata +91 -100
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm use 1.
|
1
|
+
rvm use 1.9.3@mortar --create
|
data/lib/mortar/api.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2012 Mortar Data Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
# Portions of this code from heroku (https://github.com/heroku/heroku/) Copyright Heroku 2008 - 2013,
|
17
|
+
# used under an MIT license (https://github.com/heroku/heroku/blob/master/LICENSE).
|
18
|
+
#
|
19
|
+
|
20
|
+
module Mortar
|
21
|
+
class API
|
22
|
+
|
23
|
+
# PUT /vX/config/:project_name
|
24
|
+
def put_config_vars(project_name, config_vars)
|
25
|
+
request(
|
26
|
+
:expects => 200,
|
27
|
+
:method => :put,
|
28
|
+
:path => versioned_path("/config/#{escape(project_name)}"),
|
29
|
+
:body => json_encode(config_vars)
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
# GET /vX/config/:project_name
|
34
|
+
def get_config_vars(project_name)
|
35
|
+
request(
|
36
|
+
:expects => 200,
|
37
|
+
:method => :get,
|
38
|
+
:path => versioned_path("/config/#{escape(project_name)}")
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
# DELETE /vX/config/:project_name
|
43
|
+
def delete_config_var(project_name, config_var)
|
44
|
+
body = {'key' => config_var}
|
45
|
+
request(
|
46
|
+
:expects => 200,
|
47
|
+
:method => :delete,
|
48
|
+
:path => versioned_path("/config/#{escape(project_name)}"),
|
49
|
+
:body => json_encode(body)
|
50
|
+
)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/mortar/api/version.rb
CHANGED
@@ -0,0 +1,69 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2012 Mortar Data Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require "base64"
|
18
|
+
require "spec_helper"
|
19
|
+
require "mortar/api"
|
20
|
+
|
21
|
+
|
22
|
+
describe Mortar::API do
|
23
|
+
|
24
|
+
before(:each) do
|
25
|
+
@api = Mortar::API.new
|
26
|
+
end
|
27
|
+
|
28
|
+
after(:each) do
|
29
|
+
Excon.stubs.clear
|
30
|
+
end
|
31
|
+
|
32
|
+
context "config" do
|
33
|
+
it "puts config vars" do
|
34
|
+
project_name = "my_project needs escaping"
|
35
|
+
config_vars = {"a" => "foo", "B" => "BAR"}
|
36
|
+
body = Mortar::API::OkJson.encode(config_vars)
|
37
|
+
Excon.stub({:method => :put, :path => "/v2/config/my_project+needs+escaping", :body => body}) do |params|
|
38
|
+
{:body => "", :status => 200}
|
39
|
+
end
|
40
|
+
response = @api.put_config_vars(project_name, config_vars)
|
41
|
+
response.body.should == ''
|
42
|
+
end
|
43
|
+
|
44
|
+
it "gets config vars" do
|
45
|
+
project_name = "my_project needs escaping"
|
46
|
+
Excon.stub({:method => :get, :path => "/v2/config/my_project+needs+escaping"}) do |params|
|
47
|
+
{:body => Mortar::API::OkJson.encode({"config" => {"a" => "foo", "B" => "BAR"}}),
|
48
|
+
:status => 200}
|
49
|
+
end
|
50
|
+
response = @api.get_config_vars(project_name)
|
51
|
+
config_vars = response.body["config"]
|
52
|
+
config_vars["a"].should == "foo"
|
53
|
+
config_vars["B"].should == "BAR"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "unset a config var" do
|
57
|
+
project_name = "my_project needs escaping"
|
58
|
+
var_name = "MY_VAR"
|
59
|
+
Excon.stub({:method => :delete,
|
60
|
+
:path => "/v2/config/my_project+needs+escaping",
|
61
|
+
:body => Mortar::API::OkJson.encode({'key' => var_name})}) do |params|
|
62
|
+
{:body => "", :status => 200}
|
63
|
+
end
|
64
|
+
response = @api.delete_config_var(project_name, var_name)
|
65
|
+
config_vars = response.body.should == ""
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
metadata
CHANGED
@@ -1,109 +1,108 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: mortar-api-ruby
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.7.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 7
|
9
|
-
- 0
|
10
|
-
version: 0.7.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Mortar Data
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-11-06 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: excon
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
18
|
+
requirements:
|
26
19
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
- 15
|
32
|
-
version: "0.15"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0.15'
|
33
22
|
- - <
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
|
36
|
-
segments:
|
37
|
-
- 0
|
38
|
-
- 17
|
39
|
-
version: "0.17"
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '0.17'
|
40
25
|
type: :runtime
|
41
|
-
version_requirements: *id001
|
42
|
-
- !ruby/object:Gem::Dependency
|
43
|
-
name: gem-release
|
44
26
|
prerelease: false
|
45
|
-
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
28
|
none: false
|
47
|
-
requirements:
|
48
|
-
- -
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
version:
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0.15'
|
33
|
+
- - <
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0.17'
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: gem-release
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
54
44
|
type: :development
|
55
|
-
version_requirements: *id002
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
name: rake
|
58
45
|
prerelease: false
|
59
|
-
|
46
|
+
version_requirements: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: rake
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
60
55
|
none: false
|
61
|
-
requirements:
|
62
|
-
- -
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
|
65
|
-
segments:
|
66
|
-
- 0
|
67
|
-
version: "0"
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
68
60
|
type: :development
|
69
|
-
version_requirements: *id003
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: rr
|
72
61
|
prerelease: false
|
73
|
-
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: rr
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
74
71
|
none: false
|
75
|
-
requirements:
|
76
|
-
- -
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
|
79
|
-
segments:
|
80
|
-
- 0
|
81
|
-
version: "0"
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
82
76
|
type: :development
|
83
|
-
version_requirements: *id004
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
|
-
name: rspec
|
86
77
|
prerelease: false
|
87
|
-
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
88
79
|
none: false
|
89
|
-
requirements:
|
90
|
-
- -
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rspec
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
96
92
|
type: :development
|
97
|
-
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ! '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
98
100
|
description: Client for Mortar API.
|
99
101
|
email: support@mortardata.com
|
100
102
|
executables: []
|
101
|
-
|
102
103
|
extensions: []
|
103
|
-
|
104
104
|
extra_rdoc_files: []
|
105
|
-
|
106
|
-
files:
|
105
|
+
files:
|
107
106
|
- .gitignore
|
108
107
|
- .rvmrc
|
109
108
|
- .travis.yml
|
@@ -116,6 +115,7 @@ files:
|
|
116
115
|
- lib/mortar/api.rb
|
117
116
|
- lib/mortar/api/basicauth.rb
|
118
117
|
- lib/mortar/api/clusters.rb
|
118
|
+
- lib/mortar/api/config.rb
|
119
119
|
- lib/mortar/api/describe.rb
|
120
120
|
- lib/mortar/api/errors.rb
|
121
121
|
- lib/mortar/api/fixtures.rb
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- mortar-api-ruby.gemspec
|
132
132
|
- spec/mortar/api/basicauth_spec.rb
|
133
133
|
- spec/mortar/api/clusters_spec.rb
|
134
|
+
- spec/mortar/api/config_spec.rb
|
134
135
|
- spec/mortar/api/describe_spec.rb
|
135
136
|
- spec/mortar/api/errors_spec.rb
|
136
137
|
- spec/mortar/api/fixtures_spec.rb
|
@@ -146,42 +147,32 @@ files:
|
|
146
147
|
- spec/spec_helper.rb
|
147
148
|
homepage: http://mortardata.com/
|
148
149
|
licenses: []
|
149
|
-
|
150
150
|
post_install_message:
|
151
151
|
rdoc_options: []
|
152
|
-
|
153
|
-
require_paths:
|
152
|
+
require_paths:
|
154
153
|
- lib
|
155
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
154
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
156
155
|
none: false
|
157
|
-
requirements:
|
158
|
-
- -
|
159
|
-
- !ruby/object:Gem::Version
|
160
|
-
hash: 57
|
161
|
-
segments:
|
162
|
-
- 1
|
163
|
-
- 8
|
164
|
-
- 7
|
156
|
+
requirements:
|
157
|
+
- - ! '>='
|
158
|
+
- !ruby/object:Gem::Version
|
165
159
|
version: 1.8.7
|
166
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
161
|
none: false
|
168
|
-
requirements:
|
169
|
-
- -
|
170
|
-
- !ruby/object:Gem::Version
|
171
|
-
|
172
|
-
segments:
|
173
|
-
- 0
|
174
|
-
version: "0"
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
175
166
|
requirements: []
|
176
|
-
|
177
167
|
rubyforge_project:
|
178
|
-
rubygems_version: 1.8.
|
168
|
+
rubygems_version: 1.8.23
|
179
169
|
signing_key:
|
180
170
|
specification_version: 3
|
181
171
|
summary: Client for Mortar API
|
182
|
-
test_files:
|
172
|
+
test_files:
|
183
173
|
- spec/mortar/api/basicauth_spec.rb
|
184
174
|
- spec/mortar/api/clusters_spec.rb
|
175
|
+
- spec/mortar/api/config_spec.rb
|
185
176
|
- spec/mortar/api/describe_spec.rb
|
186
177
|
- spec/mortar/api/errors_spec.rb
|
187
178
|
- spec/mortar/api/fixtures_spec.rb
|