From aeff6dd423f123fd72ef9e4cb672980e546d0de0 Mon Sep 17 00:00:00 2001 From: Peter Law Date: Thu, 5 Jan 2023 23:05:51 +0000 Subject: [PATCH 1/5] Minimal support for Ruby 3 This isn't officially supported by Jekyll and is a bit hacky, so I'm deliberately not documenting the support, however as recent Ubuntu versions now ship with Ruby 3 (not 2.7) and Jekyll isn't showing any signs of moving towards supporting Ruby 3 we're not left with many alternatives. This works around: - https://github.com/github/pages-gem/issues/752 - https://github.com/envygeeks/pathutil/pull/5 --- Gemfile | 3 +++ Gemfile.lock | 2 ++ Rakefile | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/Gemfile b/Gemfile index 9fc3bfbf..e1158738 100644 --- a/Gemfile +++ b/Gemfile @@ -19,3 +19,6 @@ gem 'html-proofer' # Avoid polling on windows gem 'wdm', '>= 0.1.0' + +# For local Ruby 3 support; works around https://github.com/github/pages-gem/issues/752 +gem "webrick", "~> 1.7" diff --git a/Gemfile.lock b/Gemfile.lock index edca955d..df90f8ce 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -98,6 +98,7 @@ GEM tzinfo-data (1.2018.5) tzinfo (>= 1.0.0) wdm (0.1.1) + webrick (1.7.0) yell (2.2.2) PLATFORMS @@ -118,6 +119,7 @@ DEPENDENCIES tzinfo tzinfo-data wdm (>= 0.1.0) + webrick (~> 1.7) BUNDLED WITH 2.3.6 diff --git a/Rakefile b/Rakefile index ef1fd57d..7026e8ae 100644 --- a/Rakefile +++ b/Rakefile @@ -11,6 +11,10 @@ task :dependencies do sh('bundle config set --local path "gems"') end sh('bundle install') + + # Fix pathutil on Ruby 3; works around https://github.com/envygeeks/pathutil/pull/5 + # as suggested by https://stackoverflow.com/a/73909894/67873 + sh('sed -i.bak "s/, kwd/, **kwd/" $(bundle exec gem which pathutil)') end task :spelling_dependencies do From ef3e8cb827266787d0948bd6e0acafc84cba2fd8 Mon Sep 17 00:00:00 2001 From: Peter Law Date: Sat, 7 Jan 2023 16:04:09 +0000 Subject: [PATCH 2/5] Implement file patching in Ruby for cross platform compatibility --- Rakefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 7026e8ae..a3cc2e21 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +require 'fileutils' + task :clean do sh('rm -rf _site') end @@ -14,7 +16,13 @@ task :dependencies do # Fix pathutil on Ruby 3; works around https://github.com/envygeeks/pathutil/pull/5 # as suggested by https://stackoverflow.com/a/73909894/67873 - sh('sed -i.bak "s/, kwd/, **kwd/" $(bundle exec gem which pathutil)') + pathutil_path = `bundle exec gem which pathutil`.chomp() + content = File.read(pathutil_path).gsub(', kwd', ', **kwd') + backup_path = '#{pathutil_path}.bak' + if File.exist?(backup_path) then + FileUtil.mv(pathutil_path, backup_path) + end + File.write(pathutil_path, content) end task :spelling_dependencies do From 6696920b0409a7ee7447248e24b98ee60fa1d801 Mon Sep 17 00:00:00 2001 From: Peter Law Date: Sun, 8 Jan 2023 17:40:45 +0000 Subject: [PATCH 3/5] Simplify conditional block Co-authored-by: Karina Kwiatek <6197148+raccube@users.noreply.github.com> --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index a3cc2e21..61788c50 100644 --- a/Rakefile +++ b/Rakefile @@ -19,7 +19,7 @@ task :dependencies do pathutil_path = `bundle exec gem which pathutil`.chomp() content = File.read(pathutil_path).gsub(', kwd', ', **kwd') backup_path = '#{pathutil_path}.bak' - if File.exist?(backup_path) then + if File.exist?(backup_path) FileUtil.mv(pathutil_path, backup_path) end File.write(pathutil_path, content) From b2a180d6efcc0653b692eef3854090310c85c723 Mon Sep 17 00:00:00 2001 From: Peter Law Date: Sun, 8 Jan 2023 17:41:13 +0000 Subject: [PATCH 4/5] Make the string interpolation work Co-authored-by: Karina Kwiatek <6197148+raccube@users.noreply.github.com> --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 61788c50..b409fbce 100644 --- a/Rakefile +++ b/Rakefile @@ -18,7 +18,7 @@ task :dependencies do # as suggested by https://stackoverflow.com/a/73909894/67873 pathutil_path = `bundle exec gem which pathutil`.chomp() content = File.read(pathutil_path).gsub(', kwd', ', **kwd') - backup_path = '#{pathutil_path}.bak' + backup_path = "#{pathutil_path}.bak" if File.exist?(backup_path) FileUtil.mv(pathutil_path, backup_path) end From 58d109b08fbb09fa7fca3cc9f784ac8dd1d201a6 Mon Sep 17 00:00:00 2001 From: Peter Law Date: Sun, 8 Jan 2023 19:08:08 +0000 Subject: [PATCH 5/5] Drop redundant backup of this file If needed, reinstalling the gem is easy enough. --- Rakefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Rakefile b/Rakefile index b409fbce..07577d6b 100644 --- a/Rakefile +++ b/Rakefile @@ -18,10 +18,6 @@ task :dependencies do # as suggested by https://stackoverflow.com/a/73909894/67873 pathutil_path = `bundle exec gem which pathutil`.chomp() content = File.read(pathutil_path).gsub(', kwd', ', **kwd') - backup_path = "#{pathutil_path}.bak" - if File.exist?(backup_path) - FileUtil.mv(pathutil_path, backup_path) - end File.write(pathutil_path, content) end