jekyll_flexible_include 2.0.23 → 2.0.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2bbd3d775f087cefca7f18e68966dc58afb1b19099154b7e56dce5fba9b6f25
4
- data.tar.gz: '065912548161e1cce5d139566f370cabe68ad0521e87e7dd50f424e3a8e958f0'
3
+ metadata.gz: e55df13c1d72abd77ed8e3c3c38b9b90948421f88b42a069a067df044aae6fe7
4
+ data.tar.gz: 366f8ca463a84047d0e8ccfc6c4a861ee1516318ce6f5eb715d6feb4e0267947
5
5
  SHA512:
6
- metadata.gz: 6c965faec3f89eb9d005dc2ad7fea3847f77d716039b9f903f8f84ea20e49ba991f016664013826d0fb4e044203a7ae82338aca7b1b7a699a8d1e59ae18f4f62
7
- data.tar.gz: b4fb7d8c8b0afddef8f0c5d359b5bbe7077ae4418b38641e6f52dd537005a75c7a47a2eb371ea3de24cc4269295e423f8ff8a3b1c719e2f8b8c862f9ed4f8b20
6
+ metadata.gz: b4dd897174369c3e5bf440d97eb95c0870b6566f10de91a9028c37ad8a5a3c7a9c62f675e2431d00a540511465dd4d849d2dd4a87952cff61a08d44b0886c57d
7
+ data.tar.gz: 22591d355535172b074c52f7522ebbbbda39a1c94d6e0107c1bd08b7fe85d051cc04cf3160092fb82e5e90cb020bfd225cb4963006b979c8ae9571598b7386c4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.0.24 / 2024-00-20
4
+
5
+ * Made compatible with `jekyll_plugin_support` v1.0.2
6
+
7
+
3
8
  ## 2.0.23 / 2024-07-22
4
9
 
5
10
  * Made compatible with `jekyll_plugin_support` v1.0.0
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
36
36
  spec.version = JekyllFlexibleIncludePluginVersion::VERSION
37
37
 
38
38
  spec.add_dependency 'jekyll_from_to_until'
39
- spec.add_dependency 'jekyll_plugin_support', '>= 1.0.0'
39
+ spec.add_dependency 'jekyll_plugin_support', '>= 1.0.3'
40
40
  spec.add_dependency 'jekyll-sass-converter', '= 2.2.0'
41
41
  spec.add_dependency 'rugged'
42
42
  end
@@ -1,3 +1,3 @@
1
1
  module JekyllFlexibleIncludePluginVersion
2
- VERSION = '2.0.23'.freeze
2
+ VERSION = '2.0.24'.freeze
3
3
  end
@@ -12,6 +12,8 @@ class String
12
12
  end
13
13
 
14
14
  module FlexibleInclude
15
+ include FlexiblePrivateMethods
16
+
15
17
  FlexibleIncludeError = JekyllSupport.define_error
16
18
 
17
19
  PLUGIN_NAME = 'flexible_include'.freeze
@@ -23,6 +25,15 @@ module FlexibleInclude
23
25
  include FlexibleClassMethods
24
26
  end
25
27
 
28
+ def html_message(error)
29
+ <<~END_MSG
30
+ <div class='#{error.class.name.snakecase}'>
31
+ #{self.class} raised in #{calling_file} while processing line #{line_number} (after front matter) of #{path}
32
+ #{message}
33
+ </div>
34
+ END_MSG
35
+ end
36
+
26
37
  def render_impl
27
38
  setup
28
39
  @path = ::JekyllSupport::JekyllPluginHelper.expand_env @filename, @logger
@@ -30,32 +41,26 @@ module FlexibleInclude
30
41
  render_completion
31
42
  rescue Errno::EACCES => e
32
43
  e.shorten_backtrace
33
- msg = format_error_message e.message
34
- @logger.error msg
35
-
36
- if @die_on_file_error
37
- e2 = Errno::EACCES.new msg
38
- e2.set_backtrace e.backtrace
39
- raise e2
40
- end
44
+ @logger.error { "#{e.class.name}: #{e.message}" }
45
+ exit! 1 if @die_on_file_error
41
46
 
42
- "<div class='custom_error'>#{e.class} raised in #{self.class};\n#{msg}</div>"
47
+ html_message
43
48
  rescue Errno::ENOENT => e
44
49
  e.shorten_backtrace
45
- msg = format_error_message e.message
46
- @logger.error msg
50
+ @logger.error { "#{e.class.name}: #{e.message}" }
51
+ exit! 1 if @die_on_path_denied
47
52
 
48
- if @die_on_path_denied
49
- e2 = Errno::ENOENT.new msg
50
- e2.set_backtrace e.backtrace
51
- raise e2
52
- end
53
-
54
- "<div class='custom_error'>#{e.class} raised in #{self.class};\n#{msg}</div>"
53
+ html_message
55
54
  rescue FlexibleIncludeError => e
56
- e.shorten_backtrace
57
- @logger.error e.message
58
- raise e
55
+ @logger.error { e.logger_message }
56
+ exit! if @die_on_other_error
57
+
58
+ html_message
59
+ # rescue StandardError => e
60
+ # @logger.error { e.full_message }
61
+ # exit! 4
62
+
63
+ # html_message
59
64
  end
60
65
 
61
66
  private
@@ -1,12 +1,14 @@
1
1
  require 'pathname'
2
2
  require 'English'
3
+ require 'facets/string/camelcase'
4
+ require 'facets/string/snakecase'
3
5
  require 'jekyll_from_to_until'
4
6
 
5
7
  module FlexibleInclude
6
8
  module FlexiblePrivateMethods
7
9
  def denied(msg)
8
10
  msg_no_html = remove_html_tags(msg)
9
- @logger.error("#{@page['path']} - #{msg_no_html}")
11
+ @logger.error { "#{@page['path']} - #{msg_no_html}" }
10
12
  raise FlexibleIncludeError, "#{@page['path']} - #{msg_no_html}".red, [] if @die_on_path_denied
11
13
 
12
14
  "<p class='flexible_error'>#{msg}</p>"
@@ -19,9 +21,8 @@ module FlexibleInclude
19
21
  end
20
22
 
21
23
  def maybe_raise_error(msg, throw_error: true)
22
- fmsg = format_error_message msg
23
- @logger.error fmsg
24
- return "<span class='flexible_error'>#{fmsg}</span>" unless throw_error
24
+ @logger.error { msg }
25
+ return "<span class='flexible_error'>#{msg}</span>" unless throw_error
25
26
 
26
27
  raise FlexibleIncludeError, msg, []
27
28
  end
@@ -61,16 +62,28 @@ module FlexibleInclude
61
62
  end
62
63
 
63
64
  def render_completion
64
- unless @path.start_with? '!'
65
- maybe_raise_error("#{@path} does not exist", throw_error: @die_on_file_error) unless File.exist? @path
66
- maybe_raise_error("#{@path} is not readable", throw_error: @die_on_file_error) unless Pathname.new(@path).readable?
65
+ unless @path.start_with?('!')
66
+ unless File.exist?(@path) && Dir.exist?(File.dirname(@path))
67
+ return maybe_raise_error(
68
+ "#{@path} does not exist, referenced on line #{@line_number} (after front matter) of #{@page['path']}",
69
+ throw_error: @die_on_file_error
70
+ )
71
+ end
72
+
73
+ unless Pathname.new(@path).readable?
74
+ return maybe_raise_error(
75
+ "#{@path} is not readable, referenced on line #{@line_number} (after front matter) of #{@page['path']}",
76
+ throw_error: @die_on_file_error
77
+ )
78
+ end
67
79
 
68
80
  @contents = File.read @path
69
81
  unless @contents.instance_of? String
70
- maybe_raise_error("contents has type a #{@contents.class}, not a String",
82
+ maybe_raise_error("contents has type #{@contents.class}, not a String",
71
83
  throw_error: @die_on_file_error)
72
84
  end
73
85
  end
86
+
74
87
  @contents = FromToUntil.from(@contents, @from) if @from
75
88
  @contents = FromToUntil.to(@contents, @to) if @to
76
89
  @contents = FromToUntil.until(@contents, @until) if @until
@@ -96,8 +109,11 @@ module FlexibleInclude
96
109
  @logger.debug { "Executing #{cmd}" }
97
110
  %x[#{cmd}].chomp
98
111
  rescue FlexibleIncludeError => e
99
- raise e
100
- rescue StandardError => e
112
+ @logger.error { e.logger_message }
113
+ exit! 1 if @die_on_any_flexible_include_error
114
+
115
+ e.html_message
116
+ rescue StandardError => e # Assumes the wasa the result of running a command; this might not be a valid assumption. Awaiting a bug report.
101
117
  @do_not_escape = true
102
118
  e = e.exception "'#{e.message}' while executing '#{cmd}'"
103
119
  maybe_reraise_error(e, throw_error: @die_on_run_error)
@@ -113,6 +129,7 @@ module FlexibleInclude
113
129
  @die_on_other_error = config['die_on_other_error'] == true
114
130
  @die_on_path_denied = config['die_on_path_denied'] == true
115
131
  @die_on_run_error = config['die_on_run_error'] == true
132
+ @die_on_any_flexible_include_error = @die_on_file_error || @die_on_other_error || @die_on_path_denied || @die_on_run_error
116
133
  end
117
134
 
118
135
  parse_args
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_flexible_include
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.23
4
+ version: 2.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Slinn
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2024-07-26 00:00:00.000000000 Z
13
+ date: 2024-08-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: jekyll_from_to_until
@@ -32,14 +32,14 @@ dependencies:
32
32
  requirements:
33
33
  - - ">="
34
34
  - !ruby/object:Gem::Version
35
- version: 1.0.0
35
+ version: 1.0.3
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 1.0.0
42
+ version: 1.0.3
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: jekyll-sass-converter
45
45
  requirement: !ruby/object:Gem::Requirement
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  requirements: []
124
- rubygems_version: 3.5.16
124
+ rubygems_version: 3.5.17
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: Jekyll plugin supports various ways to include content into the generated