Пример #1
0
func (self *extractor) extractSteps() {
	for _, step := range self.stepsToExtract {
		tokens, _ := new(parser.SpecParser).GenerateTokens("*" + step.GetName())
		stepInConcept, _ := parser.CreateStepUsingLookup(tokens[0], nil)
		if step.GetTable() != "" {
			self.handleTable(stepInConcept, step)
		}
		stepInConcept.ReplaceArgsWithDynamic(self.conceptStep.Args)
		self.stepsInConcept += formatter.FormatStep(stepInConcept)
	}
}
Пример #2
0
func getRefactorAgent(oldStepText, newStepText string, startChan *runner.StartChannels) (*rephraseRefactorer, error) {
	specParser := new(parser.SpecParser)
	stepTokens, err := specParser.GenerateTokens("* " + oldStepText + "\n" + "*" + newStepText)
	if err != nil {
		return nil, err
	}

	steps := make([]*gauge.Step, 0)
	for _, stepToken := range stepTokens {
		step, parseDetails := parser.CreateStepUsingLookup(stepToken, nil)
		if parseDetails != nil && parseDetails.Error != nil {
			return nil, parseDetails.Error
		}
		steps = append(steps, step)
	}
	return &rephraseRefactorer{oldStep: steps[0], newStep: steps[1], startChan: startChan}, nil
}
Пример #3
0
func getExtractedConcept(conceptName *gauge_messages.Step, steps []*gauge_messages.Step, content string) (string, string, error) {
	tokens, _ := new(parser.SpecParser).GenerateTokens("* " + conceptName.GetName())
	conceptStep, _ := parser.CreateStepUsingLookup(tokens[0], nil)
	specText, err := getContentWithDataTable(content)
	if err != nil {
		return "", "", err
	}
	extractor := &extractor{conceptName: "* " + conceptName.GetName(), stepsInConcept: "", stepsToExtract: steps, conceptStep: conceptStep, table: &gauge.Table{}, fileContent: specText, errors: make([]error, 0)}
	extractor.extractSteps()
	if len(extractor.errors) != 0 {
		return "", "", err
	}
	conceptStep.ReplaceArgsWithDynamic(conceptStep.Args)
	addArgsFromTable(conceptStep, &extractor.conceptName, extractor.dynamicArgs)
	if extractor.table.IsInitialized() {
		extractor.conceptName += "\n" + formatter.FormatTable(extractor.table)
	}
	return strings.Replace(formatter.FormatStep(conceptStep), "* ", "# ", 1) + (extractor.stepsInConcept), extractor.conceptName, nil
}