Class: Utopia::Bootstrap
- Inherits:
-
Object
- Object
- Utopia::Bootstrap
- Defined in:
- lib/utopia/setup.rb
Instance Method Summary collapse
- #environment_path ⇒ Object
-
#initialize(config_root) ⇒ Bootstrap
constructor
A new instance of Bootstrap.
- #setup ⇒ Object
- #setup_encoding ⇒ Object
- #setup_environment ⇒ Object
- #setup_load_path ⇒ Object
Constructor Details
#initialize(config_root) ⇒ Bootstrap
Returns a new instance of Bootstrap.
23 24 25 |
# File 'lib/utopia/setup.rb', line 23 def initialize(config_root) @config_root = config_root end |
Instance Method Details
#environment_path ⇒ Object
37 38 39 |
# File 'lib/utopia/setup.rb', line 37 def environment_path File.('environment.yaml', @config_root) end |
#setup ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/utopia/setup.rb', line 27 def setup setup_encoding setup_environment setup_load_path require_relative '../utopia' end |
#setup_encoding ⇒ Object
41 42 43 44 45 |
# File 'lib/utopia/setup.rb', line 41 def setup_encoding # If you don't specify these, it's possible to have issues when encodings mismatch on the server. Encoding.default_external = Encoding::UTF_8 Encoding.default_internal = Encoding::UTF_8 end |
#setup_environment ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/utopia/setup.rb', line 47 def setup_environment if File.exist? environment_path require 'yaml' # Load the YAML environment file: environment = YAML.load_file(environment_path) # Update the process environment: ENV.update(environment) end end |
#setup_load_path ⇒ Object
59 60 61 62 |
# File 'lib/utopia/setup.rb', line 59 def setup_load_path # Allow loading library code from lib directory: $LOAD_PATH << File.('../lib', @config_root) end |