Class: Testprune::PatchWriter
- Inherits:
-
Object
- Object
- Testprune::PatchWriter
- Defined in:
- lib/testprune/patch_writer.rb
Overview
Emits a git-applyable patch that comments out the approved tests. Locates each test’s exact AST block (def or ‘it`/`describe` block) with Prism, comments those lines, and diffs against the original via `git diff –no-index`. Writes only the .patch file — never mutates the target source.
Instance Method Summary collapse
-
#initialize(config) ⇒ PatchWriter
constructor
A new instance of PatchWriter.
- #write(candidates) ⇒ Object
Constructor Details
#initialize(config) ⇒ PatchWriter
Returns a new instance of PatchWriter.
15 16 17 |
# File 'lib/testprune/patch_writer.rb', line 15 def initialize(config) @config = config end |
Instance Method Details
#write(candidates) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/testprune/patch_writer.rb', line 19 def write(candidates) FileUtils.mkdir_p(@config.output_dir) patch = candidates.group_by { |c| c.footprint.file } .map { |file, group| file_patch(file, group) } .compact.join File.write(@config.patch_file, patch) @config.patch_file end |