Last active
September 26, 2016 22:26
-
-
Save stellimatt/15b6a67fe57d34f4208f28efa2d4a8e1 to your computer and use it in GitHub Desktop.
gems rakefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@meta[:steps].each do |step| | |
task_sym = "#{@meta[:pipeline]}:#{step[:phase]}:#{step[:name]}".to_sym | |
define_task(step[:description], task_sym) do |t, args| | |
# derive worker class namespace::name | |
pipeline = @meta[:pipeline].capitalize | |
phase = step[:phase].capitalize | |
job = step[:name].split('_').collect(&:capitalize).join | |
class_ref = "#{pipeline}::#{phase}::#{job}" | |
# instantiate worker (with store instance) | |
Object::const_get(class_ref).new(store: @store) | |
# tasks write log messages to the store, which is hooked up via 'enhance' | |
Rake::Task[task_sym.to_s].enhance do |e| | |
tasks = @store.get(attrib_name: 'tasks_executed') | |
@store.put(attrib_name: 'tasks_executed', value: (tasks.nil? ? [] : tasks) << { name: e.name, time: Time.now.strftime('%c') }) | |
@store.save | |
end | |
@store.save | |
end | |
# apply a built-in dependency to lazily-instantiate the store | |
task task_sym => [ :setup_store ] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment