lib/dake/executor.rb
# command preparation is intentionally deferred to execution phase to
# accelerate the analysis phase of big workflow file
command preparation is intentionally deferred to execution phase to
accelerate the analysis phase of big workflow file
command preparation is intentionally deferred to execution phase to accelerate the analysis phase of big workflow file
def prepare_command(step, context={})
    mixin_method = (step.option_dict['method'] ? step.option_dict['method'] : nil)
    method_mode = (step.option_dict['method_mode'] ? step.option_dict['method_mode'] : 'prepend')
    if mixin_method
      meth = @analyzer.method_dict[mixin_method]
      unless meth
        line, column = @analyzer.option_line_and_column(step.options, 'method')
        raise "Method `#{mixin_method}' used in #{step.src_file} at #{line}:#{column} is not defined."
      end
      @analyzer.analyze_option(meth)
      unless step.option_dict['protocol'] == meth.option_dict['protocol']
        line, column = @analyzer.option_line_and_column(step.options, 'protocol')
        line, column = @analyzer.step_line_and_column(step) unless line
        meth_line, meth_column = meth.name.line_and_column
        raise "Method `#{mixin_method}' defined in #{meth.src_file} at #{meth_line}:#{meth_column} " +
              "uses protocol `#{meth.option_dict['protocol']}', which is incompatible with protocol " +
              "`#{step.option_dict['protocol']}' used in #{step.src_file} at #{line}:#{column}."
      end
      if method_mode == 'replace'
        return prepare_command(meth, step.context)
      else
        method_text = prepare_command(meth, step.context)
      end
    end
    cmd_text = ''
    cmd_text << method_text if mixin_method and method_mode == 'prepend'
    first_indent = step.commands[0].items[0].to_s unless step.commands.empty?
    step.commands.each do |command|
      indent = command.items[0]
      if not indent.to_s.start_with? first_indent
        line, column = indent.line_and_column
        raise "Incompatible indentation in #{step.src_file} at #{line}:#{column}."
      else
        indentation = indent.to_s[first_indent.length..-1]
        cmd_text << indentation + @analyzer.text_eval(command, step.src_file, step.context.merge(context), 1) + "\n"
      end
    end
    cmd_text << method_text if mixin_method and method_mode == 'append'
    if cmd_text == ''
      line, column = @analyzer.step_line_and_column step
      step_meth = step.is_a?(StepMethod) ? 'Method' : 'Step'
      raise "#{step_meth} defined in #{step.src_file} at #{line}:#{column} has no commands."
    end
    cmd_text
  end
def prepare_command ( step , context = { } ) mixin_method = ( step . option_dict [ 'method' ] ? step . option_dict [ 'method' ] : nil ) method_mode = ( step . option_dict [ 'method_mode' ] ? step . option_dict [ 'method_mode' ] : 'prepend' ) if mixin_method meth = @analyzer . method_dict [ mixin_method ] unless meth line , column = @analyzer . option_line_and_column ( step . options , 'method' ) raise "Method `#{mixin_method}' used in #{step.src_file} at #{line}:#{column} is not defined." end @analyzer . analyze_option ( meth ) unless step . option_dict [ 'protocol' ] == meth . option_dict [ 'protocol' ] line , column = @analyzer . option_line_and_column ( step . options , 'protocol' ) line , column = @analyzer . step_line_and_column ( step ) unless line meth_line , meth_column = meth . name . line_and_column raise "Method `#{mixin_method}' defined in #{meth.src_file} at #{meth_line}:#{meth_column} " + "uses protocol `#{meth.option_dict['protocol']}', which is incompatible with protocol " + "`#{step.option_dict['protocol']}' used in #{step.src_file} at #{line}:#{column}." end if method_mode == 'replace' return prepare_command ( meth , step . context ) else method_text = prepare_command ( meth , step . context ) end end cmd_text = '' cmd_text << method_text if mixin_method and method_mode == 'prepend' first_indent = step . commands [ 0 ] . items [ 0 ] . to_s unless step . commands . empty? step . commands . each do | command | indent = command . items [ 0 ] if not indent . to_s . start_with? first_indent line , column = indent . line_and_column raise "Incompatible indentation in #{step.src_file} at #{line}:#{column}." else indentation = indent . to_s [ first_indent . length .. - 1 ] cmd_text << indentation + @analyzer . text_eval ( command , step . src_file , step . context . merge ( context ) , 1 ) + "\n" end end cmd_text << method_text if mixin_method and method_mode == 'append' if cmd_text == '' line , column = @analyzer . step_line_and_column step step_meth = step . is_a? ( StepMethod ) ? 'Method' : 'Step' raise "#{step_meth} defined in #{step.src_file} at #{line}:#{column} has no commands." end cmd_text end
command preparation is intentionally deferred to execution phase to
accelerate the analysis phase of big workflow file
command preparation is intentionally deferred to execution phase to accelerate the analysis phase of big workflow file
step
<not_specific>
context
<not_specific>