Sha256: a6f249cf9d80bd68697bae4ce55b56c1d05584a4d0bd0720263fca0eae14888e
Contents?: true
Size: 1002 Bytes
Versions: 1
Compression:
Stored size: 1002 Bytes
Contents
require 'netrc' require 'heroku-api' module HerokuConf ## # App object for parsing Heroku configs class App def initialize(params = {}) @app = params[:app] end def configure!(keys = nil) pairs = config_vars pairs.select! { |k, _| keys.include? k } if keys pairs.each { |k, v| ENV[k] = v } end private def config_vars client.get_config_vars(app).body end def app @app ||= parse_app end def parse_app remotes.first[1].split('/').last.split('.').first end def remotes @remote ||= parse_remotes end def parse_remotes remotes = `git remote -v`.split("\n").map(&:split) remotes.select! { |x| x.first == 'heroku' && x.last == '(push)' } fail('No app found') unless remotes.size == 1 remotes end def client @client ||= Heroku::API.new(api_key: api_key) end def api_key @api_key ||= Netrc.read['api.heroku.com'].password end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
herokuconf-0.0.1 | lib/herokuconf/app.rb |