lib/power_stencil/project/config.rb in power_stencil-0.3.3 vs lib/power_stencil/project/config.rb in power_stencil-0.3.4
- old
+ new
@@ -3,25 +3,31 @@
module Config
include PowerStencil::Project::Paths
+ PROJECT_CONFIG_PRIORITY = 2000
+ USER_CONFIG_PRIORITY = 2010
+ PLUGIN_CONFIG_PRIORITY_MIN = 1000
+
attr_reader :plugin_priority_count
+
def load_project_specific_config
# Optional config files should have less priority than the command line layer
- add_optional_config_layer project_versioned_config_file, 'versioned project config file', 70
- add_optional_config_layer project_personal_config_file, 'personal project config file', 900
+ add_optional_config_layer project_versioned_config_file, 'versioned project config file', PROJECT_CONFIG_PRIORITY
+ add_optional_config_layer project_personal_config_file, 'personal project config file', USER_CONFIG_PRIORITY
end
+
def add_plugin_config(plugin_name)
yaml_file = plugin_config_specific_file plugin_name
priority = if priority.nil?
- 200
+ PLUGIN_CONFIG_PRIORITY_MIN
else
plugin_priority_count + 1
end
-
+ raise PowerStencil::Error, 'Too many plugins !!' if priority >= PROJECT_CONFIG_PRIORITY
add_optional_config_layer yaml_file, "'#{plugin_name}' plugin specific config", priority
@plugin_priority_count ||= 0
@plugin_priority_count += 1
end