Module: PuppetfileResolver::SpecSearchers::Local

Defined in:
lib/puppetfile-resolver/spec_searchers/local.rb

Class Method Summary collapse

Class Method Details

.find_all(_puppetfile_module, dependency, cache, resolver_ui, config) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/puppetfile-resolver/spec_searchers/local.rb', line 9

def self.find_all(_puppetfile_module, dependency, cache, resolver_ui, config)
  dep_id = ::PuppetfileResolver::SpecSearchers::Common.dependency_cache_id(self, dependency)
  # Has the information been cached?
  return cache.load(dep_id) if cache.exist?(dep_id)

  result = []
  # Find the module in the modulepaths
  config.puppet_module_paths.each do |module_path|
    next unless Dir.exist?(module_path)
    module_dir = File.expand_path(File.join(module_path, dependency.name))
    next unless Dir.exist?(module_dir)
     = File.join(module_dir, 'metadata.json')
    next unless File.exist?()

     = nil
    begin
       = ::PuppetfileResolver::Util.symbolise_object(
        ::JSON.parse(File.open(, 'rb:utf-8') { |f| f.read })
      )
    rescue StandardError => _e # rubocop:disable Lint/SuppressedException Todo
      # TODO: Should really do something?
    end
    resolver_ui.debug { "Found local module at #{}" }

    result << Models::ModuleSpecification.new(
      name: [:name],
      origin: :local,
      version: [:version],
      metadata: 
    )
  end
  cache.save(dep_id, result)

  result
end