Skip to content

Commit 46bff1c

Browse files
committed
Document the json-diff executable
Also, improve the logical layout of the index maps classes.
1 parent 9e8ed01 commit 46bff1c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,19 @@ Outputs [RFC6902][]. Look at [hana][] for a JSON patch algorithm that can use th
2121

2222
- `include_was`: include a `was` field in remove and replace operations, to show the old value. Allows computing reverse operations without the source JSON.
2323
- `moves`\*: include move operations. Set it to false to remove clutter.
24-
- `additions`\*: include add operations. Se it to false to remove clutter.
24+
- `additions`\*: include add operations. Set it to false to remove clutter.
2525
- `original_indices`\*: array indices are those from the source array (for `from` fields, or `path` fields on remove operations) or the target array (for other `path` fields). It eases manual checking of differences.
2626
- `similarity`: procedure taking (before, after) objects. Returns a probability between 0 and 1 of how likely `after` is a modification of `before`, or nil if you wish to fall back to the default computation.
2727

2828
\* Changing this option prevents the use of the output for JSON patching.
2929

30+
You can also install its associated program to use this on the command line:
31+
32+
```bash
33+
gem install json-diff # On Linux, you may need to use sudo
34+
json-diff before.json after.json
35+
```
36+
3037
# Heart
3138

3239
- Recursive similarity computation between any two Ruby values.

lib/json-diff/index-map.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ class IndexMap
2525
def initialize(pivot)
2626
@pivot = pivot
2727
end
28+
end
2829

30+
class AdditionIndexMap < IndexMap
2931
def map(index)
3032
if index >= @pivot
3133
index + 1
@@ -35,9 +37,6 @@ def map(index)
3537
end
3638
end
3739

38-
class AdditionIndexMap < IndexMap
39-
end
40-
4140
class RemovalIndexMap < IndexMap
4241
def map(index)
4342
if index >= @pivot

0 commit comments

Comments
 (0)