-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathusage_examples.rb
More file actions
36 lines (23 loc) · 930 Bytes
/
usage_examples.rb
File metadata and controls
36 lines (23 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require 'check_please'
reference = { "foo" => "wibble" }
candidate = { "bar" => "wibble" }
##### Printing diffs #####
puts CheckPlease.render_diff(reference, candidate)
# this should print the following to stdout:
_ = <<EOF
TYPE | PATH | REFERENCE | CANDIDATE
--------|------|-----------|----------
missing | /foo | wibble |
extra | /bar | | wibble
EOF
##### Doing your own thing with diffs #####
diffs = CheckPlease.diff(reference, candidate)
# `diffs` is a custom collection (type: CheckPlease::Diffs) that contains
# individual Diff objects for you to inspect as you see fit.
#
# If you come up with a useful way to present these, feel free to submit a PR
# with a new class in `lib/check_please/printers` !
# To print these in the console, you can just do:
puts diffs
# If for some reason you want to print the JSON version, it gets a little more verbose:
puts diffs.to_s(format: :json)