Class: RubyPitaya::Setup
- Inherits:
-
Object
- Object
- RubyPitaya::Setup
- Defined in:
- lib/rubypitaya/core/setup.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #auto_reload ⇒ Object
-
#initialize ⇒ Setup
constructor
A new instance of Setup.
Constructor Details
#initialize ⇒ Setup
Returns a new instance of Setup.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rubypitaya/core/setup.rb', line 5 def initialize() @config = {} configs_folder_paths = Path::Plugins::APP_SETUP_FOLDER_PATHS + [Path::APP_SETUP_FOLDER_PATH] configs_folder_paths.each do |configs_folder_path| path_to_all_files = File.join(configs_folder_path, '**/*.yml') config_files = Dir.glob(path_to_all_files) config_files.each do |config_file| load_config_file(configs_folder_path, config_file) end end end |
Instance Method Details
#[](key) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/rubypitaya/core/setup.rb', line 19 def [](key) result = get_config_from_env_var(key) return result unless result.nil? split_key = key.split('.') @config.dig(*split_key) end |
#auto_reload ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rubypitaya/core/setup.rb', line 27 def auto_reload require 'listen' configs_folder_path = Path::APP_CONFIG_FOLDER_PATH config_files_listener = Listen.to(configs_folder_path, only: /\.yml$/, force_polling: true, latency: 0.25, wait_for_delay: 0.1) do |modified, added, removed| import_added_files(configs_folder_path, added) reload_modified_files(configs_folder_path, modified) end config_files_listener.start end |