Esempio n. 1
0
func (s *SpecInfoGatherer) onFileModify(watcher *fsnotify.Watcher, file string) {
	if util.IsSpec(file) {
		s.onSpecFileModify(file)
	} else if util.IsConcept(file) {
		s.onConceptFileModify(file)
	}
}
Esempio n. 2
0
func (specInfoGatherer *SpecInfoGatherer) fileModified(watcher *fsnotify.Watcher, fileName string) {
	if util.IsSpec(fileName) {
		specInfoGatherer.addSpec(fileName)
	} else if util.IsConcept(fileName) {
		specInfoGatherer.addConcept(fileName)
	}
}
Esempio n. 3
0
func (s *SpecInfoGatherer) onFileRemove(watcher *fsnotify.Watcher, file string) {
	if util.IsSpec(file) {
		s.onSpecFileRemove(file)
	} else if util.IsConcept(file) {
		s.onConceptFileRemove(file)
	} else {
		s.removeWatcherOn(watcher, file)
	}
}
Esempio n. 4
0
func (specInfoGatherer *SpecInfoGatherer) fileRemoved(watcher *fsnotify.Watcher, fileName string) {
	if util.IsSpec(fileName) {
		specInfoGatherer.removeSpec(fileName)
	} else if util.IsConcept(fileName) {
		specInfoGatherer.removeConcept(fileName)
	} else {
		specInfoGatherer.removeWatcherOn(watcher, fileName)
	}
}
Esempio n. 5
0
func ExtractConcept(conceptName *gauge_messages.Step, steps []*gauge_messages.Step, conceptFileName string, changeAcrossProject bool, selectedTextInfo *gauge_messages.TextInfo) (bool, error, []string) {
	content := SPEC_HEADING_TEMPLATE
	if util.IsSpec(selectedTextInfo.GetFileName()) {
		content, _ = common.ReadFileContents(selectedTextInfo.GetFileName())
	}
	concept, conceptUsageText, err := getExtractedConcept(conceptName, steps, content)
	if err != nil {
		return false, err, []string{}
	}
	writeConceptToFile(concept, conceptUsageText, conceptFileName, selectedTextInfo.GetFileName(), selectedTextInfo)
	return true, errors.New(""), []string{conceptFileName, selectedTextInfo.GetFileName()}
}
Esempio n. 6
0
func (s *SpecInfoGatherer) handleEvent(event fsnotify.Event, watcher *fsnotify.Watcher) {
	s.waitGroup.Wait()

	file, err := filepath.Abs(event.Name)
	if err != nil {
		logger.APILog.Error("Failed to get abs file path for %s: %s", event.Name, err)
		return
	}
	if util.IsSpec(file) || util.IsConcept(file) {
		switch event.Op {
		case fsnotify.Create:
			s.onFileAdd(watcher, file)
		case fsnotify.Write:
			s.onFileModify(watcher, file)
		case fsnotify.Rename:
			s.onFileRename(watcher, file)
		case fsnotify.Remove:
			s.onFileRemove(watcher, file)
		}
	}
}