lib/adhearsion/component_manager.rb in adhearsion-1.2.4 vs lib/adhearsion/component_manager.rb in adhearsion-1.2.5
- old
+ new
@@ -70,23 +70,22 @@
#
# @return [Hash] The loaded YAML for the given component name. An empty Hash if no YAML file exists.
#
def configuration_for_component_named(component_name)
# Look for configuration in #{AHN_ROOT}/config/components first
- if File.exists?("#{AHN_ROOT}/config/components/#{component_name}.yml")
- return YAML.load_file "#{AHN_ROOT}/config/components/#{component_name}.yml"
- end
-
+ # Look for configuration in #{AHN_ROOT}/components/#{component_name}/config next
# Next try the local app component directory
- component_dir = File.join(@path_to_container_directory, component_name)
- config_file = File.join component_dir, "#{component_name}.yml"
- if File.exists?(config_file)
- YAML.load_file config_file
- else
- # Nothing found? Return an empty hash
- ahn_log.warn "No configuration found for requested component #{component_name}"
- return {}
+ %W{
+ #{AHN_ROOT}/config/components/#{component_name}.yml
+ #{AHN_ROOT}/components/#{component_name}/config/#{component_name}.yml
+ #{File.join @path_to_container_directory, component_name, "#{component_name}.yml"}
+ }.each do |filename|
+ return YAML.load_file filename if File.exists?(filename)
end
+
+ # Nothing found? Return an empty hash
+ ahn_log.warn "No configuration found for requested component #{component_name}"
+ {}
end
def extend_object_with(object, *scopes)
raise ArgumentError, "Must supply at least one scope!" if scopes.empty?