lib/massa/tool.rb in massa-0.1.2 vs lib/massa/tool.rb in massa-0.1.3
- old
+ new
@@ -2,16 +2,28 @@
module Massa
class Tool
class << self
def list
- default_tools = YAML.load_file(config_file_from_gem)
-
- if File.exist?(config_file_from_project)
- default_tools.merge YAML.load_file(config_file_from_project)
- else
- default_tools
+ default_tools.each_with_object({}) do |(tool, options), hash|
+ hash[tool] = options.merge(custom_tools[tool] || {})
+ hash
end
+ end
+
+ private
+
+ def default_tools
+ YAML.load_file(config_file_from_gem)
+ end
+
+ def custom_tools
+ # Returns an empty hash if config file is empty
+ YAML.load_file(config_file_from_project) || {}
+
+ # When there is no config file in the project
+ rescue Errno::ENOENT
+ {}
end
def config_file_from_gem
File.expand_path('../../../config/default_tools.yml', __FILE__)
end