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 +4 -4
- data/CHANGELOG.md +5 -0
- data/jekyll_flexible_include_plugin.gemspec +1 -1
- data/lib/flexible_include/version.rb +1 -1
- data/lib/flexible_include.rb +26 -21
- data/lib/flexible_include_private_methods.rb +27 -10
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e55df13c1d72abd77ed8e3c3c38b9b90948421f88b42a069a067df044aae6fe7
|
4
|
+
data.tar.gz: 366f8ca463a84047d0e8ccfc6c4a861ee1516318ce6f5eb715d6feb4e0267947
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4dd897174369c3e5bf440d97eb95c0870b6566f10de91a9028c37ad8a5a3c7a9c62f675e2431d00a540511465dd4d849d2dd4a87952cff61a08d44b0886c57d
|
7
|
+
data.tar.gz: 22591d355535172b074c52f7522ebbbbda39a1c94d6e0107c1bd08b7fe85d051cc04cf3160092fb82e5e90cb020bfd225cb4963006b979c8ae9571598b7386c4
|
data/CHANGELOG.md
CHANGED
@@ -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.
|
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
|
data/lib/flexible_include.rb
CHANGED
@@ -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
|
-
|
34
|
-
@
|
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
|
-
|
47
|
+
html_message
|
43
48
|
rescue Errno::ENOENT => e
|
44
49
|
e.shorten_backtrace
|
45
|
-
|
46
|
-
@
|
50
|
+
@logger.error { "#{e.class.name}: #{e.message}" }
|
51
|
+
exit! 1 if @die_on_path_denied
|
47
52
|
|
48
|
-
|
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.
|
57
|
-
@
|
58
|
-
|
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
|
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
|
-
|
23
|
-
|
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
|
-
|
66
|
-
|
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
|
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
|
-
|
100
|
-
|
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.
|
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-
|
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.
|
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.
|
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.
|
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
|