Module: Exekutor::Internal::CLI::ApplicationLoader

Included in:
Cleanup, Info, Manager
Defined in:
lib/exekutor/internal/cli/application_loader.rb

Overview

Helper methods to load the Rails application

Constant Summary collapse

LOADING_MESSAGE =

The message to print when loading the Rails application

"Loading Rails environment…"

Instance Method Summary collapse

Instance Method Details

#clear_application_loading_messageObject

Clears the loading message if it was printed



28
29
30
31
32
33
# File 'lib/exekutor/internal/cli/application_loader.rb', line 28

def clear_application_loading_message
  return unless @loading_message_printed

  printf "\r#{" " * LOADING_MESSAGE.length}\r"
  @loading_message_printed = false
end

#different_time_zone?Boolean

Returns Whether the system time zone differs from the app time zone.

Returns:

  • (Boolean)

    Whether the system time zone differs from the app time zone



36
37
38
# File 'lib/exekutor/internal/cli/application_loader.rb', line 36

def different_time_zone?
  Time.zone.name != Time.new.zone
end

#load_application(environment, path = "config/environment.rb", print_message: false) ⇒ Object

Loads the Rails application

Parameters:

  • environment (String)

    the environment to load (eg. development, production)

  • path (String) (defaults to: "config/environment.rb")

    the path to the environment file

  • print_message (Boolean) (defaults to: false)

    whether to print a loading message to STDOUT



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/exekutor/internal/cli/application_loader.rb', line 15

def load_application(environment, path = "config/environment.rb", print_message: false)
  return if @application_loaded

  if print_message
    printf LOADING_MESSAGE
    @loading_message_printed = true
  end
  ENV["RAILS_ENV"] = environment unless environment.nil?
  require File.expand_path(path)
  @application_loaded = true
end

Prints a message to STDOUT indicating in which time zone times are printed



41
42
43
# File 'lib/exekutor/internal/cli/application_loader.rb', line 41

def print_time_zone_warning
  puts "(times are printed in the #{Time.zone.name} time zone)\n\n"
end