jekyll 4.2.0 → 4.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +350 -347
- data/LICENSE +21 -21
- data/README.markdown +86 -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 +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 +190 -190
- data/lib/jekyll/cleaner.rb +111 -111
- data/lib/jekyll/collection.rb +309 -309
- data/lib/jekyll/command.rb +105 -105
- data/lib/jekyll/commands/build.rb +93 -93
- data/lib/jekyll/commands/clean.rb +45 -45
- data/lib/jekyll/commands/doctor.rb +177 -177
- data/lib/jekyll/commands/help.rb +34 -34
- data/lib/jekyll/commands/new.rb +169 -169
- data/lib/jekyll/commands/new_theme.rb +40 -40
- data/lib/jekyll/commands/serve/live_reload_reactor.rb +122 -122
- data/lib/jekyll/commands/serve/livereload_assets/livereload.js +1183 -1183
- data/lib/jekyll/commands/serve/servlet.rb +202 -202
- data/lib/jekyll/commands/serve/websockets.rb +81 -81
- data/lib/jekyll/commands/serve.rb +362 -365
- 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 +199 -199
- data/lib/jekyll/converters/markdown.rb +113 -113
- data/lib/jekyll/converters/smartypants.rb +70 -70
- data/lib/jekyll/convertible.rb +257 -260
- data/lib/jekyll/deprecator.rb +50 -50
- data/lib/jekyll/document.rb +544 -544
- data/lib/jekyll/drops/collection_drop.rb +20 -20
- data/lib/jekyll/drops/document_drop.rb +70 -70
- data/lib/jekyll/drops/drop.rb +293 -293
- data/lib/jekyll/drops/excerpt_drop.rb +19 -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/unified_payload_drop.rb +26 -26
- data/lib/jekyll/drops/url_drop.rb +140 -140
- data/lib/jekyll/entry_filter.rb +121 -121
- data/lib/jekyll/errors.rb +20 -20
- data/lib/jekyll/excerpt.rb +201 -201
- data/lib/jekyll/external.rb +79 -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 +535 -535
- data/lib/jekyll/frontmatter_defaults.rb +240 -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 +67 -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 +55 -55
- data/lib/jekyll/liquid_renderer.rb +80 -80
- data/lib/jekyll/log_adapter.rb +151 -151
- data/lib/jekyll/mime.types +866 -866
- data/lib/jekyll/page.rb +217 -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 +115 -115
- data/lib/jekyll/profiler.rb +58 -58
- data/lib/jekyll/publisher.rb +23 -23
- data/lib/jekyll/reader.rb +192 -192
- data/lib/jekyll/readers/collection_reader.rb +23 -23
- data/lib/jekyll/readers/data_reader.rb +79 -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 +265 -265
- data/lib/jekyll/site.rb +551 -551
- data/lib/jekyll/static_file.rb +208 -208
- data/lib/jekyll/stevenson.rb +60 -60
- data/lib/jekyll/tags/highlight.rb +110 -110
- data/lib/jekyll/tags/include.rb +275 -270
- data/lib/jekyll/tags/link.rb +42 -42
- data/lib/jekyll/tags/post_url.rb +106 -106
- data/lib/jekyll/theme.rb +86 -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 +75 -75
- data/lib/jekyll/utils.rb +367 -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 +52 -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 +3 -3
data/lib/jekyll/static_file.rb
CHANGED
@@ -1,208 +1,208 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
class StaticFile
|
5
|
-
extend Forwardable
|
6
|
-
|
7
|
-
attr_reader :relative_path, :extname, :name
|
8
|
-
|
9
|
-
def_delegator :to_liquid, :to_json, :to_json
|
10
|
-
|
11
|
-
class << self
|
12
|
-
# The cache of last modification times [path] -> mtime.
|
13
|
-
def mtimes
|
14
|
-
@mtimes ||= {}
|
15
|
-
end
|
16
|
-
|
17
|
-
def reset_cache
|
18
|
-
@mtimes = nil
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
# Initialize a new StaticFile.
|
23
|
-
#
|
24
|
-
# site - The Site.
|
25
|
-
# base - The String path to the <source>.
|
26
|
-
# dir - The String path between <source> and the file.
|
27
|
-
# name - The String filename of the file.
|
28
|
-
# rubocop: disable Metrics/ParameterLists
|
29
|
-
def initialize(site, base, dir, name, collection = nil)
|
30
|
-
@site = site
|
31
|
-
@base = base
|
32
|
-
@dir = dir
|
33
|
-
@name = name
|
34
|
-
@collection = collection
|
35
|
-
@relative_path = File.join(*[@dir, @name].compact)
|
36
|
-
@extname = File.extname(@name)
|
37
|
-
end
|
38
|
-
# rubocop: enable Metrics/ParameterLists
|
39
|
-
|
40
|
-
# Returns source file path.
|
41
|
-
def path
|
42
|
-
@path ||= begin
|
43
|
-
# Static file is from a collection inside custom collections directory
|
44
|
-
if !@collection.nil? && !@site.config["collections_dir"].empty?
|
45
|
-
File.join(*[@base, @site.config["collections_dir"], @dir, @name].compact)
|
46
|
-
else
|
47
|
-
File.join(*[@base, @dir, @name].compact)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# Obtain destination path.
|
53
|
-
#
|
54
|
-
# dest - The String path to the destination dir.
|
55
|
-
#
|
56
|
-
# Returns destination file path.
|
57
|
-
def destination(dest)
|
58
|
-
@destination ||= {}
|
59
|
-
@destination[dest] ||= @site.in_dest_dir(dest, Jekyll::URL.unescape_path(url))
|
60
|
-
end
|
61
|
-
|
62
|
-
def destination_rel_dir
|
63
|
-
if @collection
|
64
|
-
File.dirname(url)
|
65
|
-
else
|
66
|
-
@dir
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def modified_time
|
71
|
-
@modified_time ||= File.stat(path).mtime
|
72
|
-
end
|
73
|
-
|
74
|
-
# Returns last modification time for this file.
|
75
|
-
def mtime
|
76
|
-
modified_time.to_i
|
77
|
-
end
|
78
|
-
|
79
|
-
# Is source path modified?
|
80
|
-
#
|
81
|
-
# Returns true if modified since last write.
|
82
|
-
def modified?
|
83
|
-
self.class.mtimes[path] != mtime
|
84
|
-
end
|
85
|
-
|
86
|
-
# Whether to write the file to the filesystem
|
87
|
-
#
|
88
|
-
# Returns true unless the defaults for the destination path from
|
89
|
-
# _config.yml contain `published: false`.
|
90
|
-
def write?
|
91
|
-
publishable = defaults.fetch("published", true)
|
92
|
-
return publishable unless @collection
|
93
|
-
|
94
|
-
publishable && @collection.write?
|
95
|
-
end
|
96
|
-
|
97
|
-
# Write the static file to the destination directory (if modified).
|
98
|
-
#
|
99
|
-
# dest - The String path to the destination dir.
|
100
|
-
#
|
101
|
-
# Returns false if the file was not modified since last time (no-op).
|
102
|
-
def write(dest)
|
103
|
-
dest_path = destination(dest)
|
104
|
-
return false if File.exist?(dest_path) && !modified?
|
105
|
-
|
106
|
-
self.class.mtimes[path] = mtime
|
107
|
-
|
108
|
-
FileUtils.mkdir_p(File.dirname(dest_path))
|
109
|
-
FileUtils.rm(dest_path) if File.exist?(dest_path)
|
110
|
-
copy_file(dest_path)
|
111
|
-
|
112
|
-
true
|
113
|
-
end
|
114
|
-
|
115
|
-
def data
|
116
|
-
@data ||= @site.frontmatter_defaults.all(relative_path, type)
|
117
|
-
end
|
118
|
-
|
119
|
-
def to_liquid
|
120
|
-
@to_liquid ||= Drops::StaticFileDrop.new(self)
|
121
|
-
end
|
122
|
-
|
123
|
-
# Generate "basename without extension" and strip away any trailing periods.
|
124
|
-
# NOTE: `String#gsub` removes all trailing periods (in comparison to `String#chomp`)
|
125
|
-
def basename
|
126
|
-
@basename ||= File.basename(name, extname).gsub(%r!\.*\z!, "")
|
127
|
-
end
|
128
|
-
|
129
|
-
def placeholders
|
130
|
-
{
|
131
|
-
:collection => @collection.label,
|
132
|
-
:path => cleaned_relative_path,
|
133
|
-
:output_ext => "",
|
134
|
-
:name => basename,
|
135
|
-
:title => "",
|
136
|
-
}
|
137
|
-
end
|
138
|
-
|
139
|
-
# Similar to Jekyll::Document#cleaned_relative_path.
|
140
|
-
# Generates a relative path with the collection's directory removed when applicable
|
141
|
-
# and additionally removes any multiple periods in the string.
|
142
|
-
#
|
143
|
-
# NOTE: `String#gsub!` removes all trailing periods (in comparison to `String#chomp!`)
|
144
|
-
#
|
145
|
-
# Examples:
|
146
|
-
# When `relative_path` is "_methods/site/my-cool-avatar...png":
|
147
|
-
# cleaned_relative_path
|
148
|
-
# # => "/site/my-cool-avatar"
|
149
|
-
#
|
150
|
-
# Returns the cleaned relative path of the static file.
|
151
|
-
def cleaned_relative_path
|
152
|
-
@cleaned_relative_path ||= begin
|
153
|
-
cleaned = relative_path[0..-extname.length - 1]
|
154
|
-
cleaned.gsub!(%r!\.*\z!, "")
|
155
|
-
cleaned.sub!(@collection.relative_directory, "") if @collection
|
156
|
-
cleaned
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
# Applies a similar URL-building technique as Jekyll::Document that takes
|
161
|
-
# the collection's URL template into account. The default URL template can
|
162
|
-
# be overriden in the collection's configuration in _config.yml.
|
163
|
-
def url
|
164
|
-
@url ||= begin
|
165
|
-
base = if @collection.nil?
|
166
|
-
cleaned_relative_path
|
167
|
-
else
|
168
|
-
Jekyll::URL.new(
|
169
|
-
:template => @collection.url_template,
|
170
|
-
:placeholders => placeholders
|
171
|
-
)
|
172
|
-
end.to_s.chomp("/")
|
173
|
-
base << extname
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
# Returns the type of the collection if present, nil otherwise.
|
178
|
-
def type
|
179
|
-
@type ||= @collection.nil? ? nil : @collection.label.to_sym
|
180
|
-
end
|
181
|
-
|
182
|
-
# Returns the front matter defaults defined for the file's URL and/or type
|
183
|
-
# as defined in _config.yml.
|
184
|
-
def defaults
|
185
|
-
@defaults ||= @site.frontmatter_defaults.all url, type
|
186
|
-
end
|
187
|
-
|
188
|
-
# Returns a debug string on inspecting the static file.
|
189
|
-
# Includes only the relative path of the object.
|
190
|
-
def inspect
|
191
|
-
"#<#{self.class} @relative_path=#{relative_path.inspect}>"
|
192
|
-
end
|
193
|
-
|
194
|
-
private
|
195
|
-
|
196
|
-
def copy_file(dest_path)
|
197
|
-
if @site.safe || Jekyll.env == "production"
|
198
|
-
FileUtils.cp(path, dest_path)
|
199
|
-
else
|
200
|
-
FileUtils.copy_entry(path, dest_path)
|
201
|
-
end
|
202
|
-
|
203
|
-
unless File.symlink?(dest_path)
|
204
|
-
File.utime(self.class.mtimes[path], self.class.mtimes[path], dest_path)
|
205
|
-
end
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class StaticFile
|
5
|
+
extend Forwardable
|
6
|
+
|
7
|
+
attr_reader :relative_path, :extname, :name
|
8
|
+
|
9
|
+
def_delegator :to_liquid, :to_json, :to_json
|
10
|
+
|
11
|
+
class << self
|
12
|
+
# The cache of last modification times [path] -> mtime.
|
13
|
+
def mtimes
|
14
|
+
@mtimes ||= {}
|
15
|
+
end
|
16
|
+
|
17
|
+
def reset_cache
|
18
|
+
@mtimes = nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Initialize a new StaticFile.
|
23
|
+
#
|
24
|
+
# site - The Site.
|
25
|
+
# base - The String path to the <source>.
|
26
|
+
# dir - The String path between <source> and the file.
|
27
|
+
# name - The String filename of the file.
|
28
|
+
# rubocop: disable Metrics/ParameterLists
|
29
|
+
def initialize(site, base, dir, name, collection = nil)
|
30
|
+
@site = site
|
31
|
+
@base = base
|
32
|
+
@dir = dir
|
33
|
+
@name = name
|
34
|
+
@collection = collection
|
35
|
+
@relative_path = File.join(*[@dir, @name].compact)
|
36
|
+
@extname = File.extname(@name)
|
37
|
+
end
|
38
|
+
# rubocop: enable Metrics/ParameterLists
|
39
|
+
|
40
|
+
# Returns source file path.
|
41
|
+
def path
|
42
|
+
@path ||= begin
|
43
|
+
# Static file is from a collection inside custom collections directory
|
44
|
+
if !@collection.nil? && !@site.config["collections_dir"].empty?
|
45
|
+
File.join(*[@base, @site.config["collections_dir"], @dir, @name].compact)
|
46
|
+
else
|
47
|
+
File.join(*[@base, @dir, @name].compact)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Obtain destination path.
|
53
|
+
#
|
54
|
+
# dest - The String path to the destination dir.
|
55
|
+
#
|
56
|
+
# Returns destination file path.
|
57
|
+
def destination(dest)
|
58
|
+
@destination ||= {}
|
59
|
+
@destination[dest] ||= @site.in_dest_dir(dest, Jekyll::URL.unescape_path(url))
|
60
|
+
end
|
61
|
+
|
62
|
+
def destination_rel_dir
|
63
|
+
if @collection
|
64
|
+
File.dirname(url)
|
65
|
+
else
|
66
|
+
@dir
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def modified_time
|
71
|
+
@modified_time ||= File.stat(path).mtime
|
72
|
+
end
|
73
|
+
|
74
|
+
# Returns last modification time for this file.
|
75
|
+
def mtime
|
76
|
+
modified_time.to_i
|
77
|
+
end
|
78
|
+
|
79
|
+
# Is source path modified?
|
80
|
+
#
|
81
|
+
# Returns true if modified since last write.
|
82
|
+
def modified?
|
83
|
+
self.class.mtimes[path] != mtime
|
84
|
+
end
|
85
|
+
|
86
|
+
# Whether to write the file to the filesystem
|
87
|
+
#
|
88
|
+
# Returns true unless the defaults for the destination path from
|
89
|
+
# _config.yml contain `published: false`.
|
90
|
+
def write?
|
91
|
+
publishable = defaults.fetch("published", true)
|
92
|
+
return publishable unless @collection
|
93
|
+
|
94
|
+
publishable && @collection.write?
|
95
|
+
end
|
96
|
+
|
97
|
+
# Write the static file to the destination directory (if modified).
|
98
|
+
#
|
99
|
+
# dest - The String path to the destination dir.
|
100
|
+
#
|
101
|
+
# Returns false if the file was not modified since last time (no-op).
|
102
|
+
def write(dest)
|
103
|
+
dest_path = destination(dest)
|
104
|
+
return false if File.exist?(dest_path) && !modified?
|
105
|
+
|
106
|
+
self.class.mtimes[path] = mtime
|
107
|
+
|
108
|
+
FileUtils.mkdir_p(File.dirname(dest_path))
|
109
|
+
FileUtils.rm(dest_path) if File.exist?(dest_path)
|
110
|
+
copy_file(dest_path)
|
111
|
+
|
112
|
+
true
|
113
|
+
end
|
114
|
+
|
115
|
+
def data
|
116
|
+
@data ||= @site.frontmatter_defaults.all(relative_path, type)
|
117
|
+
end
|
118
|
+
|
119
|
+
def to_liquid
|
120
|
+
@to_liquid ||= Drops::StaticFileDrop.new(self)
|
121
|
+
end
|
122
|
+
|
123
|
+
# Generate "basename without extension" and strip away any trailing periods.
|
124
|
+
# NOTE: `String#gsub` removes all trailing periods (in comparison to `String#chomp`)
|
125
|
+
def basename
|
126
|
+
@basename ||= File.basename(name, extname).gsub(%r!\.*\z!, "")
|
127
|
+
end
|
128
|
+
|
129
|
+
def placeholders
|
130
|
+
{
|
131
|
+
:collection => @collection.label,
|
132
|
+
:path => cleaned_relative_path,
|
133
|
+
:output_ext => "",
|
134
|
+
:name => basename,
|
135
|
+
:title => "",
|
136
|
+
}
|
137
|
+
end
|
138
|
+
|
139
|
+
# Similar to Jekyll::Document#cleaned_relative_path.
|
140
|
+
# Generates a relative path with the collection's directory removed when applicable
|
141
|
+
# and additionally removes any multiple periods in the string.
|
142
|
+
#
|
143
|
+
# NOTE: `String#gsub!` removes all trailing periods (in comparison to `String#chomp!`)
|
144
|
+
#
|
145
|
+
# Examples:
|
146
|
+
# When `relative_path` is "_methods/site/my-cool-avatar...png":
|
147
|
+
# cleaned_relative_path
|
148
|
+
# # => "/site/my-cool-avatar"
|
149
|
+
#
|
150
|
+
# Returns the cleaned relative path of the static file.
|
151
|
+
def cleaned_relative_path
|
152
|
+
@cleaned_relative_path ||= begin
|
153
|
+
cleaned = relative_path[0..-extname.length - 1]
|
154
|
+
cleaned.gsub!(%r!\.*\z!, "")
|
155
|
+
cleaned.sub!(@collection.relative_directory, "") if @collection
|
156
|
+
cleaned
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
# Applies a similar URL-building technique as Jekyll::Document that takes
|
161
|
+
# the collection's URL template into account. The default URL template can
|
162
|
+
# be overriden in the collection's configuration in _config.yml.
|
163
|
+
def url
|
164
|
+
@url ||= begin
|
165
|
+
base = if @collection.nil?
|
166
|
+
cleaned_relative_path
|
167
|
+
else
|
168
|
+
Jekyll::URL.new(
|
169
|
+
:template => @collection.url_template,
|
170
|
+
:placeholders => placeholders
|
171
|
+
)
|
172
|
+
end.to_s.chomp("/")
|
173
|
+
base << extname
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
# Returns the type of the collection if present, nil otherwise.
|
178
|
+
def type
|
179
|
+
@type ||= @collection.nil? ? nil : @collection.label.to_sym
|
180
|
+
end
|
181
|
+
|
182
|
+
# Returns the front matter defaults defined for the file's URL and/or type
|
183
|
+
# as defined in _config.yml.
|
184
|
+
def defaults
|
185
|
+
@defaults ||= @site.frontmatter_defaults.all url, type
|
186
|
+
end
|
187
|
+
|
188
|
+
# Returns a debug string on inspecting the static file.
|
189
|
+
# Includes only the relative path of the object.
|
190
|
+
def inspect
|
191
|
+
"#<#{self.class} @relative_path=#{relative_path.inspect}>"
|
192
|
+
end
|
193
|
+
|
194
|
+
private
|
195
|
+
|
196
|
+
def copy_file(dest_path)
|
197
|
+
if @site.safe || Jekyll.env == "production"
|
198
|
+
FileUtils.cp(path, dest_path)
|
199
|
+
else
|
200
|
+
FileUtils.copy_entry(path, dest_path)
|
201
|
+
end
|
202
|
+
|
203
|
+
unless File.symlink?(dest_path)
|
204
|
+
File.utime(self.class.mtimes[path], self.class.mtimes[path], dest_path)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
data/lib/jekyll/stevenson.rb
CHANGED
@@ -1,60 +1,60 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
class Stevenson < ::Logger
|
5
|
-
def initialize
|
6
|
-
@progname = nil
|
7
|
-
@level = DEBUG
|
8
|
-
@default_formatter = Formatter.new
|
9
|
-
@logdev = $stdout
|
10
|
-
@formatter = proc do |_, _, _, msg|
|
11
|
-
msg.to_s
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def add(severity, message = nil, progname = nil)
|
16
|
-
severity ||= UNKNOWN
|
17
|
-
@logdev = logdevice(severity)
|
18
|
-
|
19
|
-
return true if @logdev.nil? || severity < @level
|
20
|
-
|
21
|
-
progname ||= @progname
|
22
|
-
if message.nil?
|
23
|
-
if block_given?
|
24
|
-
message = yield
|
25
|
-
else
|
26
|
-
message = progname
|
27
|
-
progname = @progname
|
28
|
-
end
|
29
|
-
end
|
30
|
-
@logdev.puts(
|
31
|
-
format_message(format_severity(severity), Time.now, progname, message)
|
32
|
-
)
|
33
|
-
true
|
34
|
-
end
|
35
|
-
|
36
|
-
# Log a +WARN+ message
|
37
|
-
def warn(progname = nil, &block)
|
38
|
-
add(WARN, nil, progname.yellow, &block)
|
39
|
-
end
|
40
|
-
|
41
|
-
# Log an +ERROR+ message
|
42
|
-
def error(progname = nil, &block)
|
43
|
-
add(ERROR, nil, progname.red, &block)
|
44
|
-
end
|
45
|
-
|
46
|
-
def close
|
47
|
-
# No LogDevice in use
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
def logdevice(severity)
|
53
|
-
if severity > INFO
|
54
|
-
$stderr
|
55
|
-
else
|
56
|
-
$stdout
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class Stevenson < ::Logger
|
5
|
+
def initialize
|
6
|
+
@progname = nil
|
7
|
+
@level = DEBUG
|
8
|
+
@default_formatter = Formatter.new
|
9
|
+
@logdev = $stdout
|
10
|
+
@formatter = proc do |_, _, _, msg|
|
11
|
+
msg.to_s
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def add(severity, message = nil, progname = nil)
|
16
|
+
severity ||= UNKNOWN
|
17
|
+
@logdev = logdevice(severity)
|
18
|
+
|
19
|
+
return true if @logdev.nil? || severity < @level
|
20
|
+
|
21
|
+
progname ||= @progname
|
22
|
+
if message.nil?
|
23
|
+
if block_given?
|
24
|
+
message = yield
|
25
|
+
else
|
26
|
+
message = progname
|
27
|
+
progname = @progname
|
28
|
+
end
|
29
|
+
end
|
30
|
+
@logdev.puts(
|
31
|
+
format_message(format_severity(severity), Time.now, progname, message)
|
32
|
+
)
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
36
|
+
# Log a +WARN+ message
|
37
|
+
def warn(progname = nil, &block)
|
38
|
+
add(WARN, nil, progname.yellow, &block)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Log an +ERROR+ message
|
42
|
+
def error(progname = nil, &block)
|
43
|
+
add(ERROR, nil, progname.red, &block)
|
44
|
+
end
|
45
|
+
|
46
|
+
def close
|
47
|
+
# No LogDevice in use
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def logdevice(severity)
|
53
|
+
if severity > INFO
|
54
|
+
$stderr
|
55
|
+
else
|
56
|
+
$stdout
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|