class Mutiny::Mutants::Storage::MutantFileContents
Public Instance Methods
deserialise(contents)
click to toggle source
# 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)
click to toggle source
rubocop:disable Metrics/AbcSize
# 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
Private Instance Methods
convert_to_range(string)
click to toggle source
# File lib/mutiny/mutants/storage/mutant_file_contents.rb, line 33 def convert_to_range(string) Range.new(*string.split("..").map(&:to_i)) end
extract_contents_of_comment(line)
click to toggle source
rubocop:enable Metrics/AbcSize
# File lib/mutiny/mutants/storage/mutant_file_contents.rb, line 29 def extract_contents_of_comment(line) line[2..-1].strip end