heroku-api 0.3.15 → 0.3.16

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -12,5 +12,7 @@ rvm:
12
12
  - 1.8.7
13
13
  - 1.9.2
14
14
  - 1.9.3
15
+ - 2.0.0
16
+ - 2.1.0
15
17
 
16
18
  script: bundle exec rake
data/Rakefile CHANGED
@@ -16,14 +16,14 @@ task :cache, [:api_key] do |task, args|
16
16
  require "#{File.dirname(__FILE__)}/lib/heroku/api"
17
17
  heroku = Heroku::API.new(:api_key => args.api_key)
18
18
 
19
- addons = Heroku::API::OkJson.encode(heroku.get_addons.body)
19
+ addons = MultiJson.dump(heroku.get_addons.body)
20
20
  File.open("#{File.dirname(__FILE__)}/lib/heroku/api/mock/cache/get_addons.json", 'w') do |file|
21
21
  file.write(addons)
22
22
  end
23
23
 
24
24
  app_name = "heroku-api-#{Time.now.to_i}"
25
25
  app = heroku.post_app('name' => app_name)
26
- features = Heroku::API::OkJson.encode(heroku.get_features(app_name).body)
26
+ features = MultiJson.dump(heroku.get_features(app_name).body)
27
27
  File.open("#{File.dirname(__FILE__)}/lib/heroku/api/mock/cache/get_features.json", 'w') do |file|
28
28
  file.write(features)
29
29
  end
@@ -32,7 +32,7 @@ task :cache, [:api_key] do |task, args|
32
32
  user = heroku.get_user.body
33
33
  user["email"] = "user@example.com"
34
34
  user["id"] = "123456@users.heroku.com"
35
- user = Heroku::API::OkJson.encode(user)
35
+ user = MultiJson.dump(user)
36
36
  File.open("#{File.dirname(__FILE__)}/lib/heroku/api/mock/cache/get_user.json", 'w') do |file|
37
37
  file.write(user)
38
38
  end
data/changelog.txt CHANGED
@@ -1,7 +1,15 @@
1
+ 0.3.16 01/06/2013
2
+ =================
3
+
4
+ add process types
5
+ use multi_json instead of okjson
6
+ fix for escaping collaborator emails in requests
7
+ loosen excon dependency
8
+
1
9
  0.3.15 11/03/2013
2
10
  =================
3
11
 
4
- add get__dyno_types for retrieving process types
12
+ add get_dyno_types for retrieving process types
5
13
 
6
14
  0.3.14 07/03/2013
7
15
  =================
data/heroku-api.gemspec CHANGED
@@ -8,6 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.authors = ["geemus (Wesley Beary)", "Pedro Belo"]
9
9
  s.email = ["wesley@heroku.com", "pedro@heroku.com"]
10
10
  s.homepage = "http://github.com/heroku/heroku.rb"
11
+ s.license = 'MIT'
11
12
  s.summary = %q{Ruby Client for the Heroku API}
12
13
  s.description = %q{Ruby Client for the Heroku API}
13
14
 
@@ -16,7 +17,8 @@ Gem::Specification.new do |s|
16
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
18
  s.require_paths = ["lib"]
18
19
 
19
- s.add_runtime_dependency 'excon', '~>0.25.1'
20
+ s.add_runtime_dependency 'excon', '~>0.27'
21
+ s.add_runtime_dependency 'multi_json', '~>1.8.2'
20
22
 
21
23
  s.add_development_dependency 'minitest'
22
24
  s.add_development_dependency 'rake'
@@ -6,7 +6,7 @@ module Heroku
6
6
  request(
7
7
  :expects => 200,
8
8
  :method => :delete,
9
- :path => "/apps/#{app}/collaborators/#{email}"
9
+ :path => "/apps/#{app}/collaborators/#{CGI.escape(email)}"
10
10
  )
11
11
  end
12
12
 
@@ -22,7 +22,7 @@ module Heroku
22
22
  # PUT /apps/:app/config_vars
23
23
  def put_config_vars(app, vars)
24
24
  request(
25
- :body => Heroku::API::OkJson.encode(vars),
25
+ :body => MultiJson.dump(vars),
26
26
  :expects => 200,
27
27
  :method => :put,
28
28
  :path => "/apps/#{app}/config_vars"
@@ -14,7 +14,7 @@ module Heroku
14
14
  # addon is currently installed
15
15
  remove_mock_app_addon(mock_data, app, addon)
16
16
  {
17
- :body => Heroku::API::OkJson.encode({
17
+ :body => MultiJson.dump({
18
18
  "message" => nil,
19
19
  "price" => get_mock_addon_price(mock_data, addon),
20
20
  "status" => 'Uninstalled'
@@ -24,14 +24,14 @@ module Heroku
24
24
  else
25
25
  # addon is not currently installed
26
26
  {
27
- :body => Heroku::API::OkJson.encode({'error' => "The add-on #{addon} is not installed for this app. Did you mean:\n\t#{addon_names.join("\n\t")}"}),
27
+ :body => MultiJson.dump({'error' => "The add-on #{addon} is not installed for this app. Did you mean:\n\t#{addon_names.join("\n\t")}"}),
28
28
  :status => 422
29
29
  }
30
30
  end
31
31
  else
32
32
  # addon does not exist
33
33
  {
34
- :body => Heroku::API::OkJson.encode({'error' => "Could not find add-on #{addon}. Did you mean:\n\t#{addon_names.join("\n\t")}"}),
34
+ :body => MultiJson.dump({'error' => "Could not find add-on #{addon}. Did you mean:\n\t#{addon_names.join("\n\t")}"}),
35
35
  :status => 422
36
36
  }
37
37
  end
@@ -53,7 +53,7 @@ module Heroku
53
53
  app, _ = request_params[:captures][:path]
54
54
  with_mock_app(mock_data, app) do
55
55
  {
56
- :body => Heroku::API::OkJson.encode(mock_data[:addons][app].map {|addon| addon['configured'] = true; addon}),
56
+ :body => MultiJson.dump(mock_data[:addons][app].map {|addon| addon['configured'] = true; addon}),
57
57
  :status => 200
58
58
  }
59
59
  end
@@ -72,7 +72,7 @@ module Heroku
72
72
  # addon is not currently installed
73
73
  add_mock_app_addon(mock_data, app, addon)
74
74
  {
75
- :body => Heroku::API::OkJson.encode({
75
+ :body => MultiJson.dump({
76
76
  "message" => nil,
77
77
  "price" => get_mock_addon_price(mock_data, addon),
78
78
  "status" => 'Installed'
@@ -82,21 +82,21 @@ module Heroku
82
82
  else
83
83
  # addon is currently installed
84
84
  {
85
- :body => Heroku::API::OkJson.encode({'error' => "Add-on already installed."}),
85
+ :body => MultiJson.dump({'error' => "Add-on already installed."}),
86
86
  :status => 422
87
87
  }
88
88
  end
89
89
  else
90
90
  # addon of same type exists
91
91
  {
92
- :body => Heroku::API::OkJson.encode({'error' => "#{app_addon_type_data['name']} add-on already added.\nTo upgrade, use addons:upgrade instead.\n"}),
92
+ :body => MultiJson.dump({'error' => "#{app_addon_type_data['name']} add-on already added.\nTo upgrade, use addons:upgrade instead.\n"}),
93
93
  :status => 422
94
94
  }
95
95
  end
96
96
  else
97
97
  # addon does not exist
98
98
  {
99
- :body => Heroku::API::OkJson.encode({'error' => "Add-on not found."}),
99
+ :body => MultiJson.dump({'error' => "Add-on not found."}),
100
100
  :status => 404
101
101
  }
102
102
  end
@@ -117,7 +117,7 @@ module Heroku
117
117
  mock_data[:addons][app].delete(app_addon_data)
118
118
  add_mock_app_addon(mock_data, app, addon)
119
119
  {
120
- :body => Heroku::API::OkJson.encode({
120
+ :body => MultiJson.dump({
121
121
  "message" => 'Plan upgraded',
122
122
  "price" => get_mock_addon_price(mock_data, addon),
123
123
  "status" => 'Updated'
@@ -127,21 +127,21 @@ module Heroku
127
127
  else
128
128
  # addon is currently installed
129
129
  {
130
- :body => Heroku::API::OkJson.encode({'error' => "Add-on already installed."}),
130
+ :body => MultiJson.dump({'error' => "Add-on already installed."}),
131
131
  :status => 422
132
132
  }
133
133
  end
134
134
  else
135
135
  # addon of same type not installed
136
136
  {
137
- :body => Heroku::API::OkJson.encode({'error' => "Can't upgrade, no #{addon.split(':').join(' ')} add-on has been added.\nTo add, use addons:add instead.\n"}),
137
+ :body => MultiJson.dump({'error' => "Can't upgrade, no #{addon.split(':').join(' ')} add-on has been added.\nTo add, use addons:add instead.\n"}),
138
138
  :status => 422
139
139
  }
140
140
  end
141
141
  else
142
142
  # addon does not exist
143
143
  {
144
- :body => Heroku::API::OkJson.encode({'error' => "Add-on not found."}),
144
+ :body => MultiJson.dump({'error' => "Add-on not found."}),
145
145
  :status => 404
146
146
  }
147
147
  end
@@ -17,7 +17,7 @@ module Heroku
17
17
  mock_data[:ps].delete(app)
18
18
  mock_data[:releases].delete(app)
19
19
  {
20
- :body => Heroku::API::OkJson.encode({}),
20
+ :body => MultiJson.dump({}),
21
21
  :status => 200
22
22
  }
23
23
  end
@@ -27,7 +27,7 @@ module Heroku
27
27
  Excon.stub(:expects => 200, :method => :get, :path => '/apps') do |params|
28
28
  request_params, mock_data = parse_stub_params(params)
29
29
  {
30
- :body => Heroku::API::OkJson.encode(mock_data[:apps]),
30
+ :body => MultiJson.dump(mock_data[:apps]),
31
31
  :status => 200
32
32
  }
33
33
  end
@@ -38,7 +38,7 @@ module Heroku
38
38
  app, _ = request_params[:captures][:path]
39
39
  with_mock_app(mock_data, app) do |app_data|
40
40
  {
41
- :body => Heroku::API::OkJson.encode(app_data),
41
+ :body => MultiJson.dump(app_data),
42
42
  :status => 200
43
43
  }
44
44
  end
@@ -52,7 +52,7 @@ module Heroku
52
52
  with_mock_app(mock_data, app) do
53
53
  maintenance = mock_data[:maintenance_mode].include?(app)
54
54
  {
55
- :body => Heroku::API::OkJson.encode('maintenance' => maintenance),
55
+ :body => MultiJson.dump('maintenance' => maintenance),
56
56
  :status => 200
57
57
  }
58
58
  end
@@ -65,7 +65,7 @@ module Heroku
65
65
 
66
66
  if get_mock_app(mock_data, app)
67
67
  {
68
- :body => Heroku::API::OkJson.encode('error' => 'Name is already taken'),
68
+ :body => MultiJson.dump('error' => 'Name is already taken'),
69
69
  :status => 422
70
70
  }
71
71
  else
@@ -130,7 +130,7 @@ module Heroku
130
130
  end
131
131
 
132
132
  {
133
- :body => Heroku::API::OkJson.encode(app_data),
133
+ :body => MultiJson.dump(app_data),
134
134
  :status => 202
135
135
  }
136
136
  end
@@ -175,12 +175,12 @@ module Heroku
175
175
  end
176
176
  if email && !collaborator
177
177
  {
178
- :body => Heroku::API::OkJson.encode('error' => 'Only existing collaborators can receive ownership for an app'),
178
+ :body => MultiJson.dump('error' => 'Only existing collaborators can receive ownership for an app'),
179
179
  :status => 422
180
180
  }
181
181
  else
182
182
  {
183
- :body => Heroku::API::OkJson.encode('name' => app_data['name']),
183
+ :body => MultiJson.dump('name' => app_data['name']),
184
184
  :status => 200
185
185
  }
186
186
  end
@@ -194,7 +194,7 @@ module Heroku
194
194
 
195
195
  with_mock_app(mock_data, app) do |app_data|
196
196
  {
197
- :body => Heroku::API::OkJson.encode({}),
197
+ :body => MultiJson.dump({}),
198
198
  :status => 201
199
199
  }
200
200
  end
@@ -8,7 +8,7 @@ module Heroku
8
8
  app, _ = request_params[:captures][:path]
9
9
  with_mock_app(mock_data, app) do
10
10
  {
11
- :body => Heroku::API::OkJson.encode(mock_data[:attachments][app]),
11
+ :body => MultiJson.dump(mock_data[:attachments][app]),
12
12
  :status => 200
13
13
  }
14
14
  end
@@ -6,6 +6,7 @@ module Heroku
6
6
  Excon.stub(:expects => 200, :method => :delete, :path => %r{^/apps/([^/]+)/collaborators/([^/]+)$}) do |params|
7
7
  request_params, mock_data = parse_stub_params(params)
8
8
  app, email, _ = request_params[:captures][:path]
9
+ email = CGI.unescape(email)
9
10
  with_mock_app(mock_data, app) do
10
11
  if collaborator_data = get_mock_collaborator(mock_data, app, email)
11
12
  mock_data[:collaborators][app].delete(collaborator_data)
@@ -25,7 +26,7 @@ module Heroku
25
26
  app, _ = request_params[:captures][:path]
26
27
  with_mock_app(mock_data, app) do
27
28
  {
28
- :body => Heroku::API::OkJson.encode(mock_data[:collaborators][app]),
29
+ :body => MultiJson.dump(mock_data[:collaborators][app]),
29
30
  :status => 200
30
31
  }
31
32
  end
@@ -11,7 +11,7 @@ module Heroku
11
11
  mock_data[:config_vars][app].delete(key)
12
12
  add_mock_release(mock_data, app, {'descr' => "Config remove #{key}"})
13
13
  {
14
- :body => Heroku::API::OkJson.encode(mock_data[:config_vars][app]),
14
+ :body => MultiJson.dump(mock_data[:config_vars][app]),
15
15
  :status => 200
16
16
  }
17
17
  end
@@ -23,7 +23,7 @@ module Heroku
23
23
  app, _ = request_params[:captures][:path]
24
24
  with_mock_app(mock_data, app) do
25
25
  {
26
- :body => Heroku::API::OkJson.encode(mock_data[:config_vars][app]),
26
+ :body => MultiJson.dump(mock_data[:config_vars][app]),
27
27
  :status => 200
28
28
  }
29
29
  end
@@ -38,7 +38,7 @@ module Heroku
38
38
  mock_data[:config_vars][app].merge!(new_config_vars)
39
39
  add_mock_release(mock_data, app, {'descr' => "Config add #{new_config_vars.keys.join(', ')}"})
40
40
  {
41
- :body => Heroku::API::OkJson.encode(mock_data[:config_vars][app]),
41
+ :body => MultiJson.dump(mock_data[:config_vars][app]),
42
42
  :status => 200
43
43
  }
44
44
  end
@@ -45,7 +45,7 @@ module Heroku
45
45
  app, _ = request_params[:captures][:path]
46
46
  with_mock_app(mock_data, app) do |app_data|
47
47
  {
48
- :body => Heroku::API::OkJson.encode(mock_data[:domains][app]),
48
+ :body => MultiJson.dump(mock_data[:domains][app]),
49
49
  :status => 200
50
50
  }
51
51
  end
@@ -69,7 +69,7 @@ module Heroku
69
69
  }
70
70
  end
71
71
  {
72
- :body => Heroku::API::OkJson.encode('domain' => domain),
72
+ :body => MultiJson.dump('domain' => domain),
73
73
  :status => 201
74
74
  }
75
75
  end
@@ -16,20 +16,20 @@ module Heroku
16
16
  when 'app'
17
17
  mock_data[:features][:app][app].delete(feature_data)
18
18
  {
19
- :body => Heroku::API::OkJson.encode(feature_data.merge('enabled' => false)),
19
+ :body => MultiJson.dump(feature_data.merge('enabled' => false)),
20
20
  :status => 200
21
21
  }
22
22
  when 'user'
23
23
  mock_data[:features][:user].delete(feature_data.merge('enabled' => false))
24
24
  {
25
- :body => Heroku::API::OkJson.encode(feature_data),
25
+ :body => MultiJson.dump(feature_data),
26
26
  :status => 200
27
27
  }
28
28
  end
29
29
  else
30
30
  # feature does not exist
31
31
  {
32
- :body => Heroku::API::OkJson.encode({'error' => "Feature not found."}),
32
+ :body => MultiJson.dump({'error' => "Feature not found."}),
33
33
  :status => 404
34
34
  }
35
35
  end
@@ -56,13 +56,13 @@ module Heroku
56
56
  feature, _ = request_params[:captures][:path]
57
57
  if feature_data = get_mock_feature(mock_data, feature)
58
58
  {
59
- :body => Heroku::API::OkJson.encode(feature_data),
59
+ :body => MultiJson.dump(feature_data),
60
60
  :status => 200
61
61
  }
62
62
  else
63
63
  # feature does not exist
64
64
  {
65
- :body => Heroku::API::OkJson.encode({'error' => "Feature not found."}),
65
+ :body => MultiJson.dump({'error' => "Feature not found."}),
66
66
  :status => 404
67
67
  }
68
68
  end
@@ -87,7 +87,7 @@ module Heroku
87
87
  201
88
88
  end
89
89
  {
90
- :body => Heroku::API::OkJson.encode(feature_data),
90
+ :body => MultiJson.dump(feature_data),
91
91
  :status => status
92
92
  }
93
93
  when 'user'
@@ -105,7 +105,7 @@ module Heroku
105
105
  else
106
106
  # feature does not exist
107
107
  {
108
- :body => Heroku::API::OkJson.encode({'error' => "Feature not found."}),
108
+ :body => MultiJson.dump({'error' => "Feature not found."}),
109
109
  :status => 404
110
110
  }
111
111
  end
@@ -26,7 +26,7 @@ module Heroku
26
26
  Excon.stub(:expects => 200, :method => :get, :path => %r{^/user/keys}) do |params|
27
27
  request_params, mock_data = parse_stub_params(params)
28
28
  {
29
- :body => Heroku::API::OkJson.encode(mock_data[:keys]),
29
+ :body => MultiJson.dump(mock_data[:keys]),
30
30
  :status => 200
31
31
  }
32
32
  end
@@ -8,7 +8,7 @@ module Heroku
8
8
  app, _ = request_params[:captures][:path]
9
9
  with_mock_app(mock_data, app) do |app_data|
10
10
  {
11
- :body => Heroku::API::OkJson.encode(get_mock_processes(mock_data, app)),
11
+ :body => MultiJson.dump(get_mock_processes(mock_data, app)),
12
12
  :status => 200
13
13
  }
14
14
  end
@@ -43,7 +43,7 @@ module Heroku
43
43
  }
44
44
  mock_data[:ps][app] << data
45
45
  {
46
- :body => Heroku::API::OkJson.encode(data),
46
+ :body => MultiJson.dump(data),
47
47
  :status => 200,
48
48
  }
49
49
  end
@@ -117,13 +117,13 @@ module Heroku
117
117
  }
118
118
  else
119
119
  {
120
- :body => Heroku::API::OkJson.encode('error' => "No such type as #{type}") ,
120
+ :body => MultiJson.dump('error' => "No such type as #{type}") ,
121
121
  :status => 422
122
122
  }
123
123
  end
124
124
  else
125
125
  {
126
- :body => Heroku::API::OkJson.encode('error' => "That feature is not available on this app's stack"),
126
+ :body => MultiJson.dump('error' => "That feature is not available on this app's stack"),
127
127
  :status => 422
128
128
  }
129
129
  end
@@ -139,7 +139,7 @@ module Heroku
139
139
  type = request_params[:query].has_key?('type') && request_params[:query]['type']
140
140
  if !ps && !type
141
141
  {
142
- :body => Heroku::API::OkJson.encode({'error' => 'Missing process argument'}),
142
+ :body => MultiJson.dump({'error' => 'Missing process argument'}),
143
143
  :status => 422
144
144
  }
145
145
  else
@@ -160,12 +160,12 @@ module Heroku
160
160
  unless app_data['stack'] == 'cedar'
161
161
  app_data['dynos'] = dynos
162
162
  {
163
- :body => Heroku::API::OkJson.encode({'name' => app, 'dynos' => dynos}),
163
+ :body => MultiJson.dump({'name' => app, 'dynos' => dynos}),
164
164
  :status => 200
165
165
  }
166
166
  else
167
167
  {
168
- :body => Heroku::API::OkJson.encode({'error' => "For Cedar apps, use `heroku scale web=#{dynos}`"}),
168
+ :body => MultiJson.dump({'error' => "For Cedar apps, use `heroku scale web=#{dynos}`"}),
169
169
  :status => 422
170
170
  }
171
171
  end
@@ -181,12 +181,12 @@ module Heroku
181
181
  unless app_data['stack'] == 'cedar'
182
182
  app_data['workers'] = workers
183
183
  {
184
- :body => Heroku::API::OkJson.encode({'name' => app, 'workers' => workers}),
184
+ :body => MultiJson.dump({'name' => app, 'workers' => workers}),
185
185
  :status => 200
186
186
  }
187
187
  else
188
188
  {
189
- :body => Heroku::API::OkJson.encode({'error' => "For Cedar apps, use `heroku scale worker=#{workers}`"}),
189
+ :body => MultiJson.dump({'error' => "For Cedar apps, use `heroku scale worker=#{workers}`"}),
190
190
  :status => 422
191
191
  }
192
192
  end
@@ -203,7 +203,7 @@ module Heroku
203
203
  size = new_resize_vars[process]["size"][/(\d+)/]
204
204
  mock_data[:ps][app].first.merge!({'size' => size})
205
205
  {
206
- :body => Heroku::API::OkJson.encode(get_mock_processes(mock_data, app)),
206
+ :body => MultiJson.dump(get_mock_processes(mock_data, app)),
207
207
  :status => 200
208
208
  }
209
209
  end
@@ -215,7 +215,7 @@ module Heroku
215
215
  app, _ = request_params[:captures][:path]
216
216
  with_mock_app(mock_data, app) do |app_data|
217
217
  {
218
- :body => Heroku::API::OkJson.encode([{"command"=>"bundle exec rails console", "name"=>"console", "quantity"=>0}]),
218
+ :body => MultiJson.dump([{"command"=>"bundle exec rails console", "name"=>"console", "quantity"=>0}]),
219
219
  :status => 200
220
220
  }
221
221
  end
@@ -8,7 +8,7 @@ module Heroku
8
8
  app, _ = request_params[:captures][:path]
9
9
  with_mock_app(mock_data, app) do |app_data|
10
10
  {
11
- :body => Heroku::API::OkJson.encode(mock_data[:releases][app]),
11
+ :body => MultiJson.dump(mock_data[:releases][app]),
12
12
  :status => 200
13
13
  }
14
14
  end
@@ -22,7 +22,7 @@ module Heroku
22
22
  releases = mock_data[:releases][app]
23
23
  if release_data = (release_name == 'current' && releases.last) || releases.detect {|release| release['name'] == release_name}
24
24
  {
25
- :body => Heroku::API::OkJson.encode(release_data),
25
+ :body => MultiJson.dump(release_data),
26
26
  :status => 200
27
27
  }
28
28
  else
@@ -51,7 +51,7 @@ module Heroku
51
51
  }
52
52
  else
53
53
  {
54
- :body => Heroku::API::OkJson.encode({'error' => 'Cannot rollback to a release that had a different set of addons installed'}),
54
+ :body => MultiJson.dump({'error' => 'Cannot rollback to a release that had a different set of addons installed'}),
55
55
  :status => 422
56
56
  }
57
57
  end
@@ -37,7 +37,7 @@ module Heroku
37
37
  stack_data = Marshal::load(Marshal.dump(STACKS))
38
38
  stack_data.detect {|stack| stack['name'] == app_data['stack']}['current'] = true
39
39
  {
40
- :body => Heroku::API::OkJson.encode(stack_data),
40
+ :body => MultiJson.dump(stack_data),
41
41
  :status => 200
42
42
  }
43
43
  end
@@ -65,13 +65,13 @@ BODY
65
65
  }
66
66
  else
67
67
  {
68
- :body => Heroku::API::OkJson.encode('error' => 'Stack not found'),
68
+ :body => MultiJson.dump('error' => 'Stack not found'),
69
69
  :status => 404
70
70
  }
71
71
  end
72
72
  else
73
73
  {
74
- :body => Heroku::API::OkJson.encode('error' => 'Stack migration to/from Cedar is not available. Create a new app with --stack cedar instead.'),
74
+ :body => MultiJson.dump('error' => 'Stack migration to/from Cedar is not available. Create a new app with --stack cedar instead.'),
75
75
  :status => 422
76
76
  }
77
77
  end
@@ -73,7 +73,7 @@ module Heroku
73
73
  def self.get_mock_addon(mock_data, addon)
74
74
  @addons ||= begin
75
75
  data = File.read("#{File.dirname(__FILE__)}/mock/cache/get_addons.json")
76
- Heroku::API::OkJson.decode(data)
76
+ MultiJson.load(data)
77
77
  end
78
78
  @addons.detect {|addon_data| addon_data['name'] == addon}
79
79
  end
@@ -107,7 +107,7 @@ module Heroku
107
107
  def self.get_mock_feature(mock_data, feature)
108
108
  @features ||= begin
109
109
  data = File.read("#{File.dirname(__FILE__)}/mock/cache/get_features.json")
110
- Heroku::API::OkJson.decode(data)
110
+ MultiJson.load(data)
111
111
  end
112
112
  @features.detect {|feature_data| feature_data['name'] == feature}
113
113
  end
@@ -143,7 +143,7 @@ module Heroku
143
143
 
144
144
  parsed = params.dup
145
145
  begin # try to JSON decode
146
- parsed[:body] &&= Heroku::API::OkJson.decode(parsed[:body])
146
+ parsed[:body] &&= MultiJson.load(parsed[:body])
147
147
  rescue # else leave as is
148
148
  end
149
149
  mock_data = @mock_data[api_key]
@@ -78,7 +78,7 @@ module Heroku
78
78
  def put_formation(app, options)
79
79
  options.each { |process, size| options[process] = {'size' => size} }
80
80
  request(
81
- :body => Heroku::API::OkJson.encode(options),
81
+ :body => MultiJson.dump(options),
82
82
  :expects => 200,
83
83
  :method => :put,
84
84
  :path => "/apps/#{app}/formation"
@@ -1,5 +1,5 @@
1
1
  module Heroku
2
2
  class API
3
- VERSION = "0.3.15"
3
+ VERSION = "0.3.16"
4
4
  end
5
5
  end
data/lib/heroku/api.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require "base64"
2
+ require "cgi"
2
3
  require "excon"
4
+ require "multi_json"
3
5
  require "securerandom"
4
6
  require "uri"
5
7
  require "zlib"
@@ -9,8 +11,6 @@ unless $LOAD_PATH.include?(__LIB_DIR__)
9
11
  $LOAD_PATH.unshift(__LIB_DIR__)
10
12
  end
11
13
 
12
- require "heroku/api/vendor/okjson"
13
-
14
14
  require "heroku/api/errors"
15
15
  require "heroku/api/mock"
16
16
  require "heroku/api/version"
@@ -102,7 +102,7 @@ module Heroku
102
102
  if response.body && !response.body.empty?
103
103
  decompress_response!(response)
104
104
  begin
105
- response.body = Heroku::API::OkJson.decode(response.body)
105
+ response.body = MultiJson.load(response.body)
106
106
  rescue
107
107
  # leave non-JSON body as is
108
108
  end
data/test/test_addons.rb CHANGED
@@ -43,7 +43,7 @@ class TestAddons < Minitest::Test
43
43
  data = File.read("#{File.dirname(__FILE__)}/../lib/heroku/api/mock/cache/get_addons.json")
44
44
 
45
45
  assert_equal(200, response.status)
46
- assert_equal(Heroku::API::OkJson.decode(data), response.body)
46
+ assert_equal(MultiJson.load(data), response.body)
47
47
  end
48
48
 
49
49
  def test_get_addons_with_app
@@ -70,4 +70,19 @@ class TestCollaborators < Minitest::Test
70
70
  end
71
71
  end
72
72
 
73
+ def test_delete_collaborator
74
+ with_app do |app_data|
75
+ email_address = 'wesley+test@heroku.com'
76
+ heroku.post_collaborator(app_data['name'], email_address)
77
+
78
+ response = heroku.delete_collaborator(app_data['name'], email_address)
79
+
80
+ assert_equal(200, response.status)
81
+ assert_equal(
82
+ "#{email_address} has been removed as collaborator on #{app_data['name']}",
83
+ response.body
84
+ )
85
+ end
86
+ end
87
+
73
88
  end