Class: Heroku::Command::Ssl

Inherits:
BaseWithApp show all
Defined in:
lib/heroku/commands/ssl.rb

Instance Attribute Summary

Attributes inherited from BaseWithApp

#app

Attributes inherited from Base

#args, #autodetected_app

Instance Method Summary collapse

Methods inherited from BaseWithApp

#initialize

Methods inherited from Base

#app_urls, #ask, #display, #error, #escape, #extract_app, #extract_app_in_dir, #extract_option, #format_date, #git_remotes, #git_url, #heroku, #initialize, #shell, #web_url

Methods included from Helpers

#home_directory, #running_on_a_mac?, #running_on_windows?

Constructor Details

This class inherits a constructor from Heroku::Command::BaseWithApp

Instance Method Details

#addObject

Raises:



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/heroku/commands/ssl.rb', line 14

def add
	usage  = 'heroku ssl:add <pem> <key>'
	raise CommandFailed, "Missing pem file. Usage:\n#{usage}" unless pem_file = args.shift
	raise CommandFailed, "Missing key file. Usage:\n#{usage}" unless key_file = args.shift
	raise CommandFailed, "Could not find pem in #{pem_file}"  unless File.exists?(pem_file)
	raise CommandFailed, "Could not find key in #{key_file}"  unless File.exists?(key_file)

	pem  = File.read(pem_file)
	key  = File.read(key_file)
	info = heroku.add_ssl(app, pem, key)
	display "Added certificate to #{info['domain']}, expiring in #{info['expires_at']}"
end

#listObject Also known as: index



3
4
5
6
7
8
9
10
11
# File 'lib/heroku/commands/ssl.rb', line 3

def list
	heroku.list_domains(app).each do |d|
		if cert = d[:cert]
			display "#{d[:domain]} has a SSL certificate registered to #{cert[:subject]} which expires on #{cert[:expires_at].strftime("%b %d, %Y")}"
		else
			display "#{d[:domain]} has no certificate"
		end
	end
end

#removeObject

Raises:



27
28
29
30
31
# File 'lib/heroku/commands/ssl.rb', line 27

def remove
	raise CommandFailed, "Missing domain. Usage:\nheroku ssl:remove <domain>" unless domain = args.shift
	heroku.remove_ssl(app, domain)
	display "Removed certificate from #{domain}"
end