Sha256: ba6d2e450d5db6c188495fc23a48aea96f24bbe8c02892cd317b4c79fdc0e06a

Contents?: true

Size: 447 Bytes

Versions: 1

Compression:

Stored size: 447 Bytes

Contents

require 'facter'
require 'jgrep'

module FacterDB

  def self.get_os_facts(facter_version='*', filter=[])
    facts_dir = File.expand_path(File.join(File.dirname(__FILE__), '../facts'))
    filter_str = filter.map { |f| f.map { |k,v | "#{k}=#{v}" }.join(' and ') }.join(' or ')

    jsons = Dir.glob("#{facts_dir}/#{facter_version}/*.facts").map { |f| File.read(f) }
    json = "[#{jsons.join(',')}]\n"
    JGrep.jgrep(json, filter_str)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facterdb-0.1.0 lib/facterdb.rb