From b473e19a13819638f6a4ff0504ba4da40c71a6aa Mon Sep 17 00:00:00 2001 From: Olly Headey Date: Mon, 9 Oct 2023 20:03:55 +0100 Subject: [PATCH 1/2] Fix deprecation warnings in 3.5.0 --- lib/tailwindcss/commands.rb | 4 ++-- test/lib/tailwindcss/commands_test.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/tailwindcss/commands.rb b/lib/tailwindcss/commands.rb index 0020a97..1a4b085 100644 --- a/lib/tailwindcss/commands.rb +++ b/lib/tailwindcss/commands.rb @@ -34,7 +34,7 @@ def executable(exe_path: DEFAULT_DIR) MESSAGE end else - if Tailwindcss::Upstream::NATIVE_PLATFORMS.keys.none? { |p| Gem::Platform.match(Gem::Platform.new(p)) } + if Tailwindcss::Upstream::NATIVE_PLATFORMS.keys.none? { |p| Gem::Platform.match_gem?(Gem::Platform.new(p), nil) } raise UnsupportedPlatformException, <<~MESSAGE tailwindcss-rails does not support the #{platform} platform Please install tailwindcss following instructions at https://tailwindcss.com/docs/installation @@ -42,7 +42,7 @@ def executable(exe_path: DEFAULT_DIR) end exe_file = Dir.glob(File.expand_path(File.join(exe_path, "*", "tailwindcss"))).find do |f| - Gem::Platform.match(Gem::Platform.new(File.basename(File.dirname(f)))) + Gem::Platform.match_gem?(Gem::Platform.new(File.basename(File.dirname(f))), nil) end end diff --git a/test/lib/tailwindcss/commands_test.rb b/test/lib/tailwindcss/commands_test.rb index 142efcf..d09d8a9 100644 --- a/test/lib/tailwindcss/commands_test.rb +++ b/test/lib/tailwindcss/commands_test.rb @@ -7,7 +7,7 @@ def mock_exe_directory(platform) FileUtils.mkdir(File.join(dir, platform)) path = File.join(dir, platform, "tailwindcss") FileUtils.touch(path) - Gem::Platform.stub(:match, true) do + Gem::Platform.stub(:match_gem?, true) do yield(dir, path) end end @@ -35,7 +35,7 @@ def mock_local_tailwindcss_install end test ".executable raises UnsupportedPlatformException when we're not on a supported platform" do - Gem::Platform.stub(:match, false) do # nothing is supported + Gem::Platform.stub(:match_gem?, false) do # nothing is supported assert_raises(Tailwindcss::Commands::UnsupportedPlatformException) do Tailwindcss::Commands.executable end @@ -66,7 +66,7 @@ def mock_local_tailwindcss_install end test ".executable returns the executable in TAILWINDCSS_INSTALL_DIR when we're not on a supported platform" do - Gem::Platform.stub(:match, false) do # nothing is supported + Gem::Platform.stub(:match_gem?, false) do # nothing is supported mock_local_tailwindcss_install do |local_install_dir, expected| result = nil begin From a5dd494944ce1d9271f9a69bb0ea725da2fa89a3 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Tue, 10 Oct 2023 14:48:30 -0400 Subject: [PATCH 2/2] pass the gem name to Gem::Platform.match_gem? Although this argument isn't used in the CRuby implementation, other implementations (specifically TruffleRuby) reserve the right to re-implement this method with special cases for specific gems. More context at rubygems/rubygems#3817 --- lib/tailwindcss/commands.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/tailwindcss/commands.rb b/lib/tailwindcss/commands.rb index 1a4b085..b1367c6 100644 --- a/lib/tailwindcss/commands.rb +++ b/lib/tailwindcss/commands.rb @@ -3,6 +3,7 @@ module Tailwindcss module Commands DEFAULT_DIR = File.expand_path(File.join(__dir__, "..", "..", "exe")) + GEM_NAME = "tailwindcss-rails" # raised when the host platform is not supported by upstream tailwindcss's binary releases class UnsupportedPlatformException < StandardError @@ -34,7 +35,7 @@ def executable(exe_path: DEFAULT_DIR) MESSAGE end else - if Tailwindcss::Upstream::NATIVE_PLATFORMS.keys.none? { |p| Gem::Platform.match_gem?(Gem::Platform.new(p), nil) } + if Tailwindcss::Upstream::NATIVE_PLATFORMS.keys.none? { |p| Gem::Platform.match_gem?(Gem::Platform.new(p), GEM_NAME) } raise UnsupportedPlatformException, <<~MESSAGE tailwindcss-rails does not support the #{platform} platform Please install tailwindcss following instructions at https://tailwindcss.com/docs/installation @@ -42,7 +43,7 @@ def executable(exe_path: DEFAULT_DIR) end exe_file = Dir.glob(File.expand_path(File.join(exe_path, "*", "tailwindcss"))).find do |f| - Gem::Platform.match_gem?(Gem::Platform.new(File.basename(File.dirname(f))), nil) + Gem::Platform.match_gem?(Gem::Platform.new(File.basename(File.dirname(f))), GEM_NAME) end end