Class: Confset::Integrations::Heroku
- Inherits:
-
Struct
- Object
- Struct
- Confset::Integrations::Heroku
- Defined in:
- lib/confset/integrations/heroku.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
Instance Method Summary collapse
- #`(command) ⇒ Object
- #environment ⇒ Object
- #heroku(command) ⇒ Object
- #invoke ⇒ Object
- #to_dotted_hash(source, target = {}, namespace = nil) ⇒ Object
- #vars ⇒ Object
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app
7 8 9 |
# File 'lib/confset/integrations/heroku.rb', line 7 def app @app end |
Instance Method Details
#`(command) ⇒ Object
39 40 41 |
# File 'lib/confset/integrations/heroku.rb', line 39 def `(command) Bundler.with_clean_env { super } end |
#environment ⇒ Object
30 31 32 |
# File 'lib/confset/integrations/heroku.rb', line 30 def environment heroku("run 'echo $RAILS_ENV'").chomp[/(\w+)\z/] end |
#heroku(command) ⇒ Object
34 35 36 37 |
# File 'lib/confset/integrations/heroku.rb', line 34 def heroku(command) with_app = app ? " --app #{app}" : "" `heroku #{command}#{with_app}` end |
#invoke ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/confset/integrations/heroku.rb', line 8 def invoke puts "Setting vars..." heroku_command = "config:set #{vars}" heroku(heroku_command) puts "Vars set:" puts heroku_command end |
#to_dotted_hash(source, target = {}, namespace = nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/confset/integrations/heroku.rb', line 43 def to_dotted_hash(source, target = {}, namespace = nil) prefix = "#{namespace}." if namespace case source when Hash source.each do |key, value| to_dotted_hash(value, target, "#{prefix}#{key}") end when Array source.each_with_index do |value, index| to_dotted_hash(value, target, "#{prefix}#{index}") end else target[namespace] = source end target end |
#vars ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/confset/integrations/heroku.rb', line 16 def vars # Load only local options to Heroku Confset.load_and_set_settings( Rails.root.join("config", "settings.local.yml").to_s, Rails.root.join("config", "settings", "#{environment}.local.yml").to_s, Rails.root.join("config", "environments", "#{environment}.local.yml").to_s ) out = "" dotted_hash = to_dotted_hash Kernel.const_get(Confset.const_name).to_hash, {}, Confset.const_name dotted_hash.each { |key, value| out += " #{key}=#{value} " } out end |