Project

coopy

0.0
No commit activity in last 3 years
No release in over 3 years
Ruby port of coopyhx, for calculating tabular diffs
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0
>= 0
>= 0
 Project Readme

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