Sha256: 853b56ffc2e8a7e7a04186e0534afa9a1e876f58a3eba1011d12bdad2fbedb29
Contents?: true
Size: 997 Bytes
Versions: 17
Compression:
Stored size: 997 Bytes
Contents
# frozen_string_literal: true module Facter module Resolvers 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.map do |k, v| [k.downcase.tr(' ', '_').delete("\(\)").to_sym, v] end.to_h end end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems