Browse Source

Consolidate create_path code

main
Adrian Short 5 years ago
parent
commit
f2f6d00b64
1 changed files with 9 additions and 6 deletions
  1. +9
    -6
      bin/build

+ 9
- 6
bin/build View File

@@ -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)


Loading…
Cancel
Save