lib/resolvers/macosx/system_memory_resolver.rb in facter-4.0.20 vs lib/resolvers/macosx/system_memory_resolver.rb in facter-4.0.21

- old
+ new

@@ -4,11 +4,10 @@ module Resolvers module Macosx class SystemMemory < BaseResolver @semaphore = Mutex.new @fact_list ||= {} - @log = Facter::Log.new(self) class << self private def post_resolve(fact_name) @fact_list.fetch(fact_name) { calculate_system_memory(fact_name) } @@ -23,22 +22,22 @@ @fact_list[fact_name] end def read_available_memory_in_bytes - output, _status = Open3.capture2('vm_stat') + output = Facter::Core::Execution.execute('vm_stat', logger: log) page_size = output.match(/page size of (\d+) bytes/)[1].to_i pages_free = output.match(/Pages free:\s+(\d+)/)[1].to_i @fact_list[:available_bytes] = page_size * pages_free end def read_total_memory_in_bytes - @fact_list[:total_bytes] = Open3.capture2('sysctl -n hw.memsize').first.to_i + @fact_list[:total_bytes] = Facter::Core::Execution.execute('sysctl -n hw.memsize', logger: log).to_i end def compute_capacity(used, total) - format('%.2f', (used / total.to_f * 100)) + '%' + "#{format('%<value>.2f', value: (used / total.to_f * 100))}%" end end end end end