Search in sources :

Example 1 with BUNDLED_WITH

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();
}
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

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 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)1 LazyExternalIdDependencyGraphBuilder (com.synopsys.integration.bdio.graph.builder.LazyExternalIdDependencyGraphBuilder)1 Forge (com.synopsys.integration.bdio.model.Forge)1 DependencyId (com.synopsys.integration.bdio.model.dependencyid.DependencyId)1 NameDependencyId (com.synopsys.integration.bdio.model.dependencyid.NameDependencyId)1 NameVersionDependencyId (com.synopsys.integration.bdio.model.dependencyid.NameVersionDependencyId)1 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)1 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)1 NameVersion (com.synopsys.integration.util.NameVersion)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1