Skip to content

Instantly share code, notes, and snippets.

@cornelius
Created June 29, 2015 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cornelius/6d46ccb89410afe1731a to your computer and use it in GitHub Desktop.
Save cornelius/6d46ccb89410afe1731a to your computer and use it in GitHub Desktop.
output += Renderer.for(scope).render_comparison(comparison,
options
)
def render_comparison(comparison, options = {})
@options = options
@buffer = ""
@indent = 0
@stack = []
show_heading = if options[:show_all]
compaisonscope1 || scope2 || changed || common
else
scope1 || scope2 || changed
end
heading(display_name) if show_heading
render_comparison_only_in(comparison, :one)
render_comparison_only_in(comparison, :two)
render_comparison_changed(comparison)
render_comparison_common(comparison) if @options[:show_all]
@buffer
end
def render_comparison_only_in(comparison, which)
description = comparison.as_description(which)
return if !description[scope]
puts "Only in '#{description.name}':"
indent { compare_content_only_in(description) }
@buffer += "\n" unless @buffer.empty? || @buffer.end_with?("\n\n")
end
comparison = Comparison.compare(description1, description2, scope)
comparison.name1
comparison.name2
comparison.only_in1 [ package1, package2 ]
comparison.only_in1 { files: [ file1, file2 ] }
comparison.only_in2 [ package1, package2 ]
comparison.changed [ [ package1, package2 ], [ package1, package2 ] ]
comparison.common [ package1, package2 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment