gryphon_nest 3.0.0 → 3.1.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/lib/gryphon_nest/errors.rb +2 -0
- data/lib/gryphon_nest/processors/mustache_processor.rb +22 -10
- data/lib/gryphon_nest/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: 9a15200889f6f72f775094aed126ad46ef5dae7546395b4ebef80f830e389505
|
4
|
+
data.tar.gz: c582fb185b2663a96f959823bf769a079aeca856b8303fe83f99088078339c78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ce6e28ae987f0bf357f3035d34734e09589cf6060b9d5e9c60b327d8ed84fb9616e00994fc70e93cfc7b95a29a82cc42b1ac85704e71cf32eccbe7dcad586ef
|
7
|
+
data.tar.gz: d069c1bb1f27bcc1dca9ca4817e3d8fa06db8aeb5d0fc7aa28a1d877940ed0ece4ae720e42d2821eedf382ee14a4a2bce03c3454e8d642a310869cfdd82b034a
|
data/lib/gryphon_nest/errors.rb
CHANGED
@@ -15,6 +15,7 @@ module GryphonNest
|
|
15
15
|
# @param file [Pathname]
|
16
16
|
# @return [Pathname]
|
17
17
|
# @raise [Errors::YamlError]
|
18
|
+
# @raise [Errors::ParseError]
|
18
19
|
def process(file)
|
19
20
|
dest = dest_name(file)
|
20
21
|
msg = File.exist?(dest) ? 'Recreating' : 'Creating'
|
@@ -23,15 +24,7 @@ module GryphonNest
|
|
23
24
|
@layout ||= read_layout_file
|
24
25
|
|
25
26
|
context = read_context(file)
|
26
|
-
|
27
|
-
if @layout.empty?
|
28
|
-
content = @renderer.render_file(file, context)
|
29
|
-
else
|
30
|
-
context[:yield] = file.basename(TEMPLATE_EXT)
|
31
|
-
content = @renderer.render(@layout, context)
|
32
|
-
end
|
33
|
-
|
34
|
-
content = HtmlBeautifier.beautify(content)
|
27
|
+
content = build_output(file, context)
|
35
28
|
write_file(dest, content)
|
36
29
|
dest
|
37
30
|
end
|
@@ -60,7 +53,26 @@ module GryphonNest
|
|
60
53
|
rescue IOError, Errno::ENOENT
|
61
54
|
{}
|
62
55
|
rescue Psych::SyntaxError => e
|
63
|
-
raise Errors::YamlError, "Encountered error while reading context file. #{e.message}"
|
56
|
+
raise Errors::YamlError, "Encountered error while reading context file. Reason: #{e.message}"
|
57
|
+
end
|
58
|
+
|
59
|
+
# @param file [Pathname]
|
60
|
+
# @param context [Hash]
|
61
|
+
# @return [String]
|
62
|
+
# @raise [Errors::ParseError]
|
63
|
+
def build_output(file, context)
|
64
|
+
if @layout.empty?
|
65
|
+
content = @renderer.render_file(file, context)
|
66
|
+
else
|
67
|
+
context[:yield] = file.basename(TEMPLATE_EXT)
|
68
|
+
content = @renderer.render(@layout, context)
|
69
|
+
end
|
70
|
+
|
71
|
+
HtmlBeautifier.beautify(content, stop_on_errors: true)
|
72
|
+
rescue Mustache::Parser::SyntaxError => e
|
73
|
+
raise Errors::ParseError, "Failed to process mustache template #{file}.\nReason: #{e}"
|
74
|
+
rescue RuntimeError => e
|
75
|
+
raise Errors::ParseError, "Failed to beautify template output #{file}. Reason: #{e.message}"
|
64
76
|
end
|
65
77
|
|
66
78
|
# @param path [Pathname]
|
data/lib/gryphon_nest/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gryphon_nest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Birmingham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: htmlbeautifier
|