Module: Packs::Specification

Extended by:
T::Sig
Defined in:
lib/packs/specification.rb,
lib/packs/specification/configuration.rb

Defined Under Namespace

Classes: Configuration

Class Method Summary collapse

Class Method Details

.allObject



31
32
33
# File 'lib/packs/specification.rb', line 31

def all
  packs_by_name.values
end

.bust_cache!Object



24
25
26
27
28
# File 'lib/packs/specification.rb', line 24

def bust_cache!
  @packs_by_name = nil
  @for_file = nil
  @config = nil
end

.configObject



18
19
20
21
# File 'lib/packs/specification.rb', line 18

def config
  @config = T.let(@config, T.nilable(Configuration))
  @config ||= Configuration.fetch
end

.find(name) ⇒ Object



36
37
38
# File 'lib/packs/specification.rb', line 36

def find(name)
  packs_by_name[name]
end

.for_file(file_path) ⇒ Object



41
42
43
44
45
46
# File 'lib/packs/specification.rb', line 41

def for_file(file_path)
  path_string = file_path.to_s
  @for_file = T.let(@for_file, T.nilable(T::Hash[String, T.nilable(Pack)]))
  @for_file ||= {}
  @for_file[path_string] ||= all.find { |package| path_string.start_with?("#{package.name}/") || path_string == package.name }
end

.rootObject



13
14
15
# File 'lib/packs/specification.rb', line 13

def root
  Pathname.pwd
end