Class: Utopia::Setup
- Inherits:
-
Object
- Object
- Utopia::Setup
- Defined in:
- lib/utopia/setup.rb
Overview
Used for setting up a Utopia web application, typically via ‘config/environment.rb`
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #apply! ⇒ Object
- #config_root ⇒ Object
- #development? ⇒ Boolean
-
#initialize(root, **options) ⇒ Setup
constructor
A new instance of Setup.
- #production? ⇒ Boolean
- #secret_for(key) ⇒ Object
- #site_root ⇒ Object
- #staging? ⇒ Boolean
- #testing? ⇒ Boolean
Constructor Details
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
20 21 22 |
# File 'lib/utopia/setup.rb', line 20 def root @root end |
Instance Method Details
#apply! ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/utopia/setup.rb', line 60 def apply! add_load_path('lib') apply_environment require_relative '../utopia' end |
#config_root ⇒ Object
22 23 24 |
# File 'lib/utopia/setup.rb', line 22 def config_root File.("config", @root) end |
#development? ⇒ Boolean
38 39 40 |
# File 'lib/utopia/setup.rb', line 38 def development? Variant.for(:utopia) == :development end |
#production? ⇒ Boolean
30 31 32 |
# File 'lib/utopia/setup.rb', line 30 def production? Variant.for(:utopia) == :production end |
#secret_for(key) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/utopia/setup.rb', line 46 def secret_for(key) secret = ENV["UTOPIA_#{key.upcase}_SECRET"] if secret.nil? || secret.empty? secret = SecureRandom.hex(32) Console.warn(self) do "Generating transient #{key} secret: #{secret.inspect}" end end return secret end |
#site_root ⇒ Object
26 27 28 |
# File 'lib/utopia/setup.rb', line 26 def site_root @root end |
#staging? ⇒ Boolean
34 35 36 |
# File 'lib/utopia/setup.rb', line 34 def staging? Variant.for(:utopia) == :staging end |
#testing? ⇒ Boolean
42 43 44 |
# File 'lib/utopia/setup.rb', line 42 def testing? Variant.for(:utopia) == :testing end |