Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Remove the cluster finder
Browse files Browse the repository at this point in the history
We only use this in Diffux, not Diffux CI, so now that we've moved the
code over from diffux-core, we can simplify a little.

We may want to bring this back or something like it when we improve the
UI for reviewing diffs (#61), but for now I want to keep things simple.
  • Loading branch information
lencioni committed Jul 13, 2016
1 parent 575f6c7 commit 0ad0414
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 176 deletions.
47 changes: 0 additions & 47 deletions lib/diffux_ci/diff_cluster_finder.rb

This file was deleted.

10 changes: 4 additions & 6 deletions lib/diffux_ci/snapshot_comparer.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require 'oily_png'
require 'diff-lcs'
require_relative 'diff_cluster_finder'
require_relative 'snapshot_comparison_image/base'
require_relative 'snapshot_comparison_image/gutter'
require_relative 'snapshot_comparison_image/before'
Expand All @@ -22,7 +21,6 @@ def compare!
no_diff = {
diff_in_percent: 0,
diff_image: nil,
diff_clusters: []
}

# If these images are totally identical, we don't need to do any more
Expand All @@ -37,21 +35,21 @@ def compare!
return no_diff if array_before == array_after

sdiff = Diff::LCS.sdiff(array_before, array_after)
cluster_finder = DiffuxCI::DiffClusterFinder.new(sdiff.size)
number_of_different_rows = 0

sprite, all_comparisons = initialize_comparison_images(
[@png_after.width, @png_before.width].max, sdiff.size)

sdiff.each_with_index do |row, y|
# each row is a Diff::LCS::ContextChange instance
all_comparisons.each { |image| image.render_row(y, row) }
cluster_finder.row_is_different(y) unless row.unchanged?
number_of_different_rows += 1 unless row.unchanged?
end

percent_changed = cluster_finder.percent_of_rows_different
percent_changed = number_of_different_rows.to_f / sdiff.size * 100
{
diff_in_percent: percent_changed,
diff_image: (sprite if percent_changed > 0),
diff_clusters: cluster_finder.clusters,
}
end

Expand Down
107 changes: 0 additions & 107 deletions spec/diffux_ci/diff_cluster_finder_spec.rb

This file was deleted.

16 changes: 0 additions & 16 deletions spec/diffux_ci/snapshot_comparer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ def image(width: 2, height: 2, color: ChunkyPNG::Color::WHITE)
it 'reports no diff image' do
expect(subject[:diff_image]).to eq(nil)
end

it 'reports no cluster differences' do
expect(subject[:diff_clusters]).to be_empty
end
end

context 'with entirely different snapshots' do
Expand All @@ -38,10 +34,6 @@ def image(width: 2, height: 2, color: ChunkyPNG::Color::WHITE)
it 'reports a diff image' do
expect(subject[:diff_image]).to_not eq(nil)
end

it 'reports one cluster difference' do
expect(subject[:diff_clusters].count).to eq(1)
end
end

context 'when the after snapshot is half as tall as the before snapshot' do
Expand All @@ -50,10 +42,6 @@ def image(width: 2, height: 2, color: ChunkyPNG::Color::WHITE)
it 'reports a 50% difference' do
expect(subject[:diff_in_percent]).to eq(50.0)
end

it 'reports one cluster difference' do
expect(subject[:diff_clusters].count).to eq(1)
end
end

context 'when the after snapshot is twice as tall as the before snapshot' do
Expand All @@ -66,10 +54,6 @@ def image(width: 2, height: 2, color: ChunkyPNG::Color::WHITE)
it 'returns an image of the correct height' do
expect(subject[:diff_image].height).to eq(4)
end

it 'reports one cluster difference' do
expect(subject[:diff_clusters].count).to eq(1)
end
end

context 'when the after snapshot half as wide as the before snapshot' do
Expand Down

0 comments on commit 0ad0414

Please sign in to comment.