summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Kantrowitz <noah@coderanger.net>2018-06-23 21:37:23 -0700
committerNoah Kantrowitz <noah@coderanger.net>2018-06-23 21:37:23 -0700
commit36695a792c910feb9d834adb43faea372376cadf (patch)
treeaf44df27f7cdd9aaa39f7cf929abd4226f3d9cd6
parent76835ca40322dadda384694f00a17f73648cbf2f (diff)
downloadchef-36695a792c910feb9d834adb43faea372376cadf.tar.gz
Refactor the dot_d helpers and simplify them a bit.
Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
-rw-r--r--chef-config/lib/chef-config/mixin/dot_d.rb25
1 files changed, 15 insertions, 10 deletions
diff --git a/chef-config/lib/chef-config/mixin/dot_d.rb b/chef-config/lib/chef-config/mixin/dot_d.rb
index 778c25d7f9..4c9c998908 100644
--- a/chef-config/lib/chef-config/mixin/dot_d.rb
+++ b/chef-config/lib/chef-config/mixin/dot_d.rb
@@ -19,17 +19,22 @@ require "chef-config/path_helper"
module ChefConfig
module Mixin
module DotD
+ # Find available configuration files in a `.d/` style include directory.
+ #
+ # @api internal
+ # @param path [String] Base .d/ path to load from.
+ # @return [Array<String>]
+ def find_dot_d(path)
+ Dir["#{PathHelper.escape_glob_dir(path)}/*.rb"].select { |entry| File.file?(entry) }.sort
+ end
+
+ # Load configuration from a `.d/` style include directory.
+ #
+ # @api internal
+ # @param path [String] Base .d/ path to load from.
+ # @return [void]
def load_dot_d(path)
- dot_d_files =
- begin
- entries = Array.new
- entries << Dir.glob(File.join(
- ChefConfig::PathHelper.escape_glob_dir(path), "*.rb"))
- entries.flatten.select do |entry|
- File.file?(entry)
- end
- end
- dot_d_files.sort.map do |conf|
+ find_dot_d(path).each do |conf|
apply_config(IO.read(conf), conf)
end
end