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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '059e5147460d46712b2b7d7f700e9013aec2b515c440d2e8480dd91429a49055'
4
- data.tar.gz: 55887001c613917022871f80eb385ea21ec5fad38257d32a87b61c1ee3f2f1fb
3
+ metadata.gz: 9a15200889f6f72f775094aed126ad46ef5dae7546395b4ebef80f830e389505
4
+ data.tar.gz: c582fb185b2663a96f959823bf769a079aeca856b8303fe83f99088078339c78
5
5
  SHA512:
6
- metadata.gz: f916fed436eb1fba621d6921fbc2075dad54079b148b321accb977c5b8550efc8ed495212cec48519fa8ccfa4383f7892b594f2b7941a88542d7d84545178709
7
- data.tar.gz: d22e12353543670bd136a803c9b84efa2dc95a88f64897ebe5d1addc638df9e5ad6ef06ea54edaed515a8d7bea282bed1f77bbea21a70ea7a23fe32323811616
6
+ metadata.gz: 1ce6e28ae987f0bf357f3035d34734e09589cf6060b9d5e9c60b327d8ed84fb9616e00994fc70e93cfc7b95a29a82cc42b1ac85704e71cf32eccbe7dcad586ef
7
+ data.tar.gz: d069c1bb1f27bcc1dca9ca4817e3d8fa06db8aeb5d0fc7aa28a1d877940ed0ece4ae720e42d2821eedf382ee14a4a2bce03c3454e8d642a310869cfdd82b034a
@@ -4,6 +4,8 @@ module GryphonNest
4
4
  module Errors
5
5
  class NotFoundError < StandardError; end
6
6
 
7
+ class ParseError < StandardError; end
8
+
7
9
  class YamlError < StandardError; end
8
10
  end
9
11
  end
@@ -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]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GryphonNest
4
- VERSION = '3.0.0'
4
+ VERSION = '3.1.0'
5
5
  end
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.0.0
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: 2024-10-30 00:00:00.000000000 Z
11
+ date: 2025-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlbeautifier