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.
37 38 39 |
# File 'lib/utopia/setup.rb', line 37 def root @root end |
Instance Method Details
#apply! ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/utopia/setup.rb', line 77 def apply! add_load_path('lib') apply_environment require_relative '../utopia' end |
#config_root ⇒ Object
39 40 41 |
# File 'lib/utopia/setup.rb', line 39 def config_root File.("config", @root) end |
#development? ⇒ Boolean
55 56 57 |
# File 'lib/utopia/setup.rb', line 55 def development? Variant.for(:utopia) == :development end |
#production? ⇒ Boolean
47 48 49 |
# File 'lib/utopia/setup.rb', line 47 def production? Variant.for(:utopia) == :production end |
#secret_for(key) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/utopia/setup.rb', line 63 def secret_for(key) secret = ENV["UTOPIA_#{key.upcase}_SECRET"] if secret.nil? || secret.empty? secret = SecureRandom.hex(32) Utopia.logger.warn(self) do "Generating transient #{key} secret: #{secret.inspect}" end end return secret end |
#site_root ⇒ Object
43 44 45 |
# File 'lib/utopia/setup.rb', line 43 def site_root @root end |
#staging? ⇒ Boolean
51 52 53 |
# File 'lib/utopia/setup.rb', line 51 def staging? Variant.for(:utopia) == :staging end |
#testing? ⇒ Boolean
59 60 61 |
# File 'lib/utopia/setup.rb', line 59 def testing? Variant.for(:utopia) == :testing end |