Class: FactDif

Inherits:
Object show all
Defined in:
lib/puppet/util/fact_dif.rb

Instance Method Summary collapse

Constructor Details

#initialize(old_output, new_output, exclude_list, save_structured) ⇒ FactDif

Returns a new instance of FactDif.



4
5
6
7
8
9
10
11
# File 'lib/puppet/util/fact_dif.rb', line 4

def initialize(old_output, new_output, exclude_list, save_structured)
  @c_facter = JSON.parse(old_output)
  @next_facter = JSON.parse(new_output)
  @exclude_list = exclude_list
  @save_structured = save_structured
  @flat_diff = []
  @diff = {}
end

Instance Method Details

#difsObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/puppet/util/fact_dif.rb', line 13

def difs
  search_hash(((@c_facter.to_a - @next_facter.to_a) | (@next_facter.to_a - @c_facter.to_a)).to_h)

  @flat_diff.sort_by { |a| a[0] }.each do |pair|
    fact_path = pair[0]
    value = pair[1]
    compare(fact_path, value, @c_facter)
    compare(fact_path, value, @next_facter)
  end

  @diff
end