Class: HerokuConfig
- Inherits:
-
Object
- Object
- HerokuConfig
- Defined in:
- lib/tddium/heroku.rb
Defined Under Namespace
Classes: AppNotFound, HerokuError, HerokuNotFound, InvalidFormat, NotLoggedIn, TddiumNotAdded
Constant Summary collapse
- REQUIRED_KEYS =
%w{TDDIUM_API_KEY TDDIUM_USER_NAME}
Class Method Summary collapse
Class Method Details
.read_config(app = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/tddium/heroku.rb', line 16 def self.read_config(app=nil) config = {} command = "heroku config -s" command += " --app #{app}" if app begin output = `#{command} < /dev/null 2>&1` rescue Errno::ENOENT raise HerokuNotFound end raise HerokuNotFound if output =~ /heroku: not found/ raise AppNotFound if output =~ /App not found/ raise InvalidFormat if output.length == 0 raise NotLoggedIn if output =~ /Heroku credentials/ output.lines.each do |line| line.chomp! k, v = line.split('=') if k =~ /^TDDIUM_/ && v.length > 0 k.sub!("TDDIUM_STAGE", "TDDIUM") config[k] = v end end raise TddiumNotAdded if config.keys.length == 0 raise InvalidFormat if REQUIRED_KEYS.inject(false) {|missing, x| missing || !config[x]} config end |