Class: ParsePackwerk::PackageSet

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/parse_packwerk/package_set.rb

Class Method Summary collapse

Class Method Details

.from(package_pathspec:, exclude_pathspec:) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/parse_packwerk/package_set.rb', line 12

def self.from(package_pathspec:, exclude_pathspec:)
  package_glob_patterns = package_pathspec.map do |pathspec|
    File.join(pathspec, PACKAGE_YML_NAME)
  end

  # The T.unsafe is because the upstream RBI is wrong for Pathname.glob
  package_paths = T.unsafe(Pathname).glob(package_glob_patterns)
    .map(&:cleanpath)
    .reject { |path| exclude_path?(exclude_pathspec, path) }

  package_paths.uniq.map do |path|
    Package.from(path)
  end
end