All Projects → pvande → Differ

pvande / Differ

A simple gem for generating string diffs

Programming Languages

ruby
36898 projects - #4 most used programming language

Labels

Projects that are alternatives of or similar to Differ

pg-diff
PostgreSQL schema and data comparing tool
Stars: ✭ 39 (-88.39%)
Mutual labels:  diff
Diffson
A scala diff/patch library for Json
Stars: ✭ 258 (-23.21%)
Mutual labels:  diff
Multidiff
Binary data diffing for multiple objects or streams of data
Stars: ✭ 282 (-16.07%)
Mutual labels:  diff
reducer-tester
Utilities for testing redux reducers
Stars: ✭ 19 (-94.35%)
Mutual labels:  diff
diff2HtmlCompare
Side-by-side diff shown in HTML
Stars: ✭ 103 (-69.35%)
Mutual labels:  diff
Diff
A library for diffing golang structures
Stars: ✭ 266 (-20.83%)
Mutual labels:  diff
tailor
Infrastructure as Code for OpenShift
Stars: ✭ 12 (-96.43%)
Mutual labels:  diff
Linediff.vim
A vim plugin to perform diffs on blocks of code
Stars: ✭ 331 (-1.49%)
Mutual labels:  diff
Ace Diff
A diff/merging wrapper for Ace Editor built on google-diff-match-patch
Stars: ✭ 257 (-23.51%)
Mutual labels:  diff
Editscript
A library designed to diff and patch Clojure data structures
Stars: ✭ 281 (-16.37%)
Mutual labels:  diff
difftastic
a syntax-aware diff 🟥🟩
Stars: ✭ 1,701 (+406.25%)
Mutual labels:  diff
cartunes
Simple comparison app for iRacing car setups.
Stars: ✭ 18 (-94.64%)
Mutual labels:  diff
Vue Code Diff
vue文件差异对比
Stars: ✭ 271 (-19.35%)
Mutual labels:  diff
treediff-rs
Extract differences between arbitrary datastructures
Stars: ✭ 52 (-84.52%)
Mutual labels:  diff
Dyff
/ˈdʏf/ - diff tool for YAML files, and sometimes JSON
Stars: ✭ 277 (-17.56%)
Mutual labels:  diff
ecto diff
Generates a data structure describing the difference between two ecto structs
Stars: ✭ 22 (-93.45%)
Mutual labels:  diff
Differencekit
💻 A fast and flexible O(n) difference algorithm framework for Swift collection.
Stars: ✭ 2,986 (+788.69%)
Mutual labels:  diff
Pgdiff
Compares the PostgreSQL schema between two databases and generates SQL statements that can be run manually against the second database to make their schemas match.
Stars: ✭ 333 (-0.89%)
Mutual labels:  diff
Diff2html Cli
Pretty diff to html javascript cli (diff2html-cli)
Stars: ✭ 287 (-14.58%)
Mutual labels:  diff
Pgquarrel
pgquarrel compares PostgreSQL database schemas (DDL)
Stars: ✭ 274 (-18.45%)
Mutual labels:  diff

= Differ

As streams of text swirled before the young man's eyes, his mind swam with

thoughts of many things. They would have to wait, however, as he focussed his full concentration on the shifting patterns ahead of him. A glint of light reflecting off a piece of buried code caught his eye and any hope he had was lost. For the very moment he glanced aside, the landscape became Different. The young man gave a small sigh and trudged onward in solemn resignation, fated to wander the desolate codebanks in perpetuity.

Differ is a flexible, pure-Ruby diff library, suitable for use in both command line scripts and web applications. The flexibility comes from the fact that diffs can be built at completely arbitrary levels of granularity (some common ones are built-in), and can be output in a variety of formats.

== Installation

sudo gem install differ

== Usage

There are a number of ways to use Differ, depending on your situation and needs.

@original = "Epic lolcat fail!" @current = "Epic wolfman fail!"

You can call the Differ module directly.

require 'differ'

There are a number of built-in diff methods to choose from...

@diff = Differ.diff_by_line(@current, @original) # => "{"Epic lolcat fail!" >> "Epic wolfman fail!"}"

@diff = Differ.diff_by_word(@current, @original) # => "Epic {"lolcat" >> "wolfman"} fail!"

@diff = Differ.diff_by_char(@current, @original) # => "Epic {+"wo"}l{-"olcat "}f{+"m"}a{+"n fa"}il!"

... or call #diff directly and supply your own boundary string!

@diff = Differ.diff(@current, @original) # implicitly by line! # => "{"Epic lolcat fail!" >> "Epic wolfman fail!"}"

@diff = Differ.diff(@current, @original, 'i') # => "Epi{"c lolcat fa" >> "c wolfman fa"}il"

If you would like something a little more inline...

require 'differ/string'

@diff = @current.diff(@original) # implicitly by line! # => "{"Epic lolcat fail!" >> "Epic wolfman fail!"}"

... or a lot more inline...

@diff = (@current - @original) # implicitly by line! # => "{"Epic lolcat fail!" >> "Epic wolfman fail!"}"

$; = ' ' @diff = (@current - @original) # => "Epic {"lolcat" >> "wolfman"} fail!"

... we've pretty much got you covered.

=== Output Formatting

Need a different output format? We've got a few of those too.

Differ.format = :ascii # <- Default Differ.format = :color Differ.format = :html

Differ.format = MyCustomFormatModule

Don't want to change the system-wide default for only a single diff output? Yeah, me either.

@diff = (@current - @original) @diff.format_as(:color)

== Copyright

Copyright (c) 2009 Pieter Vande Bruggen.

(The GIFT License, v1)

Permission is hereby granted to use this software and/or its source code for whatever purpose you should choose. Seriously, go nuts. Use it for your personal RSS feed reader, your wildly profitable social network, or your mission to Mars.

I don't care, it's yours. Change the name on it if you want -- in fact, if you start significantly changing what it does, I'd rather you did! Make it your own little work of art, complete with a stylish flowing signature in the corner. All I really did was give you the canvas. And my blessing.

Know always right from wrong, and let others see your good works.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].