Class: Utopia::Command::Server::Environment

Inherits:
Samovar::Command
  • Object
show all
Defined in:
lib/utopia/command/server.rb

Overview

Set environment variables within the server deployment.

Instance Method Summary collapse

Instance Method Details

#invoke(parent) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/utopia/command/server.rb', line 83

def invoke(parent)
  return if variables.empty?
  
  destination_root = parent.root
  
  Setup::Server.environment(destination_root) do |store|
    variables.each do |variable|
      key, value = variable.split('=', 2)
      
      if value
        puts "ENV[#{key.inspect}] will default to #{value.inspect} unless otherwise specified."
        store[key] = value
      else
        puts "ENV[#{key.inspect}] will be unset unless otherwise specified."
        store.delete(key)
      end
    end
  end
end