Search in sources :

Example 1 with CarthageDeclaration

use of com.synopsys.integration.detectable.detectables.carthage.model.CarthageDeclaration in project synopsys-detect by blackducksoftware.

the class CartfileResolvedParser method parseDependencies.

public List<CarthageDeclaration> parseDependencies(List<String> dependencyDeclarations) {
    // As of Carthage 0.38.0 the dependencies in Cartfile.resolved are produced as a flat list
    // Each line in a Cartfile.resolved file is a dependency declaration: <origin> <name/resource> <version>
    // eg. github "realm/realm-cocoa" "v10.7.2"
    List<CarthageDeclaration> carthageDeclarations = new LinkedList<>();
    for (String dependencyDeclaration : dependencyDeclarations) {
        String[] dependencyDeclarationPieces = dependencyDeclaration.split("\\s+");
        String origin = dependencyDeclarationPieces[0].trim();
        String name = StringUtils.strip(dependencyDeclarationPieces[1], "\"").trim();
        String version = StringUtils.strip(dependencyDeclarationPieces[2], "\"").trim();
        CarthageDeclaration carthageDeclaration = new CarthageDeclaration(origin, name, version);
        carthageDeclarations.add(carthageDeclaration);
    }
    return carthageDeclarations;
}
Also used : CarthageDeclaration(com.synopsys.integration.detectable.detectables.carthage.model.CarthageDeclaration) LinkedList(java.util.LinkedList)

Example 2 with CarthageDeclaration

use of com.synopsys.integration.detectable.detectables.carthage.model.CarthageDeclaration in project synopsys-detect by blackducksoftware.

the class CarthageDeclarationTransformerTest method happyCase.

@Test
void happyCase() {
    CarthageDeclarationTransformer transformer = new CarthageDeclarationTransformer();
    List<CarthageDeclaration> carthageDeclarations = Arrays.asList(new CarthageDeclaration("github", "some-name/resource", "some-version"), new CarthageDeclaration("github", "different-name/resource", "other-version"));
    DependencyGraph graph = transformer.transform(carthageDeclarations);
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.GITHUB, graph);
    graphAssert.hasRootDependency("some-name/resource", "some-version");
    graphAssert.hasRootDependency("different-name/resource", "other-version");
    graphAssert.hasRootSize(2);
}
Also used : CarthageDeclaration(com.synopsys.integration.detectable.detectables.carthage.model.CarthageDeclaration) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) CarthageDeclarationTransformer(com.synopsys.integration.detectable.detectables.carthage.transform.CarthageDeclarationTransformer) Test(org.junit.jupiter.api.Test)

Example 3 with CarthageDeclaration

use of com.synopsys.integration.detectable.detectables.carthage.model.CarthageDeclaration in project synopsys-detect by blackducksoftware.

the class CarthageExtractor method extract.

public Extraction extract(File cartfileResolved) throws IOException {
    List<String> dependencyDeclarations = Files.readAllLines(cartfileResolved.toPath());
    List<CarthageDeclaration> carthageDeclarations = cartfileResolvedParser.parseDependencies(dependencyDeclarations);
    DependencyGraph dependencyGraph = declarationTransformer.transform(carthageDeclarations);
    CodeLocation codeLocation = new CodeLocation(dependencyGraph);
    // No project info - hoping git can help with that.
    return Extraction.success(codeLocation);
}
Also used : CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) CarthageDeclaration(com.synopsys.integration.detectable.detectables.carthage.model.CarthageDeclaration) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph)

Example 4 with CarthageDeclaration

use of com.synopsys.integration.detectable.detectables.carthage.model.CarthageDeclaration in project synopsys-detect by blackducksoftware.

the class CarthageDeclarationTransformerTest method excludeNonGitHubOrigin.

@Test
void excludeNonGitHubOrigin() {
    CarthageDeclarationTransformer transformer = new CarthageDeclarationTransformer();
    List<CarthageDeclaration> carthageDeclarations = Arrays.asList(new CarthageDeclaration("binary", "https://some.binary.url", "binary-version"), new CarthageDeclaration("github", "some-name/resource", "some-version"), new CarthageDeclaration("wonky-origin", "wonky-name", "wonky-version"));
    DependencyGraph graph = transformer.transform(carthageDeclarations);
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.GITHUB, graph);
    graphAssert.hasRootDependency("some-name/resource", "some-version");
    graphAssert.hasNoDependency("https://some.binary.url", "binary-version");
    graphAssert.hasNoDependency("wonky-name", "wonky-version");
    graphAssert.hasRootSize(1);
}
Also used : CarthageDeclaration(com.synopsys.integration.detectable.detectables.carthage.model.CarthageDeclaration) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) CarthageDeclarationTransformer(com.synopsys.integration.detectable.detectables.carthage.transform.CarthageDeclarationTransformer) Test(org.junit.jupiter.api.Test)

Aggregations

CarthageDeclaration (com.synopsys.integration.detectable.detectables.carthage.model.CarthageDeclaration)4 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)3 CarthageDeclarationTransformer (com.synopsys.integration.detectable.detectables.carthage.transform.CarthageDeclarationTransformer)2 NameVersionGraphAssert (com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert)2 Test (org.junit.jupiter.api.Test)2 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)1 LinkedList (java.util.LinkedList)1