Utopia SourceUtopiaSetup

class Setup

Used for setting up a Utopia web application, typically via config/environment.rb

Definitions

def add_load_path(path)

Add the given path to $LOAD_PATH. If it's relative, make it absolute relative to site_path.

Implementation

def add_load_path(path)
	# Allow loading library code from lib directory:
	$LOAD_PATH << File.expand_path(path, site_root)
end

def load_environment(variant)

Load the named configuration file from the config_root directory.

Implementation

def load_environment(variant)
	path = environment_path(variant)
	
	if File.exist?(path)
		Utopia.logger.debug(self) {"Loading environment at path: #{path.inspect}"}
		
		# Load the YAML environment file:
		if environment = YAML.load_file(path)
			# We update ENV but only when it's not already set to something:
			ENV.update(environment) do |name, old_value, new_value|
				old_value || new_value
			end
		end
		
		return true
	else
		Utopia.logger.debug(self) {"Ignoring environment at path: #{path.inspect} (file not found)"}
		
		return false
	end
end