Last active
January 3, 2016 02:09
-
-
Save pashields/8393867 to your computer and use it in GitHub Desktop.
A little json-y diff action in clojure.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns line-compare.core | |
(:require [cheshire.core :refer :all] | |
[clojure.set :refer :all] | |
[clojure.java.io :refer :all])) | |
(defn read-file | |
[file] | |
(with-open [rdr (reader file)] | |
(set (parsed-seq rdr)))) | |
(defn diff-strings | |
[filename lines] | |
(map #(str "Only in " filename ": " %) lines)) | |
(defn -main | |
[orig-file copy-file] | |
(let [orig (read-file orig-file) | |
copy (read-file copy-file) | |
orig-only (difference orig copy) | |
copy-only (difference copy orig) | |
diffs (concat | |
(diff-strings orig-file orig-only) | |
(diff-strings copy-file copy-only))] | |
(doseq [line diffs] (println line)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment