lib/ripe/worker_controller/preparer.rb
##
# Apply the workflow (callback) to each sample, producing a single root
# block per sample.
#
# @param samples [Array<String>] a list of samples
# @param callback [Proc] workflow callback to be applied to each sample
# @param params [Hash] a list of worker-wide parameters
# @return [Hash] a +{sample => block}+ hash
Apply the workflow (callback) to each sample, producing a single root
block per sample.
Apply the workflow ( callback ) to each sample producing a single root block per sample .
def prepare_sample_blocks(samples, callback, params)
        sample_blocks = samples.map do |sample|
          block = callback.call(sample, params)
          if block
            block = block.prune(params[:mode].to_sym == :force,
                              params[:mode].to_sym == :depend)
          end
          if block != nil
            puts "Preparing sample #{sample}"
            {sample => block}
          else
            puts "Nothing to do for sample #{sample}"
            nil
          end
        end
        sample_blocks.compact.inject(&:merge)
      end
def prepare_sample_blocks ( samples , callback , params ) sample_blocks = samples . map do | sample | block = callback . call ( sample , params ) if block block = block . prune ( params [ :mode ] . to_sym == :force , params [ :mode ] . to_sym == :depend ) end if block != nil puts "Preparing sample #{sample}" { sample => block } else puts "Nothing to do for sample #{sample}" nil end end sample_blocks . compact . inject ( & :merge ) end
Apply the workflow (callback) to each sample, producing a single root
block per sample.
Apply the workflow ( callback ) to each sample producing a single root block per sample .
# No need to prune if callback returns nil # Produce a {sample => block} hash
a +{sample => block}+ hash
a + { sample = > block } + hash
Hash
samples
a list of samples
a list of samples
callback
workflow callback to be applied to each sample
workflow callback to be applied to each sample
params
a list of worker-wide parameters
a list of worker - wide parameters