A Ruby port of Paul Fitzpatrick's coopyhx library for calculating tabular diffs
Ruby
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib Fix some more porting errors in alignment code Nov 12, 2014
spec fix column linking Mar 20, 2014
.gitignore ruby Array class doesn't have a splice method. replaced with delete_at Apr 11, 2014
.rspec added rspec framework Nov 12, 2013
.travis.yml Add travis config Feb 21, 2014
CHANGELOG.md
Gemfile Ruby 2.1 (in dev) Feb 21, 2014
LICENSE.md gem structure Nov 12, 2013
README.md fix coopyhx/daff link Jun 10, 2014
Rakefile added rspec framework Nov 12, 2013
coopy.gemspec don't use rspec 3 yet Jun 23, 2014

README.md

Build Status Dependency Status Coverage Status Code Climate Gem Version License Badges

Coopy for Ruby

A pure Ruby port of Paul Fitzpatrick's daff (formerly "coopyhx") library for tabular diffs.

Not all the daff code is ported or tested. There will be bugs. However, basic two-file CSV diff appears to be working. See 'Usage' section below for details.

Installation

Add this line to your application's Gemfile:

gem 'coopy'

And then execute:

$ bundle

Or install it yourself as:

$ gem install coopy

Usage

You can diff Ruby's built-in CSV objects, like so:

old_table = Coopy::CsvTable.new(old_csv_object)
new_table = Coopy::CsvTable.new(new_csv_object)

alignment = Coopy.compare_tables(old_table,new_table).align
flags = Coopy::CompareFlags.new
highlighter = Coopy::TableDiff.new(alignment,flags)

diff_table = Coopy::SimpleTable.new(0,0)
highlighter.hilite diff_table

You can inspect diff_table to see the changes.

You can also generate an HTML view of this diff like this:

diff2html = Coopy::DiffRender.new
diff2html.render diff_table
html = diff2html.html

There is plenty more in the original library, but this is all that's known working at the moment.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request