Module: Vault::App
- Defined in:
- lib/vault-tools/app.rb
Constant Summary collapse
- ID_CAPTURE =
/\Aapp(\d+)\@[\w\.]+com\z/
Class Method Summary collapse
-
.hid_to_id(heroku_id) ⇒ Integer
Convert a Heroku app ID into a core app ID.
-
.hid_to_uuid(heroku_id) ⇒ String
Convert a Heroku app ID into a v5 UUID.
-
.id_to_hid(app_id) ⇒ String
Convert a core app ID into a Heroku app ID.
-
.id_to_uuid(app_id) ⇒ String
Convert a core app ID into a v5 UUID.
Class Method Details
.hid_to_id(heroku_id) ⇒ Integer
Convert a Heroku app ID into a core app ID.
28 29 30 31 32 33 34 |
# File 'lib/vault-tools/app.rb', line 28 def self.hid_to_id(heroku_id) if app_id = heroku_id.slice(ID_CAPTURE, 1) app_id.to_i else raise ArgumentError,"#{heroku_id} is not a valid Heroku app ID." end end |
.hid_to_uuid(heroku_id) ⇒ String
Convert a Heroku app ID into a v5 UUID.
41 42 43 44 45 46 47 |
# File 'lib/vault-tools/app.rb', line 41 def self.hid_to_uuid(heroku_id) if app_id = heroku_id.slice(ID_CAPTURE, 1) id_to_uuid(app_id) else raise ArgumentError, "#{heroku_id} is not a valid Heroku app ID." end end |
.id_to_hid(app_id) ⇒ String
Convert a core app ID into a Heroku app ID.
10 11 12 |
# File 'lib/vault-tools/app.rb', line 10 def self.id_to_hid(app_id) "app#{app_id}@heroku.com" end |
.id_to_uuid(app_id) ⇒ String
Convert a core app ID into a v5 UUID.
18 19 20 21 |
# File 'lib/vault-tools/app.rb', line 18 def self.id_to_uuid(app_id) url = "https://vault.heroku.com/apps/#{app_id}" UUIDTools::UUID.sha1_create(UUIDTools::UUID_URL_NAMESPACE, url).to_s end |