jekyll 4.2.1 → 4.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +474 -350
- data/LICENSE +21 -21
- data/README.markdown +83 -86
- data/exe/jekyll +57 -57
- data/lib/blank_template/_config.yml +3 -3
- data/lib/blank_template/_layouts/default.html +12 -12
- data/lib/blank_template/_sass/{main.scss → base.scss} +9 -9
- data/lib/blank_template/assets/css/main.scss +4 -4
- data/lib/blank_template/index.md +8 -8
- data/lib/jekyll/cache.rb +186 -190
- data/lib/jekyll/cleaner.rb +111 -111
- data/lib/jekyll/collection.rb +310 -309
- data/lib/jekyll/command.rb +105 -105
- data/lib/jekyll/commands/build.rb +82 -93
- data/lib/jekyll/commands/clean.rb +44 -45
- data/lib/jekyll/commands/doctor.rb +177 -177
- data/lib/jekyll/commands/help.rb +34 -34
- data/lib/jekyll/commands/new.rb +168 -169
- data/lib/jekyll/commands/new_theme.rb +39 -40
- data/lib/jekyll/commands/serve/live_reload_reactor.rb +119 -122
- data/lib/jekyll/commands/serve/livereload_assets/livereload.js +1183 -1183
- data/lib/jekyll/commands/serve/mime_types_charset.json +71 -0
- data/lib/jekyll/commands/serve/servlet.rb +206 -202
- data/lib/jekyll/commands/serve/websockets.rb +81 -81
- data/lib/jekyll/commands/serve.rb +367 -362
- data/lib/jekyll/configuration.rb +313 -313
- data/lib/jekyll/converter.rb +54 -54
- data/lib/jekyll/converters/identity.rb +41 -41
- data/lib/jekyll/converters/markdown/kramdown_parser.rb +197 -199
- data/lib/jekyll/converters/markdown.rb +113 -113
- data/lib/jekyll/converters/smartypants.rb +70 -70
- data/lib/jekyll/convertible.rb +257 -257
- data/lib/jekyll/deprecator.rb +50 -50
- data/lib/jekyll/document.rb +543 -544
- data/lib/jekyll/drops/collection_drop.rb +20 -20
- data/lib/jekyll/drops/document_drop.rb +74 -70
- data/lib/jekyll/drops/drop.rb +293 -293
- data/lib/jekyll/drops/excerpt_drop.rb +23 -19
- data/lib/jekyll/drops/jekyll_drop.rb +32 -32
- data/lib/jekyll/drops/site_drop.rb +66 -66
- data/lib/jekyll/drops/static_file_drop.rb +14 -14
- data/lib/jekyll/drops/theme_drop.rb +36 -0
- data/lib/jekyll/drops/unified_payload_drop.rb +30 -26
- data/lib/jekyll/drops/url_drop.rb +140 -140
- data/lib/jekyll/entry_filter.rb +117 -121
- data/lib/jekyll/errors.rb +20 -20
- data/lib/jekyll/excerpt.rb +200 -201
- data/lib/jekyll/external.rb +75 -79
- data/lib/jekyll/filters/date_filters.rb +110 -110
- data/lib/jekyll/filters/grouping_filters.rb +64 -64
- data/lib/jekyll/filters/url_filters.rb +98 -98
- data/lib/jekyll/filters.rb +532 -535
- data/lib/jekyll/frontmatter_defaults.rb +238 -240
- data/lib/jekyll/generator.rb +5 -5
- data/lib/jekyll/hooks.rb +107 -107
- data/lib/jekyll/inclusion.rb +32 -32
- data/lib/jekyll/layout.rb +55 -67
- data/lib/jekyll/liquid_extensions.rb +22 -22
- data/lib/jekyll/liquid_renderer/file.rb +77 -77
- data/lib/jekyll/liquid_renderer/table.rb +45 -55
- data/lib/jekyll/liquid_renderer.rb +80 -80
- data/lib/jekyll/log_adapter.rb +151 -151
- data/lib/jekyll/mime.types +939 -866
- data/lib/jekyll/page.rb +215 -217
- data/lib/jekyll/page_excerpt.rb +25 -25
- data/lib/jekyll/page_without_a_file.rb +14 -14
- data/lib/jekyll/path_manager.rb +74 -74
- data/lib/jekyll/plugin.rb +92 -92
- data/lib/jekyll/plugin_manager.rb +123 -115
- data/lib/jekyll/profiler.rb +51 -58
- data/lib/jekyll/publisher.rb +23 -23
- data/lib/jekyll/reader.rb +209 -192
- data/lib/jekyll/readers/collection_reader.rb +23 -23
- data/lib/jekyll/readers/data_reader.rb +113 -79
- data/lib/jekyll/readers/layout_reader.rb +62 -62
- data/lib/jekyll/readers/page_reader.rb +25 -25
- data/lib/jekyll/readers/post_reader.rb +85 -85
- data/lib/jekyll/readers/static_file_reader.rb +25 -25
- data/lib/jekyll/readers/theme_assets_reader.rb +52 -52
- data/lib/jekyll/regenerator.rb +195 -195
- data/lib/jekyll/related_posts.rb +52 -52
- data/lib/jekyll/renderer.rb +263 -265
- data/lib/jekyll/site.rb +576 -551
- data/lib/jekyll/static_file.rb +205 -208
- data/lib/jekyll/stevenson.rb +60 -60
- data/lib/jekyll/tags/highlight.rb +114 -110
- data/lib/jekyll/tags/include.rb +275 -275
- data/lib/jekyll/tags/link.rb +42 -42
- data/lib/jekyll/tags/post_url.rb +106 -106
- data/lib/jekyll/theme.rb +90 -86
- data/lib/jekyll/theme_builder.rb +121 -121
- data/lib/jekyll/url.rb +167 -167
- data/lib/jekyll/utils/ansi.rb +57 -57
- data/lib/jekyll/utils/exec.rb +26 -26
- data/lib/jekyll/utils/internet.rb +37 -37
- data/lib/jekyll/utils/platforms.rb +67 -67
- data/lib/jekyll/utils/thread_event.rb +31 -31
- data/lib/jekyll/utils/win_tz.rb +46 -75
- data/lib/jekyll/utils.rb +371 -367
- data/lib/jekyll/version.rb +5 -5
- data/lib/jekyll.rb +195 -195
- data/lib/site_template/.gitignore +5 -5
- data/lib/site_template/404.html +25 -25
- data/lib/site_template/_config.yml +55 -55
- data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +29 -29
- data/lib/site_template/about.markdown +18 -18
- data/lib/site_template/index.markdown +6 -6
- data/lib/theme_template/CODE_OF_CONDUCT.md.erb +74 -74
- data/lib/theme_template/Gemfile +4 -4
- data/lib/theme_template/LICENSE.txt.erb +21 -21
- data/lib/theme_template/README.md.erb +50 -52
- data/lib/theme_template/_layouts/default.html +1 -1
- data/lib/theme_template/_layouts/page.html +5 -5
- data/lib/theme_template/_layouts/post.html +5 -5
- data/lib/theme_template/example/_config.yml.erb +1 -1
- data/lib/theme_template/example/_post.md +12 -12
- data/lib/theme_template/example/index.html +14 -14
- data/lib/theme_template/example/style.scss +7 -7
- data/lib/theme_template/gitignore.erb +6 -6
- data/lib/theme_template/theme.gemspec.erb +16 -16
- data/rubocop/jekyll/assert_equal_literal_actual.rb +149 -149
- data/rubocop/jekyll/no_p_allowed.rb +23 -23
- data/rubocop/jekyll/no_puts_allowed.rb +23 -23
- data/rubocop/jekyll.rb +5 -5
- metadata +64 -18
data/lib/jekyll/excerpt.rb
CHANGED
@@ -1,201 +1,200 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
class Excerpt
|
5
|
-
extend Forwardable
|
6
|
-
|
7
|
-
attr_accessor :doc
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
|
24
|
-
|
25
|
-
self.
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
#
|
30
|
-
#
|
31
|
-
|
32
|
-
|
33
|
-
@data
|
34
|
-
@data.delete("
|
35
|
-
@data
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
#
|
42
|
-
#
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
#
|
49
|
-
#
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
#
|
56
|
-
#
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
#
|
100
|
-
#
|
101
|
-
#
|
102
|
-
#
|
103
|
-
#
|
104
|
-
#
|
105
|
-
#
|
106
|
-
#
|
107
|
-
#
|
108
|
-
#
|
109
|
-
#
|
110
|
-
#
|
111
|
-
#
|
112
|
-
#
|
113
|
-
#
|
114
|
-
#
|
115
|
-
#
|
116
|
-
#
|
117
|
-
#
|
118
|
-
#
|
119
|
-
#
|
120
|
-
#
|
121
|
-
#
|
122
|
-
#
|
123
|
-
#
|
124
|
-
#
|
125
|
-
#
|
126
|
-
#
|
127
|
-
#
|
128
|
-
#
|
129
|
-
#
|
130
|
-
#
|
131
|
-
#
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
head
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
#
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
tag_names
|
155
|
-
tag_names.
|
156
|
-
|
157
|
-
next
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
@endtag_regex_stash ||= {}
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
return false unless tag_name
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
Jekyll.logger.warn "
|
194
|
-
|
195
|
-
|
196
|
-
Jekyll.logger.warn "", "
|
197
|
-
Jekyll.logger.warn "", "
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class Excerpt
|
5
|
+
extend Forwardable
|
6
|
+
|
7
|
+
attr_accessor :content, :doc, :ext
|
8
|
+
attr_writer :output
|
9
|
+
|
10
|
+
def_delegators :@doc,
|
11
|
+
:site, :name, :ext, :extname,
|
12
|
+
:collection, :related_posts, :type,
|
13
|
+
:coffeescript_file?, :yaml_file?,
|
14
|
+
:url, :next_doc, :previous_doc
|
15
|
+
|
16
|
+
private :coffeescript_file?, :yaml_file?
|
17
|
+
|
18
|
+
# Initialize this Excerpt instance.
|
19
|
+
#
|
20
|
+
# doc - The Document.
|
21
|
+
#
|
22
|
+
# Returns the new Excerpt.
|
23
|
+
def initialize(doc)
|
24
|
+
self.doc = doc
|
25
|
+
self.content = extract_excerpt(doc.content)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Fetch YAML front-matter data from related doc, without layout key
|
29
|
+
#
|
30
|
+
# Returns Hash of doc data
|
31
|
+
def data
|
32
|
+
@data ||= doc.data.dup
|
33
|
+
@data.delete("layout")
|
34
|
+
@data.delete("excerpt")
|
35
|
+
@data
|
36
|
+
end
|
37
|
+
|
38
|
+
def trigger_hooks(*); end
|
39
|
+
|
40
|
+
# 'Path' of the excerpt.
|
41
|
+
#
|
42
|
+
# Returns the path for the doc this excerpt belongs to with #excerpt appended
|
43
|
+
def path
|
44
|
+
File.join(doc.path, "#excerpt")
|
45
|
+
end
|
46
|
+
|
47
|
+
# 'Relative Path' of the excerpt.
|
48
|
+
#
|
49
|
+
# Returns the relative_path for the doc this excerpt belongs to with #excerpt appended
|
50
|
+
def relative_path
|
51
|
+
@relative_path ||= File.join(doc.relative_path, "#excerpt")
|
52
|
+
end
|
53
|
+
|
54
|
+
# Check if excerpt includes a string
|
55
|
+
#
|
56
|
+
# Returns true if the string passed in
|
57
|
+
def include?(something)
|
58
|
+
output&.include?(something) || content.include?(something)
|
59
|
+
end
|
60
|
+
|
61
|
+
# The UID for this doc (useful in feeds).
|
62
|
+
# e.g. /2008/11/05/my-awesome-doc
|
63
|
+
#
|
64
|
+
# Returns the String UID.
|
65
|
+
def id
|
66
|
+
"#{doc.id}#excerpt"
|
67
|
+
end
|
68
|
+
|
69
|
+
def to_s
|
70
|
+
output || content
|
71
|
+
end
|
72
|
+
|
73
|
+
def to_liquid
|
74
|
+
Jekyll::Drops::ExcerptDrop.new(self)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Returns the shorthand String identifier of this doc.
|
78
|
+
def inspect
|
79
|
+
"<#{self.class} id=#{id}>"
|
80
|
+
end
|
81
|
+
|
82
|
+
def output
|
83
|
+
@output ||= Renderer.new(doc.site, self, site.site_payload).run
|
84
|
+
end
|
85
|
+
|
86
|
+
def place_in_layout?
|
87
|
+
false
|
88
|
+
end
|
89
|
+
|
90
|
+
def render_with_liquid?
|
91
|
+
return false if data["render_with_liquid"] == false
|
92
|
+
|
93
|
+
!(coffeescript_file? || yaml_file? || !Utils.has_liquid_construct?(content))
|
94
|
+
end
|
95
|
+
|
96
|
+
protected
|
97
|
+
|
98
|
+
# Internal: Extract excerpt from the content
|
99
|
+
#
|
100
|
+
# By default excerpt is your first paragraph of a doc: everything before
|
101
|
+
# the first two new lines:
|
102
|
+
#
|
103
|
+
# ---
|
104
|
+
# title: Example
|
105
|
+
# ---
|
106
|
+
#
|
107
|
+
# First paragraph with [link][1].
|
108
|
+
#
|
109
|
+
# Second paragraph.
|
110
|
+
#
|
111
|
+
# [1]: http://example.com/
|
112
|
+
#
|
113
|
+
# This is fairly good option for Markdown and Textile files. But might cause
|
114
|
+
# problems for HTML docs (which is quite unusual for Jekyll). If default
|
115
|
+
# excerpt delimiter is not good for you, you might want to set your own via
|
116
|
+
# configuration option `excerpt_separator`. For example, following is a good
|
117
|
+
# alternative for HTML docs:
|
118
|
+
#
|
119
|
+
# # file: _config.yml
|
120
|
+
# excerpt_separator: "<!-- more -->"
|
121
|
+
#
|
122
|
+
# Notice that all markdown-style link references will be appended to the
|
123
|
+
# excerpt. So the example doc above will have this excerpt source:
|
124
|
+
#
|
125
|
+
# First paragraph with [link][1].
|
126
|
+
#
|
127
|
+
# [1]: http://example.com/
|
128
|
+
#
|
129
|
+
# Excerpts are rendered same time as content is rendered.
|
130
|
+
#
|
131
|
+
# Returns excerpt String
|
132
|
+
|
133
|
+
LIQUID_TAG_REGEX = %r!{%-?\s*(\w+)\s*.*?-?%}!m.freeze
|
134
|
+
MKDWN_LINK_REF_REGEX = %r!^ {0,3}(?:(\[[^\]]+\])(:.+))$!.freeze
|
135
|
+
|
136
|
+
def extract_excerpt(doc_content)
|
137
|
+
head, _, tail = doc_content.to_s.partition(doc.excerpt_separator)
|
138
|
+
return head if tail.empty?
|
139
|
+
|
140
|
+
head = sanctify_liquid_tags(head) if head.include?("{%")
|
141
|
+
definitions = extract_markdown_link_reference_definitions(head, tail)
|
142
|
+
return head if definitions.empty?
|
143
|
+
|
144
|
+
head << "\n\n" << definitions.join("\n")
|
145
|
+
end
|
146
|
+
|
147
|
+
private
|
148
|
+
|
149
|
+
# append appropriate closing tag(s) (for each Liquid block), to the `head` if the
|
150
|
+
# partitioning resulted in leaving the closing tag somewhere in the `tail` partition.
|
151
|
+
def sanctify_liquid_tags(head)
|
152
|
+
modified = false
|
153
|
+
tag_names = head.scan(LIQUID_TAG_REGEX)
|
154
|
+
tag_names.flatten!
|
155
|
+
tag_names.reverse_each do |tag_name|
|
156
|
+
next unless liquid_block?(tag_name)
|
157
|
+
next if endtag_regex_stash(tag_name).match?(head)
|
158
|
+
|
159
|
+
modified = true
|
160
|
+
head << "\n{% end#{tag_name} %}"
|
161
|
+
end
|
162
|
+
|
163
|
+
print_build_warning if modified
|
164
|
+
head
|
165
|
+
end
|
166
|
+
|
167
|
+
def extract_markdown_link_reference_definitions(head, tail)
|
168
|
+
[].tap do |definitions|
|
169
|
+
tail.scan(MKDWN_LINK_REF_REGEX).each do |segments|
|
170
|
+
definitions << segments.join if head.include?(segments[0])
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
def endtag_regex_stash(tag_name)
|
176
|
+
@endtag_regex_stash ||= {}
|
177
|
+
@endtag_regex_stash[tag_name] ||= %r!{%-?\s*end#{tag_name}.*?\s*-?%}!m
|
178
|
+
end
|
179
|
+
|
180
|
+
def liquid_block?(tag_name)
|
181
|
+
return false unless tag_name.is_a?(String)
|
182
|
+
return false unless Liquid::Template.tags[tag_name]
|
183
|
+
|
184
|
+
Liquid::Template.tags[tag_name].ancestors.include?(Liquid::Block)
|
185
|
+
rescue NoMethodError
|
186
|
+
Jekyll.logger.error "Error:",
|
187
|
+
"A Liquid tag in the excerpt of #{doc.relative_path} couldn't be parsed."
|
188
|
+
raise
|
189
|
+
end
|
190
|
+
|
191
|
+
def print_build_warning
|
192
|
+
Jekyll.logger.warn "Warning:", "Excerpt modified in #{doc.relative_path}!"
|
193
|
+
Jekyll.logger.warn "", "Found a Liquid block containing the excerpt separator " \
|
194
|
+
"#{doc.excerpt_separator.inspect}."
|
195
|
+
Jekyll.logger.warn "", "The block has been modified with the appropriate closing tag."
|
196
|
+
Jekyll.logger.warn "", "Feel free to define a custom excerpt or excerpt_separator in the"
|
197
|
+
Jekyll.logger.warn "", "document's Front Matter if the generated excerpt is unsatisfactory."
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
data/lib/jekyll/external.rb
CHANGED
@@ -1,79 +1,75 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
module External
|
5
|
-
class << self
|
6
|
-
#
|
7
|
-
# Gems that, if installed, should be loaded.
|
8
|
-
# Usually contain subcommands.
|
9
|
-
#
|
10
|
-
def blessed_gems
|
11
|
-
%w(
|
12
|
-
jekyll-compose
|
13
|
-
jekyll-docs
|
14
|
-
jekyll-import
|
15
|
-
)
|
16
|
-
end
|
17
|
-
|
18
|
-
#
|
19
|
-
# Require a gem or file if it's present, otherwise silently fail.
|
20
|
-
#
|
21
|
-
# names - a string gem name or array of gem names
|
22
|
-
#
|
23
|
-
def require_if_present(names)
|
24
|
-
Array(names).each do |name|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module External
|
5
|
+
class << self
|
6
|
+
#
|
7
|
+
# Gems that, if installed, should be loaded.
|
8
|
+
# Usually contain subcommands.
|
9
|
+
#
|
10
|
+
def blessed_gems
|
11
|
+
%w(
|
12
|
+
jekyll-compose
|
13
|
+
jekyll-docs
|
14
|
+
jekyll-import
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
#
|
19
|
+
# Require a gem or file if it's present, otherwise silently fail.
|
20
|
+
#
|
21
|
+
# names - a string gem name or array of gem names
|
22
|
+
#
|
23
|
+
def require_if_present(names)
|
24
|
+
Array(names).each do |name|
|
25
|
+
require name
|
26
|
+
rescue LoadError
|
27
|
+
Jekyll.logger.debug "Couldn't load #{name}. Skipping."
|
28
|
+
yield(name, version_constraint(name)) if block_given?
|
29
|
+
false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# The version constraint required to activate a given gem.
|
35
|
+
# Usually the gem version requirement is "> 0," because any version
|
36
|
+
# will do. In the case of jekyll-docs, however, we require the exact
|
37
|
+
# same version as Jekyll.
|
38
|
+
#
|
39
|
+
# Returns a String version constraint in a parseable form for
|
40
|
+
# RubyGems.
|
41
|
+
def version_constraint(gem_name)
|
42
|
+
return "= #{Jekyll::VERSION}" if gem_name.to_s.eql?("jekyll-docs")
|
43
|
+
|
44
|
+
"> 0"
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# Require a gem or gems. If it's not present, show a very nice error
|
49
|
+
# message that explains everything and is much more helpful than the
|
50
|
+
# normal LoadError.
|
51
|
+
#
|
52
|
+
# names - a string gem name or array of gem names
|
53
|
+
#
|
54
|
+
def require_with_graceful_fail(names)
|
55
|
+
Array(names).each do |name|
|
56
|
+
Jekyll.logger.debug "Requiring:", name.to_s
|
57
|
+
require name
|
58
|
+
rescue LoadError => e
|
59
|
+
Jekyll.logger.error "Dependency Error:", <<~MSG
|
60
|
+
Yikes! It looks like you don't have #{name} or one of its dependencies installed.
|
61
|
+
In order to use Jekyll as currently configured, you'll need to install this gem.
|
62
|
+
|
63
|
+
If you've run Jekyll with `bundle exec`, ensure that you have included the #{name}
|
64
|
+
gem in your Gemfile as well.
|
65
|
+
|
66
|
+
The full error message from Ruby is: '#{e.message}'
|
67
|
+
|
68
|
+
If you run into trouble, you can find helpful resources at https://jekyllrb.com/help/!
|
69
|
+
MSG
|
70
|
+
raise Jekyll::Errors::MissingDependencyException, name
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|