Class: Greenroom::CLI::Judge::Patch

Inherits:
Object
  • Object
show all
Defined in:
lib/greenroom/cli/judge.rb

Instance Method Summary collapse

Constructor Details

#initialize(repository, experiment, verdict) ⇒ Patch

Returns a new instance of Patch.



195
196
197
198
199
# File 'lib/greenroom/cli/judge.rb', line 195

def initialize(repository, experiment, verdict)
  @repository = repository
  @experiment = experiment
  @verdict = verdict
end

Instance Method Details

#callObject



201
202
203
204
205
206
207
208
209
210
# File 'lib/greenroom/cli/judge.rb', line 201

def call
  matches = find_matches
  # Multiple locations make the patch target ambiguous. The judge stops
  # instead of changing a location that it cannot identify safely.
  return [nil, "The experiment has #{matches.length} locations."] unless matches.one?

  path, source, match = matches.first
  changed = (@verdict == "go") ? promote(source, match) : revert(source, match)
  build(path, source, changed)
end