Skip to content

Commit

Permalink
DRY up tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
bfcoder committed Dec 12, 2016
1 parent 805b414 commit 5e7b6b2
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/blacklight/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ def source_for_upload_log(upload_log)
end
end

def make_directories(name, upload_dir)
mkdir_p name.pathmap("%d")
mkdir_p upload_dir
end

def log_file(name)
sh "touch #{name}"
sh "date >> #{name}"
end

module Blacklight
class Tasks
extend Rake::DSL if defined? Rake::DSL
Expand All @@ -53,8 +63,7 @@ def self.install_tasks
directory OUTPUT_NAME

rule ".imscc" => [->(f) { source_for_imscc(f) }, OUTPUT_NAME] do |t|
mkdir_p t.name.pathmap("%d")
mkdir_p OUTPUT_DIR
make_directories(t.name, OUTPUT_DIR)
Blacklight.parse(SOURCE_DIR, OUTPUT_DIR)
end

Expand All @@ -66,11 +75,9 @@ def self.install_tasks
directory UPLOAD_NAME

rule ".txt" => [->(f) { source_for_upload_log(f) }, UPLOAD_NAME] do |t|
mkdir_p t.name.pathmap("%d")
mkdir_p UPLOAD_DIR
make_directories(t.name, UPLOAD_DIR)
Blacklight.initialize_course(t.source)
sh "touch #{t.name}"
sh "date >> #{t.name}"
log_file(t.name)
end

desc "Completely delete all converted files"
Expand Down

0 comments on commit 5e7b6b2

Please sign in to comment.