Sha256: 8277f113aed042516ca7960a5c2c0838a42368a8e9225def5482036bb39f3cfb

Contents?: true

Size: 703 Bytes

Versions: 3

Compression:

Stored size: 703 Bytes

Contents

# frozen_string_literal: true

module Facter
  module Resolvers
    class Uptime < BaseResolver
      init_resolver

      class << self
        private

        def post_resolve(fact_name)
          @fact_list.fetch(fact_name) { uptime_system_call(fact_name) }
        end

        def uptime_system_call(fact_name)
          seconds = Facter::Util::Facts::UptimeParser.uptime_seconds_unix
          build_fact_list(seconds)

          @fact_list[fact_name]
        end

        def build_fact_list(seconds)
          return @fact_list[:uptime] = 'unknown' unless seconds

          @fact_list = Facter::Util::Resolvers::UptimeHelper.create_uptime_hash(seconds)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facter-4.0.49 lib/facter/resolvers/uptime.rb
facter-4.0.48 lib/facter/resolvers/uptime.rb
facter-4.0.47 lib/facter/resolvers/uptime_resolver.rb