use of com.synopsys.integration.detectable.detectables.rubygems.gemlock.parse.GemlockParser in project synopsys-detect by blackducksoftware.
the class GemlockNodeParserTest method testParsingEqualsGemfileLock.
@Test
public void testParsingEqualsGemfileLock() throws MissingExternalIdException {
List<String> gemfileLockContents = Arrays.asList("GEM", " remote: https://artifactory.ilabs.io/artifactory/api/gems/gem-public/", " specs:", " SyslogLogger (2.0)", " activesupport (4.1.15)", " json (~> 1.7, >= 1.7.7)", " json (1.8.6)", "", "PLATFORMS", " ruby", "", "DEPENDENCIES", " SyslogLogger (~> 2.0)", " activesupport (~> 4.1.15)");
GemlockParser gemlockNodeParser = new GemlockParser(new ExternalIdFactory());
DependencyGraph dependencyGraph = gemlockNodeParser.parseProjectDependencies(gemfileLockContents);
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.RUBYGEMS, dependencyGraph);
graphAssert.hasRootSize(2);
graphAssert.hasRootDependency("activesupport", "4.1.15");
graphAssert.hasRootDependency("SyslogLogger", "2.0");
graphAssert.hasParentChildRelationship("activesupport", "4.1.15", "json", "1.8.6");
}
use of com.synopsys.integration.detectable.detectables.rubygems.gemlock.parse.GemlockParser in project synopsys-detect by blackducksoftware.
the class RubygemsNodePackagerTest method findsAllVersions.
@Test
void findsAllVersions() throws MissingExternalIdException {
// Finds all versions of the package not just the first matching architecture.
List<String> actualText = Arrays.asList("GEM", " remote: https://rubygems.org/", " specs:", " nokogiri (1.8.2)", " mini_portile2 (~> 2.3.0)", " nokogiri (1.8.2-java)", " nokogiri (1.8.2-x86-mingw32)", " nokoparent (3.1.0)", " nokogiri (~> 1.8)", "", "PLATFORMS", " java", " ruby", " x86-mingw32", "", "DEPENDENCIES", " nokoparent (>= 1)", " nokogiri (>= 1.8.1)");
GemlockParser rubygemsNodePackager = new GemlockParser(new ExternalIdFactory());
DependencyGraph graph = rubygemsNodePackager.parseProjectDependencies(actualText);
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.RUBYGEMS, graph);
graphAssert.hasRootSize(2);
graphAssert.hasRootDependency("nokoparent", "3.1.0");
graphAssert.hasRootDependency("nokogiri", "1.8.2");
graphAssert.hasNoDependency("nokogiri", "");
graphAssert.hasDependency("nokogiri", "1.8.2");
graphAssert.hasDependency("nokogiri", "1.8.2-java");
graphAssert.hasDependency("nokogiri", "1.8.2-x86-mingw32");
graphAssert.hasParentChildRelationship("nokoparent", "3.1.0", "nokogiri", "1.8.2");
graphAssert.hasParentChildRelationship("nokogiri", "1.8.2", "mini_portile2", "");
}
use of com.synopsys.integration.detectable.detectables.rubygems.gemlock.parse.GemlockParser in project synopsys-detect by blackducksoftware.
the class GemlockExtractor method extract.
public Extraction extract(File gemlock) {
try {
List<String> gemlockText = Files.readAllLines(gemlock.toPath(), StandardCharsets.UTF_8);
GemlockParser gemlockParser = new GemlockParser(externalIdFactory);
DependencyGraph dependencyGraph = gemlockParser.parseProjectDependencies(gemlockText);
CodeLocation codeLocation = new CodeLocation(dependencyGraph);
return new Extraction.Builder().success(codeLocation).build();
} catch (Exception e) {
return new Extraction.Builder().exception(e).build();
}
}
use of com.synopsys.integration.detectable.detectables.rubygems.gemlock.parse.GemlockParser in project synopsys-detect by blackducksoftware.
the class GemlockNodeParserTest method testMissingVersionsGemfileLock.
@Test
public void testMissingVersionsGemfileLock() throws MissingExternalIdException {
List<String> gemfileLockContents = Arrays.asList("GEM", " remote: https://artifactory.rds.lexmark.com/artifactory/api/gems/rubygems/", " remote: https://artifactory.rds.lexmark.com/artifactory/api/gems/enterprise-gem-IDP/", " specs:", " activesupport (4.2.7.1)", " thread_safe (~> 0.3, >= 0.3.4)", " tzinfo (~> 1.1)", " bullet (5.5.0)", " activesupport (>= 3.0.0)", " uniform_notifier (~> 1.10.0)", " devise (4.2.1)", " thread_safe (0.3.6-java)", " tzinfo (1.2.3)", " thread_safe (~> 0.1)", " uniform_notifier (1.10.0)", "", "PLATFORMS", " java", "", "DEPENDENCIES", " bullet (~> 5.5.0)", " devise (~> 4.2.1)");
GemlockParser gemlockNodeParser = new GemlockParser(new ExternalIdFactory());
DependencyGraph dependencyGraph = gemlockNodeParser.parseProjectDependencies(gemfileLockContents);
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.RUBYGEMS, dependencyGraph);
graphAssert.hasRootSize(2);
graphAssert.hasRootDependency("bullet", "5.5.0");
graphAssert.hasRootDependency("devise", "4.2.1");
graphAssert.hasParentChildRelationship("bullet", "5.5.0", "activesupport", "4.2.7.1");
graphAssert.hasParentChildRelationship("activesupport", "4.2.7.1", "tzinfo", "1.2.3");
graphAssert.hasParentChildRelationship("tzinfo", "1.2.3", "thread_safe", "0.3.6-java");
graphAssert.hasParentChildRelationship("bullet", "5.5.0", "uniform_notifier", "1.10.0");
}
Aggregations