Skip to content

Commit 7abdc1d

Browse files
committed
Add json-diff executable, gem v0.4.0
1 parent 5c4c2a0 commit 7abdc1d

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

bin/json-diff

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env ruby
2+
require "json"
3+
require "json-diff"
4+
5+
HELP = <<-HELP
6+
Produce a JSON description of the difference between two JSON files.
7+
Usage:
8+
json-diff FILE1 FILE2
9+
HELP
10+
11+
if ARGV.first == "-h"
12+
puts HELP
13+
exit(0)
14+
end
15+
16+
before_filename = ARGV.shift
17+
after_filename = ARGV.shift
18+
19+
if before_filename == nil || after_filename == nil
20+
puts "A file is missing to compute the difference between two files"
21+
exit(1)
22+
end
23+
24+
before_file = IO.read(before_filename)
25+
after_file = IO.read(after_filename)
26+
before = JSON.parse(before_file)
27+
after = JSON.parse(after_file)
28+
puts JSON.pretty_generate(JsonDiff.diff(before, after))

json-diff.gemspec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ Gem::Specification.new do |s|
77
s.version = JsonDiff::VERSION
88
s.platform = Gem::Platform::RUBY
99
s.authors = ['Thaddée Tyl']
10-
s.email = ['ttyl@captaintrain.com']
10+
s.email = ['thaddee.tyl@gmail.com']
1111
s.homepage = 'http://github.com/espadrine/json-diff'
1212
s.summary = %q{Compute the difference between two JSON-serializable Ruby objects.}
1313
s.description = %q{Take two Ruby objects that can be serialized to JSON. Output an array of operations (additions, deletions, moves) that would convert the first one to the second one.}
1414
s.files = `git ls-files`.split("\n")
15+
s.bindir = "bin"
16+
s.executables = ["json-diff"]
1517
end

lib/json-diff/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module JsonDiff
2-
VERSION = '0.3.2'
2+
VERSION = '0.4.0'
33
end

0 commit comments

Comments
 (0)