jekyll-tidy-json 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.adoc +7 -0
- data/jekyll-tidy-json.gemspec +1 -1
- data/lib/jekyll/tidy_json.rb +23 -4
- data/lib/jekyll/tidy_json/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: 743cff63a7b0ed59e0696cd02bdb1b950be588188252a791cee1819800e78372
|
4
|
+
data.tar.gz: b9605dc665eae31688f7f42c5a6d898ab0d289b52b7ee954504d3956747fda41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd49755b9430689d3988c993061874b3251137a5983ac2c5a2bf868f2f32e3c646edd08a85784940e69516fefb859c45ca1cc1b802bcc6812f26cbd8134e03a9
|
7
|
+
data.tar.gz: 5bf48c6c393eca5a9507391f2c8d156263ef8a0776dde06cd86c0acf91b877c14820dfbd112a399a032f4844096c7c0d11210345c9572292d5f8a3bd265b062f
|
data/README.adoc
CHANGED
@@ -51,6 +51,13 @@ Available configuration options:
|
|
51
51
|
| Description
|
52
52
|
| Default setting
|
53
53
|
|
54
|
+
| `continue_on_error`
|
55
|
+
| If set to `false`, any malformed JSON encounter will raise error, preventing
|
56
|
+
site from being built. If set to `true`, all malformed files are exempted from
|
57
|
+
being tidied up with a meaningful warning being printed, but site generation
|
58
|
+
continues.
|
59
|
+
| `false`
|
60
|
+
|
54
61
|
| `enabled`
|
55
62
|
| Can be used to disable the plugin entirely by setting it to `false`.
|
56
63
|
| `true`
|
data/jekyll-tidy-json.gemspec
CHANGED
data/lib/jekyll/tidy_json.rb
CHANGED
@@ -15,12 +15,19 @@ module Jekyll
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def tidy_page_or_document(page_or_document)
|
18
|
+
if should_tidy?(page_or_document.relative_path)
|
19
|
+
tidy_page_or_document!(page_or_document)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def tidy_page_or_document!(page_or_document)
|
18
24
|
path = page_or_document.relative_path
|
19
25
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
26
|
+
Jekyll.logger.debug("Tidy up JSON:", path)
|
27
|
+
page_or_document.output = tidy_string(page_or_document.output)
|
28
|
+
rescue JSON::ParserError
|
29
|
+
print_parse_error(!continue_on_error?, $!, path)
|
30
|
+
raise unless continue_on_error?
|
24
31
|
end
|
25
32
|
|
26
33
|
def tidy_string(string)
|
@@ -30,6 +37,10 @@ module Jekyll
|
|
30
37
|
JSON.public_send meth, json
|
31
38
|
end
|
32
39
|
|
40
|
+
def continue_on_error?
|
41
|
+
!!@continue_on_error
|
42
|
+
end
|
43
|
+
|
33
44
|
def pretty?
|
34
45
|
!!@pretty
|
35
46
|
end
|
@@ -41,9 +52,17 @@ module Jekyll
|
|
41
52
|
private
|
42
53
|
|
43
54
|
def parse_plugin_config(pc)
|
55
|
+
@continue_on_error = pc.fetch("continue_on_error", false)
|
44
56
|
@enabled = pc.fetch("enabled", true)
|
45
57
|
@pretty = pc.fetch("pretty", false)
|
46
58
|
end
|
59
|
+
|
60
|
+
def print_parse_error(is_fatal, exception, file_path)
|
61
|
+
logger = Jekyll.logger.public_method(is_fatal ? :error : :warn)
|
62
|
+
|
63
|
+
logger.("Malformed JSON at path:", file_path)
|
64
|
+
logger.(exception)
|
65
|
+
end
|
47
66
|
end
|
48
67
|
end
|
49
68
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-tidy-json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|