derickbailey/Albacore — Issue #176: Auto loading of YML config for tasks with dependencies
Author: nithinphilips
Created: 2011-10-28 21:28:23+00:00
State: open

I ran into an issue with auto loading of YML config files. Here's a patch that fixes the problem.

**Background:**

My Rakefile had a task definition like this:

rapc :supertask => [:subtask1, :subtask2] do |r|
...
end

`rapc` is a custom task.

When I tried to put settings in the yml file, I noticed that they were never loaded. While investigating the problem I realized that the `task_name` parameter passed into the `load_config_by_task_name` method is, in case of a task definition like the one above, a `Hash`, rather than a `Symbol`. The following patch ensures that the correct yml config file will be loaded in this case.

--- yamlconfig.old.rb 2011-10-28 17:09:52.887308600 -0400
+++ yamlconfig.rb 2011-10-28 17:08:55.682036600 -0400
@@ -7,6 +7,13 @@

def load_config_by_task_name(task_name)
task_config = "#{task_name}.yml"
+
+ if task_name.is_a? Hash
+ task_name.each_key {|key|
+ task_config = "#{key}.yml"
+ }
+ end
+
task_config = File.join(Albacore.configure.yaml_config_folder, task_config) unless Albacore.configure.yaml_config_folder.nil?
configure(task_config) if File.exists?(task_config)
end