Method: Fixtury::Configuration#changes

Defined in:
lib/fixtury/configuration.rb

#changesObject



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/fixtury/configuration.rb', line 74

def changes
  return "new: #{filepath}" if stored_data.nil?

  stored_checksums = (stored_data[:dependencies] || {})
  seen_filepaths = []
  calculate_checksums do |filepath, checksum|
    # Early return if the checksums don't match
    return "change: #{filepath}" unless stored_checksums[filepath] == checksum

    seen_filepaths << filepath
  end

  # If we have a new file or a file has been removed, we need to report a change.
  new_files = seen_filepaths - stored_checksums.keys
  return "added: #{new_files.inspect}" if new_files.any?

  removed_files = stored_checksums.keys - seen_filepaths
  return "removed: #{removed_files.inspect}" if removed_files.any?

  nil
end