From 821edd77ea7140bd1b4bd7528349e99483aa91e0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 15 Jul 2025 20:27:57 +0000 Subject: [PATCH 1/3] Initial plan From 7eaa250e25924993bdf56db2e5a754203aabfabe Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 15 Jul 2025 20:37:54 +0000 Subject: [PATCH 2/3] Replace ActiveSupport with strings-inflection for pluralization Co-authored-by: sshaw <17570+sshaw@users.noreply.github.com> --- class2.gemspec | 2 +- lib/class2.rb | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/class2.gemspec b/class2.gemspec index f657b49..dbc5909 100644 --- a/class2.gemspec +++ b/class2.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_dependency "activesupport", ">= 3.2", "< 7" + spec.add_dependency "strings-inflection", "~> 0.1" spec.add_development_dependency "bundler" spec.add_development_dependency "rake", "~> 10.0" diff --git a/lib/class2.rb b/lib/class2.rb index c34d506..4760145 100644 --- a/lib/class2.rb +++ b/lib/class2.rb @@ -3,11 +3,44 @@ require "date" require "time" # for parse() require "json" -require "active_support/core_ext/module" -require "active_support/inflector" +require "strings/inflection" require "class2/version" +# String extensions to replace ActiveSupport inflector functionality +class String + def classify + # Use strings-inflection for singularization, then apply classification logic + # Handle the known issue with "address" -> "addres" + singular = case self + when /(.*)address(es)?$/ + # Handle any word ending with "address" or "addresses" + prefix = $1 + prefix + 'address' + else + Strings::Inflection.singularize(self) + end + + singular.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } + end + + def pluralize + Strings::Inflection.pluralize(self) + end + + def singularize + # Handle known issue with strings-inflection for "address" + case self + when /(.*)address(es)?$/ + # Handle any word ending with "address" or "addresses" + prefix = $1 + prefix + 'address' + else + Strings::Inflection.singularize(self) + end + end +end + no_export = ENV["CLASS2_NO_EXPORT"] unless no_export == "1" From 323dc5b0f06698a5722ba0939892125082b06c2a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 15 Jul 2025 20:41:00 +0000 Subject: [PATCH 3/3] Fix module parent resolution to complete strings-inflection migration Co-authored-by: sshaw <17570+sshaw@users.noreply.github.com> --- lib/class2.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/class2.rb b/lib/class2.rb index 4760145..6c8ee2d 100644 --- a/lib/class2.rb +++ b/lib/class2.rb @@ -284,8 +284,8 @@ def assign_attributes(attributes) name = key.to_s.classify - # parent is deprecated in ActiveSupport 6 and its warning uses Strong#squish! which they don't include! - parent = self.class.respond_to?(:module_parent) ? self.class.module_parent : self.class.parent + # Get the parent module (equivalent to ActiveSupport's module_parent/parent) + parent = self.class.name.split('::')[0..-2].inject(Object) { |mod, name| mod.const_get(name) } next unless parent.const_defined?(name) klass = parent.const_get(name)