Class: Devup::Application
- Inherits:
-
Object
- Object
- Devup::Application
- Defined in:
- lib/devup/application.rb
Instance Method Summary collapse
- #app_env ⇒ Object
- #boot ⇒ Object
- #devup ⇒ Object
- #devup_disabled? ⇒ Boolean
- #dotenv_list ⇒ Object
- #dotenv_vars ⇒ Object
- #load_env ⇒ Object
- #log_level ⇒ Object
- #run ⇒ Object
Instance Method Details
#app_env ⇒ Object
44 45 46 |
# File 'lib/devup/application.rb', line 44 def app_env (ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development").to_sym end |
#boot ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/devup/application.rb', line 13 def boot devup.up begin require "spring/commands" Spring.watch devup.root.join("docker-compose.yml") rescue LoadError, ArgumentError, NameError # Spring is not available end end |
#devup ⇒ Object
25 26 27 28 29 30 |
# File 'lib/devup/application.rb', line 25 def devup @devup ||= Devup::Environment.new( pwd: `pwd`, logger: Devup::Logger.new(level: log_level) ) end |
#devup_disabled? ⇒ Boolean
60 61 62 |
# File 'lib/devup/application.rb', line 60 def devup_disabled? ENV.fetch("DEVUP_ENABLED", dotenv_vars["DEVUP_ENABLED"] || "true") != "true" end |
#dotenv_list ⇒ Object
48 49 50 |
# File 'lib/devup/application.rb', line 48 def dotenv_list Devup::DotenvLoadList.new(env: app_env) end |
#dotenv_vars ⇒ Object
52 53 54 |
# File 'lib/devup/application.rb', line 52 def dotenv_vars Dotenv.parse(*dotenv_list.to_a) end |
#load_env ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/devup/application.rb', line 32 def load_env if defined? ActiveSupport::Notifications Dotenv.instrumenter = ActiveSupport::Notifications ActiveSupport::Notifications.subscribe(/^dotenv/) do |*args| event = ActiveSupport::Notifications::Event.new(*args) Spring.watch event.payload[:env].filename if defined? Spring end end Dotenv.load(*dotenv_list.to_a) end |
#log_level ⇒ Object
56 57 58 |
# File 'lib/devup/application.rb', line 56 def log_level ENV.fetch("DEVUP_LOG_LEVEL", dotenv_vars["DEVUP_LOG_LEVEL"] || "info") end |
#run ⇒ Object
8 9 10 11 |
# File 'lib/devup/application.rb', line 8 def run boot unless devup_disabled? load_env end |