Class: Puppet::InfoService::ClassInformationService

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/info_service/class_information_service.rb

Instance Method Summary collapse

Constructor Details

#initializeClassInformationService

Returns a new instance of ClassInformationService.



7
8
9
10
# File 'lib/puppet/info_service/class_information_service.rb', line 7

def initialize
  @file_to_result = {}
  @parser = Puppet::Pops::Parser::EvaluatingParser.new()
end

Instance Method Details

#classes_per_environment(env_file_hash) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/puppet/info_service/class_information_service.rb', line 12

def classes_per_environment(env_file_hash)
  # In this version of puppet there is only one way to parse manifests, as feature switches per environment
  # are added or removed, this logic needs to change to compute the result per environment with the correct
  # feature flags in effect.

  unless env_file_hash.is_a?(Hash)
    raise ArgumentError, _('Given argument must be a Hash')
  end

  result = {}

  # for each environment
  #   for each file
  #     if file already processed, use last result or error
  #
  env_file_hash.each do |env, files|
    env_result = result[env] = {}
    files.each do |f|
      env_result[f] = result_of(f)
    end
  end
  result
end