Sha256: 44275eaf740444ccea73dec3c82e7c8bae0677e428058e5ebdbcc18eb19fa9e1

Contents?: true

Size: 771 Bytes

Versions: 19

Compression:

Stored size: 771 Bytes

Contents

# frozen_string_literal: true

module Facter
  # Filter inside value of a fact.
  # e.g. os.release.major is the user query, os.release is the fact
  # and major is the filter criteria inside tha fact
  class FactFilter
    def filter_facts!(searched_facts)
      filter_legacy_facts!(searched_facts)
      searched_facts.each do |fact|
        fact.value = if fact.filter_tokens.any? && fact.value.respond_to?(:dig)
                       fact.value.dig(*fact.filter_tokens)
                     else
                       fact.value
                     end
      end
    end

    private

    def filter_legacy_facts!(resolved_facts)
      return unless !Options[:show_legacy] && Options[:user_query].empty?

      resolved_facts.reject!(&:legacy?)
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
facter-4.0.35 lib/facter/framework/core/fact_filter.rb
facter-4.0.34 lib/facter/framework/core/fact_filter.rb
facter-4.0.33 lib/facter/framework/core/fact_filter.rb
facter-4.0.32 lib/facter/framework/core/fact_filter.rb
facter-4.0.31 lib/facter/framework/core/fact_filter.rb
facter-4.0.30 lib/facter/framework/core/fact_filter.rb
facter-4.0.29 lib/framework/core/fact_filter.rb
facter-4.0.28 lib/framework/core/fact_filter.rb
facter-4.0.26 lib/framework/core/fact_filter.rb
facter-4.0.25 lib/framework/core/fact_filter.rb
facter-4.0.24 lib/framework/core/fact_filter.rb
facter-4.0.23 lib/framework/core/fact_filter.rb
facter-4.0.22 lib/framework/core/fact_filter.rb
facter-4.0.21 lib/framework/core/fact_filter.rb
facter-4.0.20 lib/framework/core/fact_filter.rb
facter-4.0.19 lib/framework/core/fact_filter.rb
facter-4.0.18 lib/framework/core/fact_filter.rb
facter-4.0.17 lib/framework/core/fact_filter.rb
facter-4.0.16 lib/framework/core/fact_filter.rb