check_please 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -1
- data/lib/check_please.rb +11 -7
- data/lib/check_please/printers/json.rb +0 -2
- data/lib/check_please/printers/table_print.rb +6 -1
- data/lib/check_please/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f794a7a96790b642f2afc6f66bebb761a788c2b2a95025662e4ec8e654e612ef
|
4
|
+
data.tar.gz: 98a088234aa843abf60668d8ee6722de318f60d19e29352f8332338d28268e7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 376fe8e75cf2c952d0cbaf42c32ca659c4f96488919eda781fc29cb50b259ddd3a91d60aa4bbae48022ccce96ab04148e60938079920a7657b7e288061b707dc
|
7
|
+
data.tar.gz: dd4c24bd01c391fa70e626bd9753efd3601a4a9a92dfe92956ce5742c0d8771e53a32a3ef05cbd1e45ac75eff30342230ba2b3dd238274fbe00bea2291f7d148
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/check_please.rb
CHANGED
@@ -7,6 +7,9 @@ require_relative "check_please/diffs"
|
|
7
7
|
require_relative "check_please/printers"
|
8
8
|
require_relative "check_please/cli"
|
9
9
|
|
10
|
+
require 'yaml'
|
11
|
+
require 'json'
|
12
|
+
|
10
13
|
module CheckPlease
|
11
14
|
ELEVATOR_PITCH = "Tool for parsing and diffing two JSON documents."
|
12
15
|
|
@@ -25,16 +28,17 @@ module CheckPlease
|
|
25
28
|
private
|
26
29
|
|
27
30
|
# Maybe you gave us JSON strings, maybe you gave us Ruby objects.
|
28
|
-
# We just don't know!
|
29
|
-
|
31
|
+
# Heck, maybe you even gave us some YAML! We just don't know!
|
32
|
+
# That's what makes it so exciting!
|
33
|
+
def maybe_parse(document)
|
30
34
|
|
31
|
-
case
|
32
|
-
when String ;
|
33
|
-
else ;
|
35
|
+
case document
|
36
|
+
when String ; return YAML.load(document) # don't worry, if this raises we'll assume you've already parsed it
|
37
|
+
else ; return document
|
34
38
|
end
|
35
39
|
|
36
|
-
rescue JSON::ParserError
|
37
|
-
return
|
40
|
+
rescue JSON::ParserError, Psych::SyntaxError
|
41
|
+
return document
|
38
42
|
end
|
39
43
|
end
|
40
44
|
end
|
@@ -14,11 +14,12 @@ module Printers
|
|
14
14
|
def to_s
|
15
15
|
return "" if diffs.empty?
|
16
16
|
|
17
|
-
build_string do |io|
|
17
|
+
out = build_string do |io|
|
18
18
|
switch_tableprint_io(io) do
|
19
19
|
tp diffs.data, *TP_OPTS
|
20
20
|
end
|
21
21
|
end
|
22
|
+
strip_trailing_whitespace(out)
|
22
23
|
end
|
23
24
|
|
24
25
|
private
|
@@ -31,6 +32,10 @@ module Printers
|
|
31
32
|
ensure
|
32
33
|
config.io = @old_io
|
33
34
|
end
|
35
|
+
|
36
|
+
def strip_trailing_whitespace(s)
|
37
|
+
s.lines.map(&:rstrip).join("\n")
|
38
|
+
end
|
34
39
|
end
|
35
40
|
|
36
41
|
end
|
data/lib/check_please/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: check_please
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Livingston-Gray
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: table_print
|