Git Product home page Git Product logo

diff_to_html.rb's Introduction

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

diff_to_html.rb's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.