PK œqhYî¶J‚ßFßF)nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/ $#$#$#

Dir : /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/util/macosx/
Server: Linux server1.ngambekcore.com 4.18.0-553.51.1.el8_10.x86_64 #1 SMP Wed Apr 30 04:00:07 EDT 2025 x86_64
IP: 159.198.77.92
Choose File :

Url:
Dir : //opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/util/macosx/system_profile_executor.rb

# frozen_string_literal: true

module Facter
  module Util
    module Macosx
      class SystemProfileExecutor
        @log = Log.new(self)

        class << self
          def execute(category_name)
            @log.debug "Executing command: system_profiler #{category_name}"
            output = Facter::Core::Execution.execute(
              "system_profiler #{category_name}", logger: @log
            )&.force_encoding('UTF-8')

            return unless output

            system_profiler_hash = output_to_hash(output)

            normalize_keys(system_profiler_hash)
          end

          private

          def output_to_hash(output)
            output.scan(/.*: .*$/).map { |e| e.strip.match(/(.*?): (.*)/).captures }.to_h
          end

          def normalize_keys(system_profiler_hash)
            system_profiler_hash.transform_keys do |k|
              k.downcase.tr(' ', '_').delete("\(\)").to_sym
            end.to_h
          end
        end
      end
    end
  end
end