use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class PipfileLockDependencyTransformer method transform.
public DependencyGraph transform(List<PipfileLockDependency> dependencies) {
DependencyGraph dependencyGraph = new BasicDependencyGraph();
dependencies.stream().map(this::createDependency).forEach(dependencyGraph::addChildToRoot);
return dependencyGraph;
}
use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class PubDepsParser method parse.
public DependencyGraph parse(List<String> pubDepsOutput) {
DependencyGraph dependencyGraph = new BasicDependencyGraph();
Map<String, String> resolvedVersions = resolveVersionsOfDependencies(pubDepsOutput);
parseLines(pubDepsOutput, resolvedVersions, dependencyGraph);
return dependencyGraph;
}
use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class PubSpecLockParser method parse.
public DependencyGraph parse(List<String> pubSpecLockLines) {
DependencyGraph dependencyGraph = new BasicDependencyGraph();
// TODO- do we even need these booleans? will there be cases we run into name and version keys that we don't want to read/don't correspond to a dependency?
boolean inPackages = false;
boolean inDescription = false;
Optional<String> dependencyName = Optional.empty();
for (String line : pubSpecLockLines) {
String trimmedLine = StringUtils.trimToEmpty(line);
if (StringUtils.isBlank(trimmedLine)) {
continue;
} else if (trimmedLine.equals(PACKAGES_SECTION_HEADER)) {
inPackages = true;
} else if (inPackages && trimmedLine.equals(DESCRIPTION_SECTION_HEADER)) {
inDescription = true;
} else if (inDescription && trimmedLine.startsWith(NAME_LINE_KEY)) {
dependencyName = parseValueFromLine(trimmedLine, NAME_LINE_KEY);
} else if (inPackages && trimmedLine.startsWith(VERSION_LINE_KEY)) {
Optional<String> dependencyVersion = parseValueFromLine(trimmedLine, VERSION_LINE_KEY);
if (dependencyName.isPresent() && dependencyVersion.isPresent()) {
dependencyGraph.addChildToRoot(DependencyCreator.nameVersion(Forge.DART, dependencyName.get(), dependencyVersion.get()));
// After process dependency, reset name and version variables
dependencyName = Optional.empty();
}
}
}
return dependencyGraph;
}
use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class CpanListParser method parse.
// TODO: In a transformer
public DependencyGraph parse(List<String> cpanListText, List<String> directDependenciesText) {
Map<String, String> nameVersionMap = createNameVersionMap(cpanListText);
// Lazy builder.
List<String> directModuleNames = getDirectModuleNames(directDependenciesText);
DependencyGraph graph = new BasicDependencyGraph();
for (String moduleName : directModuleNames) {
String version = nameVersionMap.get(moduleName);
if (null != version) {
String name = moduleName.replace("::", "-");
ExternalId externalId = externalIdFactory.createNameVersionExternalId(Forge.CPAN, name, version);
Dependency dependency = new Dependency(name, version, externalId);
graph.addChildToRoot(dependency);
} else {
logger.warn(String.format("Could node find resolved version for module: %s", moduleName));
}
}
return graph;
}
use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class GoLockParser method parseDepLock.
public DependencyGraph parseDepLock(InputStream depLockInputStream) {
DependencyGraph graph = new BasicDependencyGraph();
GoLock goLock = new Toml().read(depLockInputStream).to(GoLock.class);
if (goLock.projects != null) {
for (Project project : goLock.projects) {
if (project != null) {
String projectName = project.getName();
String projectVersion = Optional.ofNullable(StringUtils.stripToNull(project.getVersion())).orElse(project.getRevision());
project.getPackages().stream().map(packageName -> createDependencyName(projectName, packageName)).map(dependencyName -> createGoDependency(dependencyName, projectVersion)).forEach(graph::addChildToRoot);
}
}
}
return graph;
}
Aggregations