[Pkg-puppet-devel] [facter] 244/352: (maint) Iteratively deep merge values for default aggregate

Stig Sandbeck Mathisen ssm at debian.org
Sun Apr 6 22:21:50 UTC 2014


This is an automated email from the git hooks/post-receive script.

ssm pushed a commit to branch master
in repository facter.

commit 0bb22462a0f3376189a3e8ac2a0419942f8ae80f
Author: Adrien Thebo <git at somethingsinistral.net>
Date:   Fri Jan 31 15:41:18 2014 -0800

    (maint) Iteratively deep merge values for default aggregate
    
    Without this commit the aggregate deep merge behavior would try to pass
    all chunk values to the deep merge method at once, which was pretty
    broken. This commit uses inject to iterately merge all values.
---
 lib/facter/core/aggregate.rb     |  4 +++-
 spec/unit/core/aggregate_spec.rb | 10 +++-------
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/lib/facter/core/aggregate.rb b/lib/facter/core/aggregate.rb
index 948fad8..619bf1c 100644
--- a/lib/facter/core/aggregate.rb
+++ b/lib/facter/core/aggregate.rb
@@ -192,7 +192,9 @@ class Facter::Core::Aggregate
   end
 
   def default_aggregate(results)
-    Facter::Util::Values.deep_merge(results.keys)
+    results.values.inject do |result, current|
+      Facter::Util::Values.deep_merge(result, current)
+    end
   rescue Facter::Util::Values::DeepMergeError => e
     raise ArgumentError, "No aggregate block specified and could not deep merge" +
       " all chunks, either specify an aggregate block or ensure that all chunks" +
diff --git a/spec/unit/core/aggregate_spec.rb b/spec/unit/core/aggregate_spec.rb
index fd4bcb6..f22d150 100644
--- a/spec/unit/core/aggregate_spec.rb
+++ b/spec/unit/core/aggregate_spec.rb
@@ -5,11 +5,7 @@ describe Facter::Core::Aggregate do
 
   let(:fact) { stub('stub_fact', :name => 'stub_fact') }
 
-  subject do
-    obj = described_class.new('aggregated', fact)
-    obj.aggregate { |chunks| chunks.values }
-    obj
-  end
+  subject { obj = described_class.new('aggregated', fact) }
 
   it "can be resolved" do
     expect(subject).to be_a_kind_of Facter::Core::Resolvable
@@ -78,9 +74,9 @@ describe Facter::Core::Aggregate do
     end
 
     it "passes all requested chunk results to the depending chunk" do
-      subject.chunk(:first) { 'foo' }
+      subject.chunk(:first) { ['foo'] }
       subject.chunk(:second, :require => [:first]) do |first|
-        "#{first} bar"
+        [first[0] + ' bar']
       end
 
       output = subject.value

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git



More information about the Pkg-puppet-devel mailing list