Sha256: 18f4062d31037ef45b8e42e37452f53b79692b6c4949a06211b7aacd7c9d62ba

Contents?: true

Size: 514 Bytes

Versions: 3

Compression:

Stored size: 514 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
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
puppet_factset-0.1.1 lib/puppet_factset.rb
puppet_factset-0.1.0 lib/puppet_factset.rb
puppet_factset-0.0.1 lib/puppet_factset.rb