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



12
13
14
15
16
17
18
19
# File 'lib/mutiny/mutants/storage/mutant_file_contents.rb', line 12

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

#serialise(mutant) ⇒ Object



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

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