Permalink
Browse files

Factor out buildpack_url_for method.

  • Loading branch information...
1 parent e9b7d6b commit 0f604de00db1fb3a3f11389891d83efe2de7d97b @technomancy technomancy committed Aug 30, 2012
Showing with 17 additions and 13 deletions.
  1. +17 −13 lib/packaging/heroku/command/buildpacks.rb
@@ -192,19 +192,8 @@ def unshare
#
def set
action "Modifying BUILDPACK_URL for #{app}" do
- buildpack = shift_argument || error("Must specify a buildpack name")
- buildpack_url = if buildpack =~ /:\/\//
- buildpack
- else
- begin
- response = server["/buildpacks/#{buildpack}"].get
- json_decode(response)["tar_link"]
- rescue RestClient::Exception => e
- body = json_decode(e.http_body) || {"message" => "failed"}
- error body["message"]
- end
- end
- api.put_config_vars app, "BUILDPACK_URL" => buildpack_url
+ buildpack_url = buildpack_url_for(shift_argument)
+ api.put_config_vars(app, "BUILDPACK_URL" => buildpack_url)
end
end
@@ -223,6 +212,21 @@ def server
:password => auth.password)
end
+ def buildpack_url_for(name)
+ error("Must specify a buildpack") if name.nil?
+ if name =~ /:\/\//
+ name # is a URL
+ else
+ begin
+ response = server["/buildpacks/#{name}"].get
+ json_decode(response)["tar_link"]
+ rescue RestClient::Exception => e
+ body = json_decode(e.http_body) || {"message" => "failed"}
+ error body["message"]
+ end
+ end
+ end
+
def check_name(name)
if name.nil?
error("Must specify a buildpack name")

0 comments on commit 0f604de

Please sign in to comment.