use of com.blackducksoftware.integration.hub.detect.detector.rubygems.GemlockParser.GemfileLockSection.BUNDLED_WITH in project hub-detect by blackducksoftware.
the class GemlockParser method parseProjectDependencies.
public DependencyGraph parseProjectDependencies(final List<String> gemfileLockLines) {
encounteredDependencies = new ArrayList<>();
resolvedDependencies = new ArrayList<>();
lazyBuilder = new LazyExternalIdDependencyGraphBuilder();
currentParent = null;
for (final String line : gemfileLockLines) {
final 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.contains(it)).collect(Collectors.toList());
for (final String missingName : missingDependencies) {
String missingVersion = "";
final DependencyId dependencyId = new NameDependencyId(missingName);
final ExternalId externalId = externalIdFactory.createNameVersionExternalId(Forge.RUBYGEMS, missingName, missingVersion);
lazyBuilder.setDependencyInfo(dependencyId, missingName, missingVersion, externalId);
}
return lazyBuilder.build();
}
Aggregations