From f2f6d00b64ffdf50bba4d400a8f48c23e33a892c Mon Sep 17 00:00:00 2001 From: Adrian Short Date: Sat, 22 Sep 2018 22:01:16 +0100 Subject: [PATCH] Consolidate create_path code --- bin/build | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bin/build b/bin/build index 7a58554..6986a4d 100755 --- a/bin/build +++ b/bin/build @@ -12,9 +12,7 @@ VIEWS_DIR = File.join('views') LAYOUT_FN = File.join(VIEWS_DIR, 'layout.haml') def write_page(path_items, template, locals = {}) - dir = File.join(OUTPUT_DIR, path_items) - FileUtils.mkdir_p(dir) - @log.debug dir + dir = create_path(path_items) fn = File.join(dir, 'index.html') # https://stackoverflow.com/questions/6125265/using-layouts-in-haml-files-independently-of-rails @@ -30,9 +28,7 @@ def write_page(path_items, template, locals = {}) end def write_csv(path_items, filename, data) - dir = File.join(OUTPUT_DIR, path_items) - FileUtils.mkdir_p(dir) - @log.debug dir + dir = create_path(path_items) fn = File.join(dir, filename + '.csv') csv_string = CSV.generate do |csv| @@ -44,6 +40,13 @@ def write_csv(path_items, filename, data) @log.info fn end +def create_path(path_items) + dir = File.join(OUTPUT_DIR, path_items) + FileUtils.mkdir_p(dir) + @log.debug dir + dir +end + def create_output_dir # Recursively delete working directory to ensure no redundant files are left behind from previous builds. # FileUtils.rm_rf(@working_dir)