Search in sources :

Example 6 with NameDependencyId

use of com.synopsys.integration.bdio.model.dependencyid.NameDependencyId in project hub-detect by blackducksoftware.

the class GemlockParser method processNameVersion.

// If you have Version, you know everything. Otherwise, you need to find this version later.
// Generally each parse/process call should either call this or add to encountered.
private DependencyId processNameVersion(NameVersion nameVersion) {
    NameDependencyId nameDependencyId = new NameDependencyId(nameVersion.getName());
    if (StringUtils.isNotBlank(nameVersion.getVersion())) {
        NameVersionDependencyId nameVersionDependencyId = new NameVersionDependencyId(nameVersion.getName(), nameVersion.getVersion());
        discoveredDependencyInfo(nameVersionDependencyId);
    } else {
        encounteredDependencies.add(nameVersion.getName());
    }
    return nameDependencyId;
}
Also used : NameVersionDependencyId(com.synopsys.integration.bdio.model.dependencyid.NameVersionDependencyId) NameDependencyId(com.synopsys.integration.bdio.model.dependencyid.NameDependencyId)

Example 7 with NameDependencyId

use of com.synopsys.integration.bdio.model.dependencyid.NameDependencyId 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();
}
Also used : NONE(com.blackducksoftware.integration.hub.detect.detector.rubygems.GemlockParser.GemfileLockSection.NONE) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Logger(org.slf4j.Logger) BUNDLED_WITH(com.blackducksoftware.integration.hub.detect.detector.rubygems.GemlockParser.GemfileLockSection.BUNDLED_WITH) Forge(com.synopsys.integration.bdio.model.Forge) LoggerFactory(org.slf4j.LoggerFactory) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) LazyExternalIdDependencyGraphBuilder(com.synopsys.integration.bdio.graph.builder.LazyExternalIdDependencyGraphBuilder) DependencyId(com.synopsys.integration.bdio.model.dependencyid.DependencyId) Collectors(java.util.stream.Collectors) StringUtils(org.apache.commons.lang3.StringUtils) NameDependencyId(com.synopsys.integration.bdio.model.dependencyid.NameDependencyId) ArrayList(java.util.ArrayList) NameVersion(com.synopsys.integration.util.NameVersion) List(java.util.List) SPECS(com.blackducksoftware.integration.hub.detect.detector.rubygems.GemlockParser.GemfileLockSection.SPECS) Optional(java.util.Optional) DEPENDENCIES(com.blackducksoftware.integration.hub.detect.detector.rubygems.GemlockParser.GemfileLockSection.DEPENDENCIES) NameVersionDependencyId(com.synopsys.integration.bdio.model.dependencyid.NameVersionDependencyId) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) DependencyId(com.synopsys.integration.bdio.model.dependencyid.DependencyId) NameDependencyId(com.synopsys.integration.bdio.model.dependencyid.NameDependencyId) NameVersionDependencyId(com.synopsys.integration.bdio.model.dependencyid.NameVersionDependencyId) NameDependencyId(com.synopsys.integration.bdio.model.dependencyid.NameDependencyId) LazyExternalIdDependencyGraphBuilder(com.synopsys.integration.bdio.graph.builder.LazyExternalIdDependencyGraphBuilder) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId)

Aggregations

NameDependencyId (com.synopsys.integration.bdio.model.dependencyid.NameDependencyId)7 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)5 LazyExternalIdDependencyGraphBuilder (com.synopsys.integration.bdio.graph.builder.LazyExternalIdDependencyGraphBuilder)4 NameVersionDependencyId (com.synopsys.integration.bdio.model.dependencyid.NameVersionDependencyId)4 DependencyId (com.synopsys.integration.bdio.model.dependencyid.DependencyId)3 NameVersion (com.synopsys.integration.util.NameVersion)3 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)2 BUNDLED_WITH (com.blackducksoftware.integration.hub.detect.detector.rubygems.GemlockParser.GemfileLockSection.BUNDLED_WITH)1 DEPENDENCIES (com.blackducksoftware.integration.hub.detect.detector.rubygems.GemlockParser.GemfileLockSection.DEPENDENCIES)1 NONE (com.blackducksoftware.integration.hub.detect.detector.rubygems.GemlockParser.GemfileLockSection.NONE)1 SPECS (com.blackducksoftware.integration.hub.detect.detector.rubygems.GemlockParser.GemfileLockSection.SPECS)1 DetectCodeLocation (com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation)1 JsonObject (com.google.gson.JsonObject)1 JsonParser (com.google.gson.JsonParser)1 GraphEdge (com.paypal.digraph.parser.GraphEdge)1 GraphNode (com.paypal.digraph.parser.GraphNode)1 Forge (com.synopsys.integration.bdio.model.Forge)1 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1