summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorJon Cowie <jonlives@gmail.com>2018-03-12 17:43:39 +0000
committerJon Cowie <jonlives@gmail.com>2018-03-12 17:43:39 +0000
commit59e0243609f89827145fc737a4e0eb4a18e87ef0 (patch)
treebf76d19e37ce920a90cdb796fe3bcaaa00e9ba3b /lib/chef
parentfaa20488b77904ba91723754d7604620f3ee02df (diff)
downloadchef-59e0243609f89827145fc737a4e0eb4a18e87ef0.tar.gz
Make output location handling more idiomaticjcowie/data_collector_json
Signed-off-by: Jon Cowie <jonlives@gmail.com>
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/data_collector.rb12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/chef/data_collector.rb b/lib/chef/data_collector.rb
index 1c2a83337d..6d8b3d6e5f 100644
--- a/lib/chef/data_collector.rb
+++ b/lib/chef/data_collector.rb
@@ -351,18 +351,16 @@ class Chef
def send_to_output_locations(message)
data_collector_output_locations.each do |type, location_list|
- method = if type == :urls
- method(:send_to_http_location)
- elsif type == :files
- method(:send_to_file_location)
- end
-
location_list.each do |l|
- method.call(l, message)
+ handle_output_location(type, l, message)
end
end
end
+ def handle_output_location(type, loc, message)
+ type == :urls ? send_to_http_location(loc, message) : send_to_file_location(loc, message)
+ end
+
def send_to_file_location(file_name, message)
open(file_name, "a") { |f| f.puts message }
end