No commit activity in last 3 years
No release in over 3 years
Generates HTML view of given unified diff
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

diff_to_html¶ ↑

This is a Ruby class for converting unified diff, like the one you get with ‘svn diff’, to HTML like in changeset viewer of a tool like Trac, GitHub or Codenotifier, e.g. codenotifier.com/projects/49/commits/47#F0.

It’s based on code from gurge.com/blog/2006/10/03/subversion-diff-viewer-cgi-in-ruby (thanks Adam Doppelt!), adopted lightly to support multifile diffs and to have more familiar output. It definitely have things to improve, so contribution/patches are very welcome.

  • install the gem:

    gem install artemv-diff_to_html --source=http://gems.github.com
  • go to gem’s ‘examples’ dir (it’s …/ruby/lib/ruby/gems/1.8/gems/artemv-diff_to_html-x.x.x/examples/) and run ‘ruby test.rb >out.html’ - this will get diff from sample ‘svn diff’ and generate out.html. Resulting html is linked to diff.css in ‘examples’ directory - you’ll need to copy it to your project’s dir to use it.

  • To use in Rails project:

    require 'diff_to_html'
    diff = `cat #{File.join(File.dirname(__FILE__), 'diff.svn')}`
    converter = SvnDiffToHtml.new #there's also GitDiffToHtml
    puts converter.composite_to_html(diff)
    
  • to use in any Ruby program:

    require 'rubygems'
    require 'diff_to_html'
    ...

License¶ ↑

diff_to_html is released under the MIT license.

Authors and credits¶ ↑

Authors

Artem Vasiliev

Original code

Adam Doppelt, gurge.com/blog/2006/10/03/subversion-diff-viewer-cgi-in-ruby