Internal Release 0.2.4
- remove activesupport as a runtime dependency - use alternative to activesupport/inflector methods - use `json_rpc_handler` gem - add json_rpc_handler to gem dependencies
This commit is contained in:
parent
6004f42573
commit
c5591be30b
1 changed files with 145 additions and 507 deletions
26
lib/model_context_protocol/string_utils.rb
Normal file
26
lib/model_context_protocol/string_utils.rb
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
module ModelContextProtocol
|
||||
module StringUtils
|
||||
extend self
|
||||
|
||||
def handle_from_class_name(class_name)
|
||||
underscore(demodulize(class_name))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def demodulize(path)
|
||||
path.to_s.split("::").last || path.to_s
|
||||
end
|
||||
|
||||
def underscore(camel_cased_word)
|
||||
camel_cased_word.dup
|
||||
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
||||
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
||||
.tr("-", "_")
|
||||
.downcase
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue