diff modules/stdlib/lib/facter/facter_dot_d.rb @ 37:addb0ea390a1 puppet-3.6

Update Puppet "stdlib" module
author IBBoard <dev@ibboard.co.uk>
date Sat, 14 Mar 2015 20:09:45 +0000
parents 956e484adc12
children c42fb28cff86
line wrap: on
line diff
--- a/modules/stdlib/lib/facter/facter_dot_d.rb	Sat Mar 14 20:07:04 2015 +0000
+++ b/modules/stdlib/lib/facter/facter_dot_d.rb	Sat Mar 14 20:09:45 2015 +0000
@@ -15,7 +15,7 @@
 class Facter::Util::DotD
   require 'yaml'
 
-  def initialize(dir="/etc/facts.d", cache_file="/tmp/facts_cache.yml")
+  def initialize(dir="/etc/facts.d", cache_file=File.join(Puppet[:libdir], "facts_dot_d.cache"))
     @dir = dir
     @cache_file = cache_file
     @cache = nil
@@ -23,7 +23,7 @@
   end
 
   def entries
-    Dir.entries(@dir).reject{|f| f =~ /^\.|\.ttl$/}.sort.map {|f| File.join(@dir, f) }
+    Dir.entries(@dir).reject { |f| f =~ /^\.|\.ttl$/ }.sort.map { |f| File.join(@dir, f) }
   rescue
     []
   end
@@ -40,7 +40,7 @@
 
   def txt_parser(file)
     File.readlines(file).each do |line|
-      if line =~ /^(.+)=(.+)$/
+      if line =~ /^([^=]+)=(.+)$/
         var = $1; val = $2
 
         Facter.add(var) do
@@ -113,7 +113,7 @@
 
   def cache_save!
     cache = load_cache
-    File.open(@cache_file, "w", 0600) {|f| f.write(YAML.dump(cache)) }
+    File.open(@cache_file, "w", 0600) { |f| f.write(YAML.dump(cache)) }
   rescue
   end