Skip to content

Instantly share code, notes, and snippets.

@stellimatt
Last active September 26, 2016 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stellimatt/15b6a67fe57d34f4208f28efa2d4a8e1 to your computer and use it in GitHub Desktop.
Save stellimatt/15b6a67fe57d34f4208f28efa2d4a8e1 to your computer and use it in GitHub Desktop.
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