Skip to content

A Ruby port of Paul Fitzpatrick's coopyhx library for calculating tabular diffs

License

Notifications You must be signed in to change notification settings

theodi/coopy-ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A Ruby port of Paul Fitzpatrick's coopyhx library for calculating tabular diffs

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages