summaryrefslogtreecommitdiff
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
parentfaa20488b77904ba91723754d7604620f3ee02df (diff)
downloadchef-jcowie/data_collector_json.tar.gz
Make output location handling more idiomaticjcowie/data_collector_json
Signed-off-by: Jon Cowie <jonlives@gmail.com>
-rw-r--r--data_collection.json2
-rw-r--r--lib/chef/data_collector.rb12
2 files changed, 7 insertions, 7 deletions
diff --git a/data_collection.json b/data_collection.json
new file mode 100644
index 0000000000..139597f9cb
--- /dev/null
+++ b/data_collection.json
@@ -0,0 +1,2 @@
+
+
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