From b7fe789d5c10254378ba93172df06f097b8822c8 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Mon, 28 Oct 2024 18:54:18 +0530 Subject: [PATCH] Bring Ruby dependencies up to date (#715) * Bump Sinatra and associates to v4.0 * Bump minimum required Ruby version to Ruby 2.7 * Misc. updates to the Ruby side of dev environment --- .github/workflows/ci.yml | 2 +- Gemfile | 31 +++++++++++++++++++-------- jekyll-admin.gemspec | 28 ++++++------------------ lib/jekyll/commands/serve.rb | 6 ++++-- spec/jekyll-admin/integration_spec.rb | 8 +++---- spec/spec_helper.rb | 4 ++++ 6 files changed, 42 insertions(+), 37 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0427a48d4..a80468f59 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - ruby_version: ["2.7"] + ruby_version: ["2.7", "3.3"] jekyll_version: - "~> 3.9" - "~> 4.0" diff --git a/Gemfile b/Gemfile index 15cbb20ed..0f9befe96 100644 --- a/Gemfile +++ b/Gemfile @@ -2,16 +2,29 @@ source "https://rubygems.org" -# Specify the gem's dependencies in jekyll-admin.gemspec +# Specify the gem's runtime dependencies in jekyll-admin.gemspec gemspec -# To allow testing with specific Jekyll versions -gem "jekyll", ENV["JEKYLL_VERSION"] if ENV["JEKYLL_VERSION"] -gem "kramdown-parser-gfm" if ENV["JEKYLL_VERSION"] == "~> 3.9" +group :development do + gem "gem-release", "~> 0.7" -# Fixture site dependencies -gem "jekyll-redirect-from" + # Fixture site dependencies + gem "jekyll-redirect-from" + gem "sinatra-cross_origin", "~> 0.3" +end -# Site dependencies -gem "jekyll-seo-tag" -gem "jekyll-sitemap" +group :docs do + gem "jekyll-seo-tag" + gem "jekyll-sitemap" +end + +group :test do + # To allow testing with specific Jekyll versions + gem "jekyll", ENV["JEKYLL_VERSION"] if ENV["JEKYLL_VERSION"] + gem "kramdown-parser-gfm" if ENV["JEKYLL_VERSION"] == "~> 3.9" + + gem "rack-test", "~> 2.0" + gem "rake", ">= 10.0" + gem "rspec", "~> 3.4" + gem "rubocop-jekyll", "~> 0.14.0" +end diff --git a/jekyll-admin.gemspec b/jekyll-admin.gemspec index a2d0159a7..f2f388172 100644 --- a/jekyll-admin.gemspec +++ b/jekyll-admin.gemspec @@ -1,8 +1,6 @@ # frozen_string_literal: true -lib = File.expand_path("lib", __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "jekyll-admin/version" +require_relative "lib/jekyll-admin/version" Gem::Specification.new do |spec| spec.name = "jekyll-admin" @@ -17,28 +15,16 @@ Gem::Specification.new do |spec| # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host' # to allow pushing to a single host or delete this section to allow pushing to any host. - if spec.respond_to?(:metadata) - spec.metadata["allowed_push_host"] = "https://rubygems.org" - else - raise "RubyGems 2.0 or newer is required to protect against public gem pushes." - end + spec.metadata["allowed_push_host"] = "https://rubygems.org" spec.files = Dir.glob("lib/**/*").concat(%w(LICENSE README.md)) - spec.bindir = "exe" - spec.executables = spec.files.grep(%r!^exe/!) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.required_ruby_version = ">= 2.3.0" + spec.required_ruby_version = ">= 2.7.0" + spec.required_rubygems_version = ">= 2.7.0" spec.add_dependency "jekyll", ">= 3.7", "< 5.0" - spec.add_dependency "sinatra", ">= 1.4" - spec.add_dependency "sinatra-contrib", ">= 1.4" - - spec.add_development_dependency "bundler", ">= 1.7" - spec.add_development_dependency "gem-release", "~> 0.7" - spec.add_development_dependency "rack-test", "~> 1.0" - spec.add_development_dependency "rake", "~> 10.0" - spec.add_development_dependency "rspec", "~> 3.4" - spec.add_development_dependency "rubocop-jekyll", "~> 0.10.0" - spec.add_development_dependency "sinatra-cross_origin", "~> 0.3" + spec.add_dependency "rackup", "~> 2.0" + spec.add_dependency "sinatra", "~> 4.0" + spec.add_dependency "sinatra-contrib", "~> 4.0" end diff --git a/lib/jekyll/commands/serve.rb b/lib/jekyll/commands/serve.rb index 50e6548e8..5abec8ecc 100644 --- a/lib/jekyll/commands/serve.rb +++ b/lib/jekyll/commands/serve.rb @@ -20,8 +20,10 @@ def start_up_webrick(opts, destination) end def jekyll_admin_monkey_patch - @server.mount "/admin", Rack::Handler::WEBrick, JekyllAdmin::StaticServer - @server.mount "/_api", Rack::Handler::WEBrick, JekyllAdmin::Server + Jekyll::External.require_with_graceful_fail "rackup" + + @server.mount "/admin", Rackup::Handler::WEBrick, JekyllAdmin::StaticServer + @server.mount "/_api", Rackup::Handler::WEBrick, JekyllAdmin::Server Jekyll.logger.info "JekyllAdmin mode:", ENV["RACK_ENV"] || "production" end end diff --git a/spec/jekyll-admin/integration_spec.rb b/spec/jekyll-admin/integration_spec.rb index 36444fbaf..1deab5eff 100644 --- a/spec/jekyll-admin/integration_spec.rb +++ b/spec/jekyll-admin/integration_spec.rb @@ -23,7 +23,7 @@ context "Jekyll site" do let(:path) { "/" } - it "serves the Jekyll site", :skip => Gem.win_platform? do + it "serves the Jekyll site", :skip => skip_integration_condition do expect(response.code).to eql("200") expect(response.body).to match("You're probably looking for") end @@ -32,7 +32,7 @@ context "Admin site" do let(:path) { "/admin" } - it "serves the Jekyll site", :skip => Gem.win_platform? do + it "serves the Jekyll site", :skip => skip_integration_condition do with_index_stubbed do expect(response.code).to eql("200") expect(response.body).to match("Jekyll Admin") @@ -43,14 +43,14 @@ context "API" do let(:path) { "/_api" } - it "serves the Jekyll site", :skip => Gem.win_platform? do + it "serves the Jekyll site", :skip => skip_integration_condition do expect(response.code).to eql("200") expect(response.body).to match("collections_api") end end context "watching" do - it "Jekyll isn't watching", :skip => Gem.win_platform? do + it "Jekyll isn't watching", :skip => skip_integration_condition do File.open(File.join(source, "page.md"), "a") do |f| f.puts "peek-a-boo" end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 050102d0a..e02e51775 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -70,6 +70,10 @@ def write_file(path, content = "---\n---\n\n# test") path end +def skip_integration_condition + Gem.win_platform? || ENV["CI"] +end + RSpec::Matchers.define :be_an_existing_file do match do |path| path = in_source_dir(path)