Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
heroku pg creds
class CredFinder
attr_accessor :cred_hsh
def initialize(urn)
puts "***** \nSapSucking Creds For -- \n#{urn} \n*****"
@cms_urn = urn
@cred_hsh = {'dbname'=>'','host'=>'','port'=>'','user'=>'', 'password'=>''}
def build_creds
# get credentials string from heroku
str = `heroku pg:credentials -a "#{@cms_urn}"`
# split string by spaces
str = str.split(' ')
# select only values that contain an equals symbol
creds = {|substr| substr.include?('=')}
# for each key in the credentials hash, return the value from the creds array
@cred_hsh.keys.each do |key|
item_array = { |val| val.include?(key) }
item = item_array[0].split('=')
value = item.last
@cred_hsh[key] = value
return @cred_hsh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.