Class: Mutiny::Mutants::Storage::MutantFileContents

Inherits:
Object
  • Object
show all
Defined in:
lib/mutiny/mutants/storage/mutant_file_contents.rb

Instance Method Summary collapse

Instance Method Details

#deserialise(contents) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/mutiny/mutants/storage/mutant_file_contents.rb', line 14

def deserialise(contents)
  {
    subject: { name: extract_contents_of_comment(contents.lines[0]) },
    mutation_name: extract_contents_of_comment(contents.lines[1]),
    position: {
      old: convert_to_range(extract_contents_of_comment(contents.lines[2])),
      new: convert_to_range(extract_contents_of_comment(contents.lines[3]))
    },
    code: contents.lines.drop(4).join
  }
end

#serialise(mutant) ⇒ Object

rubocop:disable Metrics/AbcSize



6
7
8
9
10
11
12
# File 'lib/mutiny/mutants/storage/mutant_file_contents.rb', line 6

def serialise(mutant)
  "# " + mutant.subject.name + "\n" \
  "# " + mutant.mutation_name + "\n" \
  "# " + mutant.location.old_position.to_s + "\n" \
  "# " + mutant.location.new_position.to_s + "\n" +
    mutant.code
end