Module: AbideDevUtils::XCCDF::Diff

Defined in:
lib/abide_dev_utils/xccdf/diff.rb,
lib/abide_dev_utils/xccdf/diff/utils.rb,
lib/abide_dev_utils/xccdf/diff/benchmark.rb,
lib/abide_dev_utils/xccdf/diff/benchmark/profile.rb,
lib/abide_dev_utils/xccdf/diff/benchmark/property.rb,
lib/abide_dev_utils/xccdf/diff/benchmark/number_title.rb,
lib/abide_dev_utils/xccdf/diff/benchmark/property_existence.rb

Overview

Holds methods and classes used to diff XCCDF-derived objects.

Defined Under Namespace

Modules: BenchmarkPropertyDiff Classes: BenchmarkDiff, ChangeSet, DiffChangeResult, DiffTypeText, InconsistentDiffTypeError, NumberTitleContainer, NumberTitleContainerStandIn, NumberTitleDiff, NumberTitleDiffError, ProfileDiff, ProfileRuleContainer, PropChecker, PropertyExistenceChecker

Constant Summary collapse

DEFAULT_DIFF_OPTS =
{
  similarity: 1,
  strict: true,
  strip: true,
  array_path: true,
  delimiter: '//',
  use_lcs: true,
}.freeze

Class Method Summary collapse

Class Method Details

.diff_benchmarks(benchmark_a, benchmark_b, opts = {}) ⇒ Object



212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/abide_dev_utils/xccdf/diff.rb', line 212

def self.diff_benchmarks(benchmark_a, benchmark_b, opts = {})
  profile = opts.fetch(:profile, nil)
  profile_key = profile.nil? ? 'all_profiles' : profile
  benchmark_diff = BenchmarkDiff.new(benchmark_a, benchmark_b, opts)
  transform_method_sym = opts.fetch(:raw, false) ? :to_h : :to_s
  diff = if profile.nil?
           benchmark_diff.profiles.each do |_, v|
             v.transform_values! { |x| x.map!(&transform_method_sym) }
           end
         else
           benchmark_diff.profiles(profile: profile)[profile].transform_values! { |x| x.map!(&transform_method_sym) }
         end
  return diff.values.flatten if opts.fetch(:raw, false)

  {
    'benchmark' => benchmark_diff.title_version.transform_values { |x| x.map!(&:to_s) },
    profile_key => diff.values.flatten,
  }
end