lib/dake/analyzer.rb
# src_file is needed by prepare_command in execution phase
# because @inclusion_stack will have only root workflow by then
src_file is needed by prepare_command in execution phase
because @inclusion_stack will have only root workflow by then
src_file is needed by prepare_command in execution phase because @inclusion_stack will have only root workflow by then
def text_eval(text, src_file=@inclusion_stack[-1], context=@variable_dict, skip=0)
    text.items[skip..-1].reduce('') do |string, item|
      case item
      when Chars
        string.concat item.string.to_s
      when VariableSub
        var_name = item.var_name.to_s
        var_value = context[var_name]
        if var_value
          string.concat var_value
        else
          line, column = item.var_name.line_and_column
          raise "Variable `#{var_name}' in #{src_file} at #{line}:#{column} is not defined."
        end
      when CommandSub
        command = text_eval(item.cmd_text, src_file, context)
        stdout, stderr, status = Open3.capture3(command, :chdir=>@variable_dict['BASE'])
        if status.success?
          string.concat stdout.chomp
        else
          line, column = text_line_and_column item.cmd_text
          raise "Command `#{command}' in #{src_file} at #{line}:#{column} failed " +
                 "with EXIT_STATUS:#{status.exitstatus} and STDERR:\n#{stderr}"
        end
      else 
        string.concat item.to_s
      end
      string
    end
  end
def text_eval ( text , src_file = @inclusion_stack [ - 1 ] , context = @variable_dict , skip = 0 ) text . items [ skip .. - 1 ] . reduce ( '' ) do | string , item | case item when Chars string . concat item . string . to_s when VariableSub var_name = item . var_name . to_s var_value = context [ var_name ] if var_value string . concat var_value else line , column = item . var_name . line_and_column raise "Variable `#{var_name}' in #{src_file} at #{line}:#{column} is not defined." end when CommandSub command = text_eval ( item . cmd_text , src_file , context ) stdout , stderr , status = Open3 . capture3 ( command , :chdir => @variable_dict [ 'BASE' ] ) if status . success? string . concat stdout . chomp else line , column = text_line_and_column item . cmd_text raise "Command `#{command}' in #{src_file} at #{line}:#{column} failed " + "with EXIT_STATUS:#{status.exitstatus} and STDERR:\n#{stderr}" end else string . concat item . to_s end string end end
src_file is needed by prepare_command in execution phase
because @inclusion_stack will have only root workflow by then
src_file is needed by prepare_command in execution phase because @inclusion_stack will have only root workflow by then
# For Escaped Char
text
<not_specific>
src_file
<not_specific>
context
<not_specific>
skip
<not_specific>