Sha256: 350cbb7ae8437ab2792be0652c3ee46402e5397c532ce21583c4bf78f3f6a1ca

Contents?: true

Size: 678 Bytes

Versions: 1

Compression:

Stored size: 678 Bytes

Contents

require "puppet_factset/version"
require "json"

module PuppetFactset
  # Return the name of the directory holding the factsets
  def self.factset_dir
    File.expand_path(File.join(File.dirname(__FILE__), '..', 'res', 'factset'))
  end

  # Load factset json file and return a hash
  def self.factset_hash(factset_name)
    data = JSON.parse(File.read(File.join(factset_dir(), "#{factset_name}.json")))

    # The facts are tucked away inside the 'values' element so just return that
    data["values"]
  end

  # List the available factsets
  def self.factsets()
    Dir.glob(File.join(factset_dir, '*.json')).map { |f|
      File.basename(f).gsub('.json','')
    }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
puppet_factset-0.2.0 lib/puppet_factset.rb