Class: Shred::Commands::Dotenv
- Defined in:
- lib/shred/commands/dotenv.rb
Instance Attribute Summary
Attributes inherited from Base
#command_config, #command_name, #console
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Shred::Commands::Base
Instance Method Details
#custom ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/shred/commands/dotenv.rb', line 49 def custom custom = cfg('custom.vars') mode = cfg('custom.mode') == 'a' ? 'a' : 'w' File.open('.env', mode) do |output| custom.each do |key, value| output.write("#{key}=#{value}\n") end end console.say_ok("Custom config written to environment config file") end |
#heroku ⇒ 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 |
# File 'lib/shred/commands/dotenv.rb', line 16 def heroku app_name = cfg('heroku.app_name') vars = cfg('heroku.vars') mode = cfg('heroku.mode') == 'a' ? 'a' : 'w' authenticate_to_heroku run_shell_command(ShellCommand.new( command_lines: "heroku config --app #{app_name} --shell", output: '.heroku.env' )) File.open('.heroku.env') do |input| File.open('.env', mode) do |output| input.readlines.each do |line| line.chomp! if line =~ /^([^=]+)=/ && vars.include?($1) output.write("#{line}\n") end end end end File.unlink('.heroku.env') console.say_ok("Heroku config written to environment config file") end |