Skip to content

Commit

Permalink
refactor(bundler): Refer to data from https://rubygems.org as "RubyGems"
Browse files Browse the repository at this point in the history
This is partly a fixup for 7e49e1b.

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Jul 2, 2024
1 parent 51d0bec commit a8f6547
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions plugins/package-managers/bundler/src/main/kotlin/Bundler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,14 @@ class Bundler(
val gemId = Identifier("Gem", "", gemSpec.name, gemSpec.version)

// The project itself can be listed as a dependency if the project is a gem (i.e. there is a .gemspec file
// for it, and the Gemfile refers to it). In that case, skip querying Rubygems and adding Package and
// for it, and the Gemfile refers to it). In that case, skip querying RubyGems and adding Package and
// PackageReference objects and continue with the projects dependencies.
if (gemId == projectId) {
gemSpec.runtimeDependencies.forEach {
parseDependency(workingDir, projectId, it, gemSpecs, scopeDependencies, issues)
}
} else {
queryRubygems(gemId.name, gemId.version)?.apply {
queryRubyGems(gemId.name, gemId.version)?.apply {
gemSpecs[gemName] = merge(gemSpec)
}

Expand Down Expand Up @@ -357,7 +357,7 @@ class Bundler(
private fun getGemspecFile(workingDir: File) =
workingDir.walk().maxDepth(1).filter { it.isFile && it.extension == "gemspec" }.firstOrNull()

private fun queryRubygems(name: String, version: String, retryCount: Int = 3): GemSpec? {
private fun queryRubyGems(name: String, version: String, retryCount: Int = 3): GemSpec? {
// NOTE: Explicitly use platform=ruby here to enforce the same behavior here that is also used in the Bundler
// resolving logic.
// See plugins/package-managers/bundler/src/main/resources/resolve_dependencies.rb
Expand Down Expand Up @@ -386,7 +386,7 @@ class Bundler(
if (retryCount > 0) {
// We see a lot of sporadic "bad gateway" responses that disappear when trying again.
Thread.sleep(100)
return queryRubygems(name, version, retryCount - 1)
return queryRubyGems(name, version, retryCount - 1)
}

throw IOException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ class BundlerTest : WordSpec({

"createFromGem()" should {
"parse YAML metadata for a Gem correctly" {
val gemSpecFile = File("src/test/assets/rspec-3.7.0.yaml")
val rubyGemsFile = File("src/test/assets/rspec-3.7.0.yaml")

val gemspec = GemSpec.createFromGem(gemSpecFile.readValue())
val gemspec = GemSpec.createFromGem(rubyGemsFile.readValue())

gemspec shouldBe GemSpec(
name = "rspec",
Expand Down

0 comments on commit a8f6547

Please sign in to comment.