Sha256: 4f1522c81d5f9620231813dbfbb61fc2972c9ac598d9ca45bcf4b633635a9cc0

Contents?: true

Size: 854 Bytes

Versions: 2

Compression:

Stored size: 854 Bytes

Contents

require 'set'

class Mona::Package::DependencyBypasser
  include Mona::Mixins

  Inject = Mona::Deps[
    packages_repo: "package.repo"
  ]

  include Inject

  sig do
    params(
      package_name: Symbol,
      env: Symbol,
    )
    .returns(T::Array[Symbol])
  end
  def call(package_name:, env:)
    walk(package_name: package_name, env: env, imported: Set.new)
  end

  private

  def walk(package_name:, env:, imported:, packages_order: [])
    package = packages_repo.find!(package_name)

    return if !imported.add?(package_name)

    package_dependencies = package.get_dependencies(env)

    package_dependencies.each do |name|
      walk(
        package_name: name,
        imported: imported,
        packages_order: packages_order,
        env: Mona::Package::DEFAULT_ENV,
      )
    end

    packages_order.push(package_name)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mona-0.2.3 lib/mona/package/dependency_bypasser.rb
mona-0.2.2 lib/mona/package/dependency_bypasser.rb