use of com.synopsys.integration.detectable.detectables.rubygems.gemlock.parse.GemlockParser.GemfileLockSection.SPECS in project synopsys-detect by blackducksoftware.
the class GemlockParser method parseProjectDependencies.
public DependencyGraph parseProjectDependencies(List<String> gemfileLockLines) throws MissingExternalIdException {
encounteredDependencies = new HashSet<>();
resolvedDependencies = new HashMap<>();
lazyBuilder = new LazyExternalIdDependencyGraphBuilder();
currentParent = null;
for (String line : gemfileLockLines) {
String trimmedLine = StringUtils.trimToEmpty(line);
if (StringUtils.isBlank(trimmedLine)) {
currentSection = NONE;
} else if (SPECS_HEADER.equals(trimmedLine)) {
currentSection = SPECS;
} else if (DEPENDENCIES_HEADER.equals(trimmedLine)) {
currentSection = DEPENDENCIES;
} else if (BUNDLED_WITH_HEADER.equals(trimmedLine)) {
currentSection = BUNDLED_WITH;
} else if (BUNDLED_WITH.equals(currentSection)) {
addBundlerDependency(trimmedLine);
} else if (SPECS.equals(currentSection)) {
parseSpecsSectionLine(line);
} else if (DEPENDENCIES.equals(currentSection)) {
parseDependencySectionLine(trimmedLine);
}
}
List<String> missingDependencies = encounteredDependencies.stream().filter(it -> !resolvedDependencies.containsKey(it)).collect(Collectors.toList());
for (String missingName : missingDependencies) {
final String missingVersion = "";
LazyId dependencyId = LazyId.fromName(missingName);
ExternalId externalId = externalIdFactory.createNameVersionExternalId(Forge.RUBYGEMS, missingName, missingVersion);
lazyBuilder.setDependencyInfo(dependencyId, missingName, missingVersion, externalId);
}
return lazyBuilder.build();
}
Aggregations