Class: Shanty::ChangedMutator

Inherits:
Mutator
  • Object
show all
Defined in:
lib/shanty/mutators/changed.rb

Overview

Mutates the graph to mark projects which have changed since the last time they were built.

Constant Summary collapse

UNIT_SEPARATOR =
"\u001F"

Instance Attribute Summary

Attributes inherited from Mutator

#env, #graph

Instance Method Summary collapse

Methods inherited from Mutator

#apply_mutations, inherited, #initialize

Constructor Details

This class inherits a constructor from Shanty::Mutator

Instance Method Details

#mutateObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/shanty/mutators/changed.rb', line 11

def mutate
  FileUtils.mkdir(shanty_dir) unless File.directory?(shanty_dir)

  self.cached_index = all_index_files.each_with_object({}) do |path, acc|
    # Check if the file has changed between
    next if unchanged_in_index?(path)
    # Otherwise, it was modified, deleted or added, so update the index if the file still exists.
    acc[path] = current_index[path] if current_index.include?(path)
    mark_project_as_changed(path)
  end
end