Module: LatoCore::Interface::Modules
- Included in:
- LatoCore::Interface
- Defined in:
- lib/lato_core/interfaces/modules.rb
Overview
This module contains a list of functions used to work and manage other lato modules.
Instance Method Summary collapse
-
#core__get_module_application_configs(module_name) ⇒ Object
This function load application configs for a specific module.
-
#core__get_module_application_languages(module_name) ⇒ Object
This function load application languages for a specific module.
-
#core__get_module_configs(module_name) ⇒ Object
This function load configs for a specific module.
-
#core__get_module_default_configs(module_name) ⇒ Object
This function load default configs for a specific module.
-
#core__get_module_default_languages(module_name) ⇒ Object
This function load default languages for a specific module.
-
#core__get_module_languages(module_name) ⇒ Object
This function load languages for a specific module.
-
#core__get_module_root_path(module_name) ⇒ Object
This function return the root path of a specific module.
-
#core__get_modules_configs ⇒ Object
This function returns an object with configs for every module.
-
#core__get_modules_languages ⇒ Object
This function returns an object with languages for every module.
-
#core__get_modules_list ⇒ Object
This function returns the list of lato modules installed on main application.
Instance Method Details
#core__get_module_application_configs(module_name) ⇒ Object
This function load application configs for a specific module.
96 97 98 99 100 |
# File 'lib/lato_core/interfaces/modules.rb', line 96 def core__get_module_application_configs module_name application_config_path = core__get_application_lato_configs_path absolute_path = "#{application_config_path}/#{module_name}.yml" return core__read_yaml(absolute_path) end |
#core__get_module_application_languages(module_name) ⇒ Object
This function load application languages for a specific module.
61 62 63 64 65 |
# File 'lib/lato_core/interfaces/modules.rb', line 61 def core__get_module_application_languages(module_name) application_config_path = core__get_application_lato_configs_path absolute_path = "#{application_config_path}/#{module_name}_locale.yml" core__read_yaml(absolute_path) end |
#core__get_module_configs(module_name) ⇒ Object
This function load configs for a specific module. This configs are generated from the merge of application configs for the module and default configs of the module.
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/lato_core/interfaces/modules.rb', line 83 def core__get_module_configs module_name default_config = core__get_module_default_configs(module_name) application_config = core__get_module_application_configs(module_name) return default_config unless application_config default_config.each do |key, value| application_config[key] = value unless application_config[key] end return application_config end |
#core__get_module_default_configs(module_name) ⇒ Object
This function load default configs for a specific module.
103 104 105 106 107 |
# File 'lib/lato_core/interfaces/modules.rb', line 103 def core__get_module_default_configs module_name module_root_path = core__get_module_root_path(module_name) absolute_path = "#{module_root_path}/config/configs.yml" return core__read_yaml(absolute_path) end |
#core__get_module_default_languages(module_name) ⇒ Object
This function load default languages for a specific module.
55 56 57 58 |
# File 'lib/lato_core/interfaces/modules.rb', line 55 def core__get_module_default_languages(module_name) module_root_path = core__get_module_root_path(module_name) core__read_yaml("#{module_root_path}/config/languages/default.yml") end |
#core__get_module_languages(module_name) ⇒ Object
This function load languages for a specific module. This config are generated from the merge of application languages for the module and default languages of the module.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/lato_core/interfaces/modules.rb', line 42 def core__get_module_languages(module_name) default_languages = core__get_module_default_languages(module_name) application_languages = core__get_module_application_languages(module_name) return default_languages unless application_languages default_languages.each do |key, value| application_languages[key] = value unless application_languages[key] end application_languages end |
#core__get_module_root_path(module_name) ⇒ Object
This function return the root path of a specific module.
10 11 12 |
# File 'lib/lato_core/interfaces/modules.rb', line 10 def core__get_module_root_path(module_name) Gem.loaded_specs[module_name].full_gem_path end |
#core__get_modules_configs ⇒ Object
This function returns an object with configs for every module.
71 72 73 74 75 76 77 78 |
# File 'lib/lato_core/interfaces/modules.rb', line 71 def core__get_modules_configs lato_modules = core__get_modules_list configs = {} lato_modules.each do |lato_module_name| configs[lato_module_name.to_sym] = core__get_module_configs(lato_module_name) end configs end |
#core__get_modules_languages ⇒ Object
This function returns an object with languages for every module.
30 31 32 33 34 35 36 37 |
# File 'lib/lato_core/interfaces/modules.rb', line 30 def core__get_modules_languages lato_modules = core__get_modules_list languages = {} lato_modules.each do |lato_module_name| languages[lato_module_name.to_sym] = core__get_module_languages(lato_module_name) end languages end |
#core__get_modules_list ⇒ Object
This function returns the list of lato modules installed on main application.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/lato_core/interfaces/modules.rb', line 15 def core__get_modules_list all_gems = core__get_application_gems.keys lato_gems = [] # check every gem all_gems.each do |name| lato_gems.push(name) if name.start_with? 'lato' end # return result lato_gems end |