Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
gems rakefile
@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
You can’t perform that action at this time.