Sha256: 38f0b4b9d5dae7855d3ef6ea6581e3f2538dc586a44013bce6f889672ece19ec

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

class MonoRepoDeps::Package
  include MonoRepoDeps::Mixins

  attr_reader :name, :root_path, :dependencies, :configs

  DEFAULT_ENV = :_default_

  DependencyDto = Struct.new(:name, :only, :skip, keyword_init: true)

  sig do
    params(
      name: Symbol,
      root_path: String,
      package_dirname: String,
      dependencies: T::Hash[Symbol, DependencyDto]
    )
    .void
  end
  def initialize(name:, root_path:, package_dirname:, dependencies:)
    @name = name
    @root_path = root_path
    @package_dirname = package_dirname
    @dependencies = dependencies

    nil
  end

  sig do
    params(env: T.nilable(Symbol)).returns(T::Array[DependencyDto])
  end
  def get_dependencies(env = nil)
    [DEFAULT_ENV, env].uniq.compact.inject([]) do |acc, item|
      acc += @dependencies.fetch(item, [])
    end
  end

  def get_dependency_envs
    @dependencies.keys
  end

  def workdir_path
    File.join( self.root_path, @package_dirname )
  end

  def entrypoint_file
    File.join( self.workdir_path, "#{name}.rb" )
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mono_repo_deps-0.1.14 lib/mono_repo_deps/package.rb
mono_repo_deps-0.1.13 lib/mono_repo_deps/package.rb