All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.searls.jasmine.io.scripts.ResolvesLocationOfPreloadSources Maven / Gradle / Ivy

Go to download

A JavaScript unit test plugin that processes JavaScript sources and Jasmine specs, prepares test runner HTML files, executes Jasmine specs headlessly with HtmlUnit, and produces JUnit XML reports

There is a newer version: 1.1.2
Show newest version
package com.github.searls.jasmine.io.scripts;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import com.github.searls.jasmine.collections.CollectionHelper;

public class ResolvesLocationOfPreloadSources {

	private CollectionHelper collectionHelper = new CollectionHelper();
	private ConvertsFileToUriString convertsFileToUriString = new ConvertsFileToUriString();

	public List resolve(List preloadSources, File sourceDir, File specDir) {
		List sources = new ArrayList();
		for (String source : collectionHelper.list(preloadSources)) {
			if(fileCouldNotBeAdded(new File(sourceDir, source),sources) 
				&& fileCouldNotBeAdded(new File(specDir, source),sources)
					&& fileCouldNotBeAdded(new File(source),sources)) {
				sources.add(source);
			}
		}
		return sources;
	}
	
	private boolean fileCouldNotBeAdded(File file, List sourcePaths) {
		boolean canAdd = file.exists();
		if (canAdd) {
			sourcePaths.add(convertsFileToUriString.convert(file));
		}
		return !canAdd;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy