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