Class: HerokuConfig::Config
- Inherits:
-
Object
- Object
- HerokuConfig::Config
- Defined in:
- lib/heroku_config/config.rb
Instance Method Summary collapse
- #get(name) ⇒ Object
-
#initialize(app) ⇒ Config
constructor
A new instance of Config.
- #set(*params) ⇒ Object
-
#set_many(hash) ⇒ Object
Example:.
- #set_one(name, value) ⇒ Object
Constructor Details
#initialize(app) ⇒ Config
Returns a new instance of Config.
5 6 7 8 |
# File 'lib/heroku_config/config.rb', line 5 def initialize(app) @app = app check_heroku_cli_installed! end |
Instance Method Details
#get(name) ⇒ Object
10 11 12 13 14 |
# File 'lib/heroku_config/config.rb', line 10 def get(name) return "fakevalue" if ENV['HEROKU_CONFIG_TEST'] out = sh "heroku config:get #{name} -a #{@app}" return out if !out&.empty? end |
#set(*params) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/heroku_config/config.rb', line 16 def set(*params) case params.size when 1 # Hash set_many(params.first) when 2 # 2 Strings set_one(name, value) else raise "ERROR: #{params.class} is a class that is not supported" end end |
#set_many(hash) ⇒ Object
Example:
set(a: 1, b: 2)
=>
heroku config:set a=1 b=2 -a APP
37 38 39 40 |
# File 'lib/heroku_config/config.rb', line 37 def set_many(hash) args = hash.map { |k,v| "#{k}=#{v}" }.join(' ') sh "heroku config:set #{args} -a #{@app}", include_stderr: true end |
#set_one(name, value) ⇒ Object
27 28 29 |
# File 'lib/heroku_config/config.rb', line 27 def set_one(name, value) sh "heroku config:set #{name} #{value} -a #{@app}" end |