Class: Bleib::Configuration
- Inherits:
-
Object
- Object
- Bleib::Configuration
- Defined in:
- lib/bleib/configuration.rb
Defined Under Namespace
Classes: DatabaseYmlNotFoundException, UnsupportedAdapterException
Constant Summary collapse
- DEFAULT_CHECK_DATABASE_INTERVAL =
Seconds
5- DEFAULT_CHECK_MIGRATIONS_INTERVAL =
Seconds
5- DEFAULT_DATABASE_YML_PATH =
'config/database'- SUPPORTED_ADAPTERS =
%w(postgresql postgis mysql2)
Instance Attribute Summary collapse
-
#check_database_interval ⇒ Object
readonly
Returns the value of attribute check_database_interval.
-
#check_migrations_interval ⇒ Object
readonly
Returns the value of attribute check_migrations_interval.
-
#database ⇒ Object
readonly
Returns the value of attribute database.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(database_configuration, check_database_interval: DEFAULT_CHECK_DATABASE_INTERVAL, check_migrations_interval: DEFAULT_CHECK_MIGRATIONS_INTERVAL) ⇒ Configuration
constructor
A new instance of Configuration.
- #logger ⇒ Object
Constructor Details
#initialize(database_configuration, check_database_interval: DEFAULT_CHECK_DATABASE_INTERVAL, check_migrations_interval: DEFAULT_CHECK_MIGRATIONS_INTERVAL) ⇒ Configuration
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/bleib/configuration.rb', line 37 def initialize(database_configuration, check_database_interval: DEFAULT_CHECK_DATABASE_INTERVAL, check_migrations_interval: DEFAULT_CHECK_MIGRATIONS_INTERVAL) # To be 100% sure which connection the # active record pool creates, returns or removes. only_one_connection = { 'pool' => 1 } @database = database_configuration.merge(only_one_connection) @check_database_interval = check_database_interval @check_migrations_interval = check_migrations_interval check! end |
Instance Attribute Details
#check_database_interval ⇒ Object (readonly)
Returns the value of attribute check_database_interval.
6 7 8 |
# File 'lib/bleib/configuration.rb', line 6 def check_database_interval @check_database_interval end |
#check_migrations_interval ⇒ Object (readonly)
Returns the value of attribute check_migrations_interval.
6 7 8 |
# File 'lib/bleib/configuration.rb', line 6 def check_migrations_interval @check_migrations_interval end |
#database ⇒ Object (readonly)
Returns the value of attribute database.
6 7 8 |
# File 'lib/bleib/configuration.rb', line 6 def database @database end |
Class Method Details
.from_environment ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/bleib/configuration.rb', line 14 def self.from_environment check_database_interval = interval_or_default( ENV['BLEIB_CHECK_DATABASE_INTERVAL'], DEFAULT_CHECK_DATABASE_INTERVAL ) check_migrations_interval = interval_or_default( ENV['BLEIB_CHECK_MIGRATIONS_INTERVAL'], DEFAULT_CHECK_MIGRATIONS_INTERVAL ) database_yml_path = ENV['BLEIB_DATABASE_YML_PATH'] database_yml_path ||= File.('config/database.yml') ensure_database_yml!(database_yml_path) rails_env = ENV['RAILS_ENV'] || 'development' new( rails_database(database_yml_path, rails_env), check_database_interval: check_database_interval.to_i, check_migrations_interval: check_migrations_interval.to_i ) end |
Instance Method Details
#logger ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/bleib/configuration.rb', line 52 def logger return @logger unless @logger.nil? @logger = Logger.new(STDOUT) @logger.level = if ENV['BLEIB_LOG_LEVEL'] == 'debug' Logger::DEBUG else Logger::INFO end @logger end |