Class: DamageControl::Visitor::DiffPersister
- Inherits:
-
Object
- Object
- DamageControl::Visitor::DiffPersister
- Defined in:
- lib/damagecontrol/visitor/diff_persister.rb
Overview
Visitor that persists unified diffs to disk.
Instance Method Summary collapse
-
#initialize(scm, project_name) ⇒ DiffPersister
constructor
Creates a new Differ that will persist diffs to file.
- #visit_change(change) ⇒ Object
- #visit_changeset(changeset) ⇒ Object
- #visit_changesets(changesets) ⇒ Object
Constructor Details
#initialize(scm, project_name) ⇒ DiffPersister
Creates a new Differ that will persist diffs to file.
13 14 15 |
# File 'lib/damagecontrol/visitor/diff_persister.rb', line 13 def initialize(scm, project_name) @scm, @project_name = scm, project_name end |
Instance Method Details
#visit_change(change) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/damagecontrol/visitor/diff_persister.rb', line 25 def visit_change(change) diff_file = Directories.diff_file(@project_name, @changeset, change) Log.info " Writing diff for #{change.path} -> #{diff_file}" checkout_dir = Directories.checkout_dir(@project_name) @scm.diff(checkout_dir, change) do |diff_io| FileUtils.mkdir_p(File.dirname(diff_file)) File.open(diff_file, "w") do |io| diff_io.each_line do |line| io.write(line) end end end end |
#visit_changeset(changeset) ⇒ Object
20 21 22 23 |
# File 'lib/damagecontrol/visitor/diff_persister.rb', line 20 def visit_changeset(changeset) @changeset = changeset Log.info "Writing diffs for #{@project_name} changeset #{changeset.identifier}" end |
#visit_changesets(changesets) ⇒ Object
17 18 |
# File 'lib/damagecontrol/visitor/diff_persister.rb', line 17 def visit_changesets(changesets) end |