diff options
author | Jon Cowie <jonlives@gmail.com> | 2018-03-12 17:43:39 +0000 |
---|---|---|
committer | Jon Cowie <jonlives@gmail.com> | 2018-03-12 17:43:39 +0000 |
commit | 59e0243609f89827145fc737a4e0eb4a18e87ef0 (patch) | |
tree | bf76d19e37ce920a90cdb796fe3bcaaa00e9ba3b /lib/chef | |
parent | faa20488b77904ba91723754d7604620f3ee02df (diff) | |
download | chef-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.rb | 12 |
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 |