jekyll 3.10.0 → 4.0.0.pre.alpha1

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.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +27 -50
  3. data/LICENSE +1 -1
  4. data/README.markdown +46 -17
  5. data/lib/blank_template/_config.yml +3 -0
  6. data/lib/blank_template/_layouts/default.html +12 -0
  7. data/lib/blank_template/_sass/main.scss +9 -0
  8. data/lib/blank_template/assets/css/main.scss +4 -0
  9. data/lib/blank_template/index.md +8 -0
  10. data/lib/jekyll/cache.rb +183 -0
  11. data/lib/jekyll/cleaner.rb +2 -1
  12. data/lib/jekyll/collection.rb +78 -8
  13. data/lib/jekyll/command.rb +31 -6
  14. data/lib/jekyll/commands/build.rb +11 -20
  15. data/lib/jekyll/commands/clean.rb +2 -0
  16. data/lib/jekyll/commands/doctor.rb +15 -8
  17. data/lib/jekyll/commands/help.rb +1 -1
  18. data/lib/jekyll/commands/new.rb +37 -42
  19. data/lib/jekyll/commands/new_theme.rb +30 -28
  20. data/lib/jekyll/commands/serve/live_reload_reactor.rb +6 -10
  21. data/lib/jekyll/commands/serve/servlet.rb +15 -19
  22. data/lib/jekyll/commands/serve.rb +46 -86
  23. data/lib/jekyll/configuration.rb +26 -26
  24. data/lib/jekyll/converters/identity.rb +18 -0
  25. data/lib/jekyll/converters/markdown/kramdown_parser.rb +1 -10
  26. data/lib/jekyll/converters/markdown.rb +49 -40
  27. data/lib/jekyll/converters/smartypants.rb +34 -14
  28. data/lib/jekyll/convertible.rb +11 -13
  29. data/lib/jekyll/deprecator.rb +1 -3
  30. data/lib/jekyll/document.rb +44 -41
  31. data/lib/jekyll/drops/collection_drop.rb +2 -3
  32. data/lib/jekyll/drops/document_drop.rb +2 -1
  33. data/lib/jekyll/drops/drop.rb +3 -6
  34. data/lib/jekyll/drops/excerpt_drop.rb +4 -0
  35. data/lib/jekyll/drops/site_drop.rb +4 -13
  36. data/lib/jekyll/drops/unified_payload_drop.rb +1 -0
  37. data/lib/jekyll/drops/url_drop.rb +1 -0
  38. data/lib/jekyll/entry_filter.rb +2 -1
  39. data/lib/jekyll/excerpt.rb +45 -34
  40. data/lib/jekyll/external.rb +10 -5
  41. data/lib/jekyll/filters/date_filters.rb +6 -3
  42. data/lib/jekyll/filters/grouping_filters.rb +1 -2
  43. data/lib/jekyll/filters/url_filters.rb +6 -1
  44. data/lib/jekyll/filters.rb +72 -31
  45. data/lib/jekyll/frontmatter_defaults.rb +35 -19
  46. data/lib/jekyll/hooks.rb +2 -3
  47. data/lib/jekyll/liquid_extensions.rb +0 -2
  48. data/lib/jekyll/liquid_renderer/file.rb +14 -3
  49. data/lib/jekyll/liquid_renderer/table.rb +67 -65
  50. data/lib/jekyll/liquid_renderer.rb +13 -1
  51. data/lib/jekyll/log_adapter.rb +5 -1
  52. data/lib/jekyll/mime.types +80 -195
  53. data/lib/jekyll/page.rb +10 -26
  54. data/lib/jekyll/page_without_a_file.rb +0 -4
  55. data/lib/jekyll/plugin.rb +5 -11
  56. data/lib/jekyll/plugin_manager.rb +2 -0
  57. data/lib/jekyll/reader.rb +38 -8
  58. data/lib/jekyll/readers/data_reader.rb +5 -5
  59. data/lib/jekyll/readers/layout_reader.rb +2 -12
  60. data/lib/jekyll/readers/post_reader.rb +29 -17
  61. data/lib/jekyll/readers/static_file_reader.rb +1 -1
  62. data/lib/jekyll/readers/theme_assets_reader.rb +7 -5
  63. data/lib/jekyll/regenerator.rb +4 -12
  64. data/lib/jekyll/renderer.rb +14 -25
  65. data/lib/jekyll/site.rb +78 -34
  66. data/lib/jekyll/static_file.rb +47 -11
  67. data/lib/jekyll/stevenson.rb +7 -5
  68. data/lib/jekyll/tags/highlight.rb +22 -52
  69. data/lib/jekyll/tags/include.rb +27 -48
  70. data/lib/jekyll/tags/link.rb +11 -7
  71. data/lib/jekyll/tags/post_url.rb +17 -16
  72. data/lib/jekyll/theme.rb +12 -23
  73. data/lib/jekyll/theme_builder.rb +91 -89
  74. data/lib/jekyll/url.rb +3 -2
  75. data/lib/jekyll/utils/ansi.rb +1 -1
  76. data/lib/jekyll/utils/exec.rb +0 -1
  77. data/lib/jekyll/utils/internet.rb +2 -4
  78. data/lib/jekyll/utils/platforms.rb +8 -8
  79. data/lib/jekyll/utils/thread_event.rb +1 -5
  80. data/lib/jekyll/utils/win_tz.rb +47 -18
  81. data/lib/jekyll/utils.rb +5 -4
  82. data/lib/jekyll/version.rb +1 -1
  83. data/lib/jekyll.rb +5 -0
  84. data/lib/site_template/.gitignore +2 -0
  85. data/lib/site_template/404.html +1 -0
  86. data/lib/site_template/_config.yml +17 -5
  87. data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +5 -1
  88. data/lib/theme_template/gitignore.erb +1 -0
  89. data/rubocop/jekyll/assert_equal_literal_actual.rb +149 -0
  90. metadata +70 -71
  91. data/lib/jekyll/commands/serve/mime_types_charset.json +0 -71
  92. data/lib/jekyll/converters/markdown/rdiscount_parser.rb +0 -37
  93. data/lib/jekyll/converters/markdown/redcarpet_parser.rb +0 -112
  94. data/lib/jekyll/utils/rouge.rb +0 -22
  95. /data/lib/site_template/{about.md → about.markdown} +0 -0
  96. /data/lib/site_template/{index.md → index.markdown} +0 -0
@@ -2,28 +2,19 @@
2
2
 
3
3
  module Jekyll
4
4
  module Tags
5
- class IncludeTagError < StandardError
6
- attr_accessor :path
7
-
8
- def initialize(msg, path)
9
- super(msg)
10
- @path = path
11
- end
12
- end
13
-
14
5
  class IncludeTag < Liquid::Tag
15
6
  VALID_SYNTAX = %r!
16
7
  ([\w-]+)\s*=\s*
17
8
  (?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w\.-]+))
18
- !x
9
+ !x.freeze
19
10
  VARIABLE_SYNTAX = %r!
20
11
  (?<variable>[^{]*(\{\{\s*[\w\-\.]+\s*(\|.*)?\}\}[^\s{}]*)+)
21
12
  (?<params>.*)
22
- !mx
13
+ !mx.freeze
23
14
 
24
- FULL_VALID_SYNTAX = %r!\A\s*(?:#{VALID_SYNTAX}(?=\s|\z)\s*)*\z!
25
- VALID_FILENAME_CHARS = %r!^[\w/.\-()+~\#@]+$!
26
- INVALID_SEQUENCES = %r![./]{2,}!
15
+ FULL_VALID_SYNTAX = %r!\A\s*(?:#{VALID_SYNTAX}(?=\s|\z)\s*)*\z!.freeze
16
+ VALID_FILENAME_CHARS = %r!^[\w/\.-]+$!.freeze
17
+ INVALID_SEQUENCES = %r![./]{2,}!.freeze
27
18
 
28
19
  def initialize(tag_name, markup, tokens)
29
20
  super
@@ -50,9 +41,9 @@ module Jekyll
50
41
  markup = markup[match.end(0)..-1]
51
42
 
52
43
  value = if match[2]
53
- match[2].gsub(%r!\\"!, '"')
44
+ match[2].gsub('\\"', '"')
54
45
  elsif match[3]
55
- match[3].gsub(%r!\\'!, "'")
46
+ match[3].gsub("\\'", "'")
56
47
  elsif match[4]
57
48
  context[match[4]]
58
49
  end
@@ -64,31 +55,31 @@ module Jekyll
64
55
 
65
56
  def validate_file_name(file)
66
57
  if file =~ INVALID_SEQUENCES || file !~ VALID_FILENAME_CHARS
67
- raise ArgumentError, <<-MSG
68
- Invalid syntax for include tag. File contains invalid characters or sequences:
58
+ raise ArgumentError, <<~MSG
59
+ Invalid syntax for include tag. File contains invalid characters or sequences:
69
60
 
70
- #{file}
61
+ #{file}
71
62
 
72
- Valid syntax:
63
+ Valid syntax:
73
64
 
74
- #{syntax_example}
65
+ #{syntax_example}
75
66
 
76
- MSG
67
+ MSG
77
68
  end
78
69
  end
79
70
 
80
71
  def validate_params
81
72
  unless @params =~ FULL_VALID_SYNTAX
82
- raise ArgumentError, <<-MSG
83
- Invalid syntax for include tag:
73
+ raise ArgumentError, <<~MSG
74
+ Invalid syntax for include tag:
84
75
 
85
- #{@params}
76
+ #{@params}
86
77
 
87
- Valid syntax:
78
+ Valid syntax:
88
79
 
89
- #{syntax_example}
80
+ #{syntax_example}
90
81
 
91
- MSG
82
+ MSG
92
83
  end
93
84
  end
94
85
 
@@ -99,13 +90,7 @@ MSG
99
90
 
100
91
  # Render the variable if required
101
92
  def render_variable(context)
102
- if @file =~ VARIABLE_SYNTAX
103
- partial = context.registers[:site]
104
- .liquid_renderer
105
- .file("(variable)")
106
- .parse(@file)
107
- partial.render!(context)
108
- end
93
+ Liquid::Template.parse(@file).render(context) if @file =~ VARIABLE_SYNTAX
109
94
  end
110
95
 
111
96
  def tag_includes_dirs(context)
@@ -147,17 +132,12 @@ MSG
147
132
  end
148
133
 
149
134
  def add_include_to_dependency(site, path, context)
150
- page = context.registers[:page]
151
- return unless page
152
- return unless page.key?("path")
153
-
154
- absolute_path = \
155
- if page["collection"]
156
- site.in_source_dir(site.config["collections_dir"], page["path"])
157
- else
158
- site.in_source_dir(page["path"])
159
- end
160
- site.regenerator.add_dependency(absolute_path, path)
135
+ if context.registers[:page]&.key?("path")
136
+ site.regenerator.add_dependency(
137
+ site.in_source_dir(context.registers[:page]["path"]),
138
+ path
139
+ )
140
+ end
161
141
  end
162
142
 
163
143
  def load_cached_partial(path, context)
@@ -196,7 +176,7 @@ MSG
196
176
 
197
177
  # This method allows to modify the file content by inheriting from the class.
198
178
  def read_file(file, context)
199
- File.read(file, **file_read_opts(context))
179
+ File.read(file, file_read_opts(context))
200
180
  end
201
181
 
202
182
  private
@@ -229,7 +209,6 @@ MSG
229
209
  else
230
210
  File.join(site.config["collections_dir"], page_payload["path"])
231
211
  end
232
- resource_path.sub!(%r!/#excerpt\z!, "")
233
212
  site.in_source_dir File.dirname(resource_path)
234
213
  end
235
214
  end
@@ -3,9 +3,11 @@
3
3
  module Jekyll
4
4
  module Tags
5
5
  class Link < Liquid::Tag
6
+ include Jekyll::Filters::URLFilters
7
+
6
8
  class << self
7
9
  def tag_name
8
- self.name.split("::").last.downcase
10
+ name.split("::").last.downcase
9
11
  end
10
12
  end
11
13
 
@@ -16,19 +18,21 @@ module Jekyll
16
18
  end
17
19
 
18
20
  def render(context)
21
+ @context = context
19
22
  site = context.registers[:site]
23
+ relative_path = Liquid::Template.parse(@relative_path).render(context)
20
24
 
21
25
  site.each_site_file do |item|
22
- return item.url if item.relative_path == @relative_path
26
+ return relative_url(item) if item.relative_path == relative_path
23
27
  # This takes care of the case for static files that have a leading /
24
- return item.url if item.relative_path == "/#{@relative_path}"
28
+ return relative_url(item) if item.relative_path == "/#{relative_path}"
25
29
  end
26
30
 
27
- raise ArgumentError, <<-MSG
28
- Could not find document '#{@relative_path}' in tag '#{self.class.tag_name}'.
31
+ raise ArgumentError, <<~MSG
32
+ Could not find document '#{relative_path}' in tag '#{self.class.tag_name}'.
29
33
 
30
- Make sure the document exists and the path is correct.
31
- MSG
34
+ Make sure the document exists and the path is correct.
35
+ MSG
32
36
  end
33
37
  end
34
38
  end
@@ -3,7 +3,7 @@
3
3
  module Jekyll
4
4
  module Tags
5
5
  class PostComparer
6
- MATCHER = %r!^(.+/)*(\d+-\d+-\d+)-(.*)$!
6
+ MATCHER = %r!^(.+/)*(\d+-\d+-\d+)-(.*)$!.freeze
7
7
 
8
8
  attr_reader :path, :date, :slug, :name
9
9
 
@@ -13,7 +13,7 @@ module Jekyll
13
13
  all, @path, @date, @slug = *name.sub(%r!^/!, "").match(MATCHER)
14
14
  unless all
15
15
  raise Jekyll::Errors::InvalidPostNameError,
16
- "'#{name}' does not contain valid date and/or title."
16
+ "'#{name}' does not contain valid date and/or title."
17
17
  end
18
18
 
19
19
  escaped_slug = Regexp.escape(slug)
@@ -22,8 +22,10 @@ module Jekyll
22
22
  end
23
23
 
24
24
  def post_date
25
- @post_date ||= Utils.parse_date(date,
26
- "\"#{date}\" does not contain valid date and/or title.")
25
+ @post_date ||= Utils.parse_date(
26
+ date,
27
+ "'#{date}' does not contain valid date and/or title."
28
+ )
27
29
  end
28
30
 
29
31
  def ==(other)
@@ -38,6 +40,7 @@ module Jekyll
38
40
  end
39
41
 
40
42
  private
43
+
41
44
  # Construct the directory-aware post slug for a Jekyll::Post
42
45
  #
43
46
  # other - the Jekyll::Post
@@ -60,13 +63,11 @@ module Jekyll
60
63
  begin
61
64
  @post = PostComparer.new(@orig_post)
62
65
  rescue StandardError => e
63
- raise Jekyll::Errors::PostURLError, <<-MSG
64
- Could not parse name of post "#{@orig_post}" in tag 'post_url'.
65
-
66
- Make sure the post exists and the name is correct.
67
-
68
- #{e.class}: #{e.message}
69
- MSG
66
+ raise Jekyll::Errors::PostURLError, <<~MSG
67
+ Could not parse name of post "#{@orig_post}" in tag 'post_url'.
68
+ Make sure the post exists and the name is correct.
69
+ #{e.class}: #{e.message}
70
+ MSG
70
71
  end
71
72
  end
72
73
 
@@ -82,6 +83,7 @@ MSG
82
83
 
83
84
  site.posts.docs.each do |p|
84
85
  next unless @post.deprecated_equality p
86
+
85
87
  Jekyll::Deprecator.deprecation_message "A call to "\
86
88
  "'{% post_url #{@post.name} %}' did not match " \
87
89
  "a post using the new matching method of checking name " \
@@ -90,11 +92,10 @@ MSG
90
92
  return p.url
91
93
  end
92
94
 
93
- raise Jekyll::Errors::PostURLError, <<-MSG
94
- Could not find post "#{@orig_post}" in tag 'post_url'.
95
-
96
- Make sure the post exists and the name is correct.
97
- MSG
95
+ raise Jekyll::Errors::PostURLError, <<~MSG
96
+ Could not find post "#{@orig_post}" in tag 'post_url'.
97
+ Make sure the post exists and the name is correct.
98
+ MSG
98
99
  end
99
100
  end
100
101
  end
data/lib/jekyll/theme.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Jekyll
4
4
  class Theme
5
5
  extend Forwardable
6
- attr_reader :name
6
+ attr_reader :name
7
7
  def_delegator :gemspec, :version, :version
8
8
 
9
9
  def initialize(name)
@@ -23,23 +23,24 @@ module Jekyll
23
23
  end
24
24
 
25
25
  def includes_path
26
- @includes_path ||= path_for "_includes".freeze
26
+ @includes_path ||= path_for "_includes"
27
27
  end
28
28
 
29
29
  def layouts_path
30
- @layouts_path ||= path_for "_layouts".freeze
30
+ @layouts_path ||= path_for "_layouts"
31
31
  end
32
32
 
33
33
  def sass_path
34
- @sass_path ||= path_for "_sass".freeze
34
+ @sass_path ||= path_for "_sass"
35
35
  end
36
36
 
37
37
  def assets_path
38
- @assets_path ||= path_for "assets".freeze
38
+ @assets_path ||= path_for "assets"
39
39
  end
40
40
 
41
41
  def configure_sass
42
42
  return unless sass_path
43
+
43
44
  External.require_with_graceful_fail("sass") unless defined?(Sass)
44
45
  Sass.load_paths << sass_path
45
46
  end
@@ -56,33 +57,21 @@ module Jekyll
56
57
  end
57
58
 
58
59
  def realpath_for(folder)
59
- # This resolves all symlinks for the theme subfolder and then ensures
60
- # that the directory remains inside the theme root. This prevents the
61
- # use of symlinks for theme subfolders to escape the theme root.
60
+ # This resolves all symlinks for the theme subfolder and then ensures that the directory
61
+ # remains inside the theme root. This prevents the use of symlinks for theme subfolders to
62
+ # escape the theme root.
62
63
  # However, symlinks are allowed to point to other directories within the theme.
63
64
  Jekyll.sanitized_path(root, File.realpath(Jekyll.sanitized_path(root, folder.to_s)))
64
- rescue Errno::ENOENT, Errno::EACCES, Errno::ELOOP => e
65
- log_realpath_exception(e, folder)
65
+ rescue Errno::ENOENT, Errno::EACCES, Errno::ELOOP
66
+ Jekyll.logger.warn "Invalid theme folder:", folder
66
67
  nil
67
68
  end
68
69
 
69
- def log_realpath_exception(err, folder)
70
- return if err.is_a?(Errno::ENOENT)
71
-
72
- case err
73
- when Errno::EACCES
74
- Jekyll.logger.error "Theme error:", "Directory '#{folder}' is not accessible."
75
- when Errno::ELOOP
76
- Jekyll.logger.error "Theme error:",
77
- "Directory '#{folder}' includes a symbolic link loop."
78
- end
79
- end
80
-
81
70
  def gemspec
82
71
  @gemspec ||= Gem::Specification.find_by_name(name)
83
72
  rescue Gem::LoadError
84
73
  raise Jekyll::Errors::MissingDependencyException,
85
- "The #{name} theme could not be found."
74
+ "The #{name} theme could not be found."
86
75
  end
87
76
  end
88
77
  end
@@ -1,119 +1,121 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Jekyll::ThemeBuilder
4
- SCAFFOLD_DIRECTORIES = %w(
5
- assets _layouts _includes _sass
6
- ).freeze
7
-
8
- attr_reader :name, :path, :code_of_conduct
3
+ module Jekyll
4
+ class ThemeBuilder
5
+ SCAFFOLD_DIRECTORIES = %w(
6
+ assets _layouts _includes _sass
7
+ ).freeze
8
+
9
+ attr_reader :name, :path, :code_of_conduct
10
+
11
+ def initialize(theme_name, opts)
12
+ @name = theme_name.to_s.tr(" ", "_").squeeze("_")
13
+ @path = Pathname.new(File.expand_path(name, Dir.pwd))
14
+ @code_of_conduct = !!opts["code_of_conduct"]
15
+ end
9
16
 
10
- def initialize(theme_name, opts)
11
- @name = theme_name.to_s.tr(" ", "_").squeeze("_")
12
- @path = Pathname.new(File.expand_path(name, Dir.pwd))
13
- @code_of_conduct = !!opts["code_of_conduct"]
14
- end
17
+ def create!
18
+ create_directories
19
+ create_starter_files
20
+ create_gemspec
21
+ create_accessories
22
+ initialize_git_repo
23
+ end
15
24
 
16
- def create!
17
- create_directories
18
- create_starter_files
19
- create_gemspec
20
- create_accessories
21
- initialize_git_repo
22
- end
25
+ def user_name
26
+ @user_name ||= `git config user.name`.chomp
27
+ end
23
28
 
24
- def user_name
25
- @user_name ||= `git config user.name`.chomp
26
- end
29
+ def user_email
30
+ @user_email ||= `git config user.email`.chomp
31
+ end
27
32
 
28
- def user_email
29
- @user_email ||= `git config user.email`.chomp
30
- end
33
+ private
31
34
 
32
- private
35
+ def root
36
+ @root ||= Pathname.new(File.expand_path("../", __dir__))
37
+ end
33
38
 
34
- def root
35
- @root ||= Pathname.new(File.expand_path("../", __dir__))
36
- end
39
+ def template_file(filename)
40
+ [
41
+ root.join("theme_template", "#{filename}.erb"),
42
+ root.join("theme_template", filename.to_s),
43
+ ].find(&:exist?)
44
+ end
37
45
 
38
- def template_file(filename)
39
- [
40
- root.join("theme_template", "#{filename}.erb"),
41
- root.join("theme_template", filename.to_s),
42
- ].find(&:exist?)
43
- end
46
+ def template(filename)
47
+ erb.render(template_file(filename).read)
48
+ end
44
49
 
45
- def template(filename)
46
- erb.render(template_file(filename).read)
47
- end
50
+ def erb
51
+ @erb ||= ERBRenderer.new(self)
52
+ end
48
53
 
49
- def erb
50
- @erb ||= ERBRenderer.new(self)
51
- end
54
+ def mkdir_p(directories)
55
+ Array(directories).each do |directory|
56
+ full_path = path.join(directory)
57
+ Jekyll.logger.info "create", full_path.to_s
58
+ FileUtils.mkdir_p(full_path)
59
+ end
60
+ end
52
61
 
53
- def mkdir_p(directories)
54
- Array(directories).each do |directory|
55
- full_path = path.join(directory)
62
+ def write_file(filename, contents)
63
+ full_path = path.join(filename)
56
64
  Jekyll.logger.info "create", full_path.to_s
57
- FileUtils.mkdir_p(full_path)
65
+ File.write(full_path, contents)
58
66
  end
59
- end
60
-
61
- def write_file(filename, contents)
62
- full_path = path.join(filename)
63
- Jekyll.logger.info "create", full_path.to_s
64
- File.write(full_path, contents)
65
- end
66
67
 
67
- def create_directories
68
- mkdir_p(SCAFFOLD_DIRECTORIES)
69
- end
68
+ def create_directories
69
+ mkdir_p(SCAFFOLD_DIRECTORIES)
70
+ end
70
71
 
71
- def create_starter_files
72
- %w(page post default).each do |layout|
73
- write_file("_layouts/#{layout}.html", template("_layouts/#{layout}.html"))
72
+ def create_starter_files
73
+ %w(page post default).each do |layout|
74
+ write_file("_layouts/#{layout}.html", template("_layouts/#{layout}.html"))
75
+ end
74
76
  end
75
- end
76
77
 
77
- def create_gemspec
78
- write_file("Gemfile", template("Gemfile"))
79
- write_file("#{name}.gemspec", template("theme.gemspec"))
80
- end
78
+ def create_gemspec
79
+ write_file("Gemfile", template("Gemfile"))
80
+ write_file("#{name}.gemspec", template("theme.gemspec"))
81
+ end
81
82
 
82
- def create_accessories
83
- accessories = %w(README.md LICENSE.txt)
84
- accessories << "CODE_OF_CONDUCT.md" if code_of_conduct
85
- accessories.each do |filename|
86
- write_file(filename, template(filename))
83
+ def create_accessories
84
+ accessories = %w(README.md LICENSE.txt)
85
+ accessories << "CODE_OF_CONDUCT.md" if code_of_conduct
86
+ accessories.each do |filename|
87
+ write_file(filename, template(filename))
88
+ end
87
89
  end
88
- end
89
90
 
90
- def initialize_git_repo
91
- Jekyll.logger.info "initialize", path.join(".git").to_s
92
- Dir.chdir(path.to_s) { `git init` }
93
- write_file(".gitignore", template("gitignore"))
94
- end
91
+ def initialize_git_repo
92
+ Jekyll.logger.info "initialize", path.join(".git").to_s
93
+ Dir.chdir(path.to_s) { `git init` }
94
+ write_file(".gitignore", template("gitignore"))
95
+ end
95
96
 
96
- class ERBRenderer
97
- extend Forwardable
97
+ class ERBRenderer
98
+ extend Forwardable
98
99
 
99
- def_delegator :@theme_builder, :name, :theme_name
100
- def_delegator :@theme_builder, :user_name, :user_name
101
- def_delegator :@theme_builder, :user_email, :user_email
100
+ def_delegator :@theme_builder, :name, :theme_name
101
+ def_delegator :@theme_builder, :user_name, :user_name
102
+ def_delegator :@theme_builder, :user_email, :user_email
102
103
 
103
- def initialize(theme_builder)
104
- @theme_builder = theme_builder
105
- end
104
+ def initialize(theme_builder)
105
+ @theme_builder = theme_builder
106
+ end
106
107
 
107
- def jekyll_version_with_minor
108
- Jekyll::VERSION.split(".").take(2).join(".")
109
- end
108
+ def jekyll_version_with_minor
109
+ Jekyll::VERSION.split(".").take(2).join(".")
110
+ end
110
111
 
111
- def theme_directories
112
- SCAFFOLD_DIRECTORIES
113
- end
112
+ def theme_directories
113
+ SCAFFOLD_DIRECTORIES
114
+ end
114
115
 
115
- def render(contents)
116
- ERB.new(contents).result binding
116
+ def render(contents)
117
+ ERB.new(contents).result binding
118
+ end
117
119
  end
118
120
  end
119
121
  end
data/lib/jekyll/url.rb CHANGED
@@ -68,6 +68,7 @@ module Jekyll
68
68
  def generate_url_from_hash(template)
69
69
  @placeholders.inject(template) do |result, token|
70
70
  break result if result.index(":").nil?
71
+
71
72
  if token.last.nil?
72
73
  # Remove leading "/" to avoid generating urls with `//`
73
74
  result.gsub("/:#{token.first}", "")
@@ -98,8 +99,8 @@ module Jekyll
98
99
  winner = pool.find { |key| @placeholders.key?(key) }
99
100
  if winner.nil?
100
101
  raise NoMethodError,
101
- "The URL template doesn't have #{pool.join(" or ")} keys. "\
102
- "Check your permalink template!"
102
+ "The URL template doesn't have #{pool.join(" or ")} keys. "\
103
+ "Check your permalink template!"
103
104
  end
104
105
 
105
106
  value = @placeholders[winner]
@@ -6,7 +6,7 @@ module Jekyll
6
6
  extend self
7
7
 
8
8
  ESCAPE = format("%c", 27)
9
- MATCH = %r!#{ESCAPE}\[(?:\d+)(?:;\d+)*(j|k|m|s|u|A|B|G)|\e\(B\e\[m!ix
9
+ MATCH = %r!#{ESCAPE}\[(?:\d+)(?:;\d+)*(j|k|m|s|u|A|B|G)|\e\(B\e\[m!ix.freeze
10
10
  COLORS = {
11
11
  :red => 31,
12
12
  :green => 32,
@@ -21,7 +21,6 @@ module Jekyll
21
21
  [stdin, stdout, stderr].each(&:close)
22
22
  [process.value, out + err]
23
23
  end
24
-
25
24
  end
26
25
  end
27
26
  end
@@ -3,7 +3,6 @@
3
3
  module Jekyll
4
4
  module Utils
5
5
  module Internet
6
-
7
6
  # Public: Determine whether the present device has a connection to
8
7
  # the Internet. This allows plugin writers which require the outside
9
8
  # world to have a neat fallback mechanism for offline building.
@@ -18,13 +17,13 @@ module Jekyll
18
17
  # end
19
18
  #
20
19
  # Returns true if a DNS call can successfully be made, or false if not.
20
+
21
21
  module_function
22
+
22
23
  def connected?
23
24
  !dns("example.com").nil?
24
25
  end
25
26
 
26
- private
27
- module_function
28
27
  def dns(domain)
29
28
  require "resolv"
30
29
  Resolv::DNS.open do |resolver|
@@ -33,7 +32,6 @@ module Jekyll
33
32
  rescue Resolv::ResolvError, Resolv::ResolvTimeout
34
33
  nil
35
34
  end
36
-
37
35
  end
38
36
  end
39
37
  end
@@ -31,7 +31,7 @@ module Jekyll
31
31
  # --
32
32
 
33
33
  alias_method :really_windows?, \
34
- :vanilla_windows?
34
+ :vanilla_windows?
35
35
 
36
36
  #
37
37
 
@@ -68,14 +68,14 @@ module Jekyll
68
68
  #
69
69
 
70
70
  private
71
+
71
72
  def proc_version
72
- @proc_version ||= begin
73
- File.read(
74
- "/proc/version"
75
- ).downcase
76
- rescue Errno::ENOENT
77
- nil
78
- end
73
+ @proc_version ||=
74
+ begin
75
+ Pathutil.new("/proc/version").read
76
+ rescue Errno::ENOENT, Errno::EACCES
77
+ nil
78
+ end
79
79
  end
80
80
  end
81
81
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "thread"
4
-
5
3
  module Jekyll
6
4
  module Utils
7
5
  # Based on the pattern and code from
@@ -25,9 +23,7 @@ module Jekyll
25
23
 
26
24
  def wait
27
25
  @lock.synchronize do
28
- unless @flag
29
- @cond.wait(@lock)
30
- end
26
+ @cond.wait(@lock) unless @flag
31
27
  end
32
28
  end
33
29
  end