From f5619c3916929578606f215b3999e9655a300d37 Mon Sep 17 00:00:00 2001
From: Bohdan Zhuravel <bohdan@zhuravel.bz>
Date: Mon, 11 Nov 2024 13:31:53 +0200
Subject: [PATCH] Address code review remarks

---
 Appraisals                        | 42 +++++--------------------------
 Gemfile                           | 11 --------
 gemfiles/activerecord_6.0.gemfile | 17 +------------
 gemfiles/activerecord_6.1.gemfile | 17 +------------
 gemfiles/activerecord_7.0.gemfile | 18 ++-----------
 gemfiles/activerecord_7.1.gemfile | 18 ++-----------
 gemfiles/activerecord_7.2.gemfile | 18 ++-----------
 gemfiles/activerecord_8.0.gemfile | 18 ++-----------
 temping.gemspec                   | 21 ++++++++++++++++
 9 files changed, 37 insertions(+), 143 deletions(-)

diff --git a/Appraisals b/Appraisals
index 4b339f0..e0ac287 100644
--- a/Appraisals
+++ b/Appraisals
@@ -1,69 +1,39 @@
 appraise "activerecord-6.0" do
   gem "activerecord", "~> 6.0.0"
   gem "activesupport", "~> 6.0.0"
-
-  platforms :ruby, :truffleruby do
-    gem "sqlite3", "~> 1.4.0"
-    gem "pg", "~> 1.5.8"
-    gem "mysql2", "~> 0.5.6"
-  end
+  gem "sqlite3", "~> 1.4", platforms: [:ruby, :truffleruby]
 end
 
 appraise "activerecord-6.1" do
   gem "activerecord", "~> 6.1.0"
   gem "activesupport", "~> 6.1.0"
-
-  platforms :ruby, :truffleruby do
-    gem "sqlite3", "~> 1.4.0"
-    gem "pg", "~> 1.5.8"
-    gem "mysql2", "~> 0.5.6"
-  end
+  gem "sqlite3", "~> 1.4", platforms: [:ruby, :truffleruby]
 end
 
 appraise "activerecord-7.0" do
   gem "activerecord", "~> 7.0.0"
   gem "activesupport", "~> 7.0.0"
+  gem "sqlite3", "~> 1.6", platforms: [:ruby, :truffleruby]
   gem "standard", "~> 1.31"
-
-  platforms :ruby, :truffleruby do
-    gem "sqlite3", "~> 1.6.0"
-    gem "pg", "~> 1.5.8"
-    gem "mysql2", "~> 0.5.6"
-  end
 end
 
 appraise "activerecord-7.1" do
   gem "activerecord", "~> 7.1.0"
   gem "activesupport", "~> 7.1.0"
+  gem "sqlite3", "~> 1.6", platforms: [:ruby, :truffleruby]
   gem "standard", "~> 1.31"
-
-  platforms :ruby, :truffleruby do
-    gem "sqlite3", "~> 1.6.0"
-    gem "pg", "~> 1.5.8"
-    gem "mysql2", "~> 0.5.6"
-  end
 end
 
 appraise "activerecord-7.2" do
   gem "activerecord", "~> 7.2.0"
   gem "activesupport", "~> 7.2.0"
+  gem "sqlite3", "~> 2.0", platforms: [:ruby, :truffleruby]
   gem "standard", "~> 1.31"
-
-  platforms :ruby, :truffleruby do
-    gem "sqlite3", "~> 2.0.0"
-    gem "pg", "~> 1.5.8"
-    gem "mysql2", "~> 0.5.6"
-  end
 end
 
 appraise "activerecord-8.0" do
   gem "activerecord", "~> 8.0.0"
   gem "activesupport", "~> 8.0.0"
+  gem "sqlite3", "~> 2.1", platforms: [:ruby, :truffleruby]
   gem "standard", "~> 1.31"
-
-  platforms :ruby, :truffleruby do
-    gem "sqlite3", "~> 2.2.0"
-    gem "pg", "~> 1.5.8"
-    gem "mysql2", "~> 0.5.6"
-  end
 end
diff --git a/Gemfile b/Gemfile
index a1369cb..b4e2a20 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,14 +1,3 @@
 source "https://rubygems.org"
 
 gemspec
-
-gem "rspec", "~> 3.13"
-gem "rake", "~> 13.0"
-gem "simplecov", "~> 0.21"
-gem "standard", ">= 0.0.1", "< 2.0"
-
-platforms :jruby do
-  gem "activerecord-jdbcsqlite3-adapter", ">= 60.0"
-  gem "activerecord-jdbcpostgresql-adapter", ">= 60.0"
-  gem "activerecord-jdbcmysql-adapter", ">= 60.0"
-end
diff --git a/gemfiles/activerecord_6.0.gemfile b/gemfiles/activerecord_6.0.gemfile
index 72fd478..10cc96d 100644
--- a/gemfiles/activerecord_6.0.gemfile
+++ b/gemfiles/activerecord_6.0.gemfile
@@ -2,23 +2,8 @@
 
 source "https://rubygems.org"
 
-gem "rspec", "~> 3.13"
-gem "rake", "~> 13.0"
-gem "simplecov", "~> 0.21"
-gem "standard", ">= 0.0.1", "< 2.0"
 gem "activerecord", "~> 6.0.0"
 gem "activesupport", "~> 6.0.0"
-
-platforms :jruby do
-  gem "activerecord-jdbcsqlite3-adapter", ">= 60.0"
-  gem "activerecord-jdbcpostgresql-adapter", ">= 60.0"
-  gem "activerecord-jdbcmysql-adapter", ">= 60.0"
-end
-
-platforms :ruby, :truffleruby do
-  gem "sqlite3", "~> 1.4.0"
-  gem "pg", "~> 1.5.8"
-  gem "mysql2", "~> 0.5.6"
-end
+gem "sqlite3", "~> 1.4", platforms: [:ruby, :truffleruby]
 
 gemspec path: "../"
diff --git a/gemfiles/activerecord_6.1.gemfile b/gemfiles/activerecord_6.1.gemfile
index e743e58..c4e1a1f 100644
--- a/gemfiles/activerecord_6.1.gemfile
+++ b/gemfiles/activerecord_6.1.gemfile
@@ -2,23 +2,8 @@
 
 source "https://rubygems.org"
 
-gem "rspec", "~> 3.13"
-gem "rake", "~> 13.0"
-gem "simplecov", "~> 0.21"
-gem "standard", ">= 0.0.1", "< 2.0"
 gem "activerecord", "~> 6.1.0"
 gem "activesupport", "~> 6.1.0"
-
-platforms :jruby do
-  gem "activerecord-jdbcsqlite3-adapter", ">= 60.0"
-  gem "activerecord-jdbcpostgresql-adapter", ">= 60.0"
-  gem "activerecord-jdbcmysql-adapter", ">= 60.0"
-end
-
-platforms :ruby, :truffleruby do
-  gem "sqlite3", "~> 1.4.0"
-  gem "pg", "~> 1.5.8"
-  gem "mysql2", "~> 0.5.6"
-end
+gem "sqlite3", "~> 1.4", platforms: [:ruby, :truffleruby]
 
 gemspec path: "../"
diff --git a/gemfiles/activerecord_7.0.gemfile b/gemfiles/activerecord_7.0.gemfile
index 0b7d0a5..8118937 100644
--- a/gemfiles/activerecord_7.0.gemfile
+++ b/gemfiles/activerecord_7.0.gemfile
@@ -2,23 +2,9 @@
 
 source "https://rubygems.org"
 
-gem "rspec", "~> 3.13"
-gem "rake", "~> 13.0"
-gem "simplecov", "~> 0.21"
-gem "standard", "~> 1.31"
 gem "activerecord", "~> 7.0.0"
 gem "activesupport", "~> 7.0.0"
-
-platforms :jruby do
-  gem "activerecord-jdbcsqlite3-adapter", ">= 60.0"
-  gem "activerecord-jdbcpostgresql-adapter", ">= 60.0"
-  gem "activerecord-jdbcmysql-adapter", ">= 60.0"
-end
-
-platforms :ruby, :truffleruby do
-  gem "sqlite3", "~> 1.6.0"
-  gem "pg", "~> 1.5.8"
-  gem "mysql2", "~> 0.5.6"
-end
+gem "sqlite3", "~> 1.6", platforms: [:ruby, :truffleruby]
+gem "standard", "~> 1.31"
 
 gemspec path: "../"
diff --git a/gemfiles/activerecord_7.1.gemfile b/gemfiles/activerecord_7.1.gemfile
index 8dc2c21..48cd5cf 100644
--- a/gemfiles/activerecord_7.1.gemfile
+++ b/gemfiles/activerecord_7.1.gemfile
@@ -2,23 +2,9 @@
 
 source "https://rubygems.org"
 
-gem "rspec", "~> 3.13"
-gem "rake", "~> 13.0"
-gem "simplecov", "~> 0.21"
-gem "standard", "~> 1.31"
 gem "activerecord", "~> 7.1.0"
 gem "activesupport", "~> 7.1.0"
-
-platforms :jruby do
-  gem "activerecord-jdbcsqlite3-adapter", ">= 60.0"
-  gem "activerecord-jdbcpostgresql-adapter", ">= 60.0"
-  gem "activerecord-jdbcmysql-adapter", ">= 60.0"
-end
-
-platforms :ruby, :truffleruby do
-  gem "sqlite3", "~> 1.6.0"
-  gem "pg", "~> 1.5.8"
-  gem "mysql2", "~> 0.5.6"
-end
+gem "sqlite3", "~> 1.6", platforms: [:ruby, :truffleruby]
+gem "standard", "~> 1.31"
 
 gemspec path: "../"
diff --git a/gemfiles/activerecord_7.2.gemfile b/gemfiles/activerecord_7.2.gemfile
index 5f78b1d..df0e4fb 100644
--- a/gemfiles/activerecord_7.2.gemfile
+++ b/gemfiles/activerecord_7.2.gemfile
@@ -2,23 +2,9 @@
 
 source "https://rubygems.org"
 
-gem "rspec", "~> 3.13"
-gem "rake", "~> 13.0"
-gem "simplecov", "~> 0.21"
-gem "standard", "~> 1.31"
 gem "activerecord", "~> 7.2.0"
 gem "activesupport", "~> 7.2.0"
-
-platforms :jruby do
-  gem "activerecord-jdbcsqlite3-adapter", ">= 60.0"
-  gem "activerecord-jdbcpostgresql-adapter", ">= 60.0"
-  gem "activerecord-jdbcmysql-adapter", ">= 60.0"
-end
-
-platforms :ruby, :truffleruby do
-  gem "sqlite3", "~> 2.0.0"
-  gem "pg", "~> 1.5.8"
-  gem "mysql2", "~> 0.5.6"
-end
+gem "sqlite3", "~> 2.0", platforms: [:ruby, :truffleruby]
+gem "standard", "~> 1.31"
 
 gemspec path: "../"
diff --git a/gemfiles/activerecord_8.0.gemfile b/gemfiles/activerecord_8.0.gemfile
index d15854c..a4dd300 100644
--- a/gemfiles/activerecord_8.0.gemfile
+++ b/gemfiles/activerecord_8.0.gemfile
@@ -2,23 +2,9 @@
 
 source "https://rubygems.org"
 
-gem "rspec", "~> 3.13"
-gem "rake", "~> 13.0"
-gem "simplecov", "~> 0.21"
-gem "standard", "~> 1.31"
 gem "activerecord", "~> 8.0.0"
 gem "activesupport", "~> 8.0.0"
-
-platforms :jruby do
-  gem "activerecord-jdbcsqlite3-adapter", ">= 60.0"
-  gem "activerecord-jdbcpostgresql-adapter", ">= 60.0"
-  gem "activerecord-jdbcmysql-adapter", ">= 60.0"
-end
-
-platforms :ruby, :truffleruby do
-  gem "sqlite3", "~> 2.2.0"
-  gem "pg", "~> 1.5.8"
-  gem "mysql2", "~> 0.5.6"
-end
+gem "sqlite3", "~> 2.1", platforms: [:ruby, :truffleruby]
+gem "standard", "~> 1.31"
 
 gemspec path: "../"
diff --git a/temping.gemspec b/temping.gemspec
index 2057d59..c3ab11b 100644
--- a/temping.gemspec
+++ b/temping.gemspec
@@ -15,4 +15,25 @@ Gem::Specification.new do |s|
   s.add_dependency "activesupport", ">= 6.0", "< 8.1"
 
   s.add_development_dependency "appraisal", "~> 2.5"
+
+  skipped_adapters = ENV["SKIPPED_ADAPTERS"].to_s.downcase
+  sqlite_skipped = skipped_adapters.include?("sqlite")
+  postgresql_skipped = skipped_adapters.include?("postgres")
+  mysql_skipped = skipped_adapters.include?("mysql")
+  if RUBY_PLATFORM.include?("java")
+    s.add_development_dependency "activerecord-jdbcsqlite3-adapter", ">= 60.0" unless sqlite_skipped
+    unless postgresql_skipped
+      s.add_development_dependency "activerecord-jdbcpostgresql-adapter", ">= 60.0"
+    end
+    s.add_development_dependency "activerecord-jdbcmysql-adapter", ">= 60.0" unless mysql_skipped
+  else
+    s.add_development_dependency "sqlite3", ">= 1.3", "< 3.0" unless sqlite_skipped
+    s.add_development_dependency "pg", ">= 1.2", "< 2.0" unless postgresql_skipped
+    s.add_development_dependency "mysql2", "~> 0.5" unless mysql_skipped
+  end
+
+  s.add_development_dependency "rspec", "~> 3.13"
+  s.add_development_dependency "rake", "~> 13.0"
+  s.add_development_dependency "simplecov", "~> 0.21"
+  s.add_development_dependency "standard", ">= 0.0.1", "< 2.0"
 end