From d0934b8fbd8173aee8a52af3b7f94ff24078dfbc Mon Sep 17 00:00:00 2001 From: Jane Davis <61095764+janie314@users.noreply.github.com> Date: Tue, 7 Jan 2025 04:55:42 -0600 Subject: [PATCH] Ruby 3.4.1 compatability (#735) * Add logger and observer as explicit dependencies * Add explicit rake dependency * Add nil handling to node_range method * Add explicit ostruct dependency * Update deprecated JaroWinkler distance method --------- Co-authored-by: 12ball --- lib/solargraph/parser/rubyvm/class_methods.rb | 4 ++++ lib/solargraph/pin/search.rb | 2 +- solargraph.gemspec | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/solargraph/parser/rubyvm/class_methods.rb b/lib/solargraph/parser/rubyvm/class_methods.rb index a208f4e8e..2533eb79e 100644 --- a/lib/solargraph/parser/rubyvm/class_methods.rb +++ b/lib/solargraph/parser/rubyvm/class_methods.rb @@ -108,9 +108,13 @@ def is_ast_node? node end def node_range node + if node.nil? + nil + else st = Position.new(node.first_lineno - 1, node.first_column) en = Position.new(node.last_lineno - 1, node.last_column) Range.new(st, en) + end end def recipient_node tree diff --git a/lib/solargraph/pin/search.rb b/lib/solargraph/pin/search.rb index 5564fac7c..da1de116d 100644 --- a/lib/solargraph/pin/search.rb +++ b/lib/solargraph/pin/search.rb @@ -49,7 +49,7 @@ def do_query # @return [Float] def fuzzy_string_match str1, str2 return (1.0 + (str2.length.to_f / str1.length.to_f)) if str1.downcase.include?(str2.downcase) - JaroWinkler.distance(str1, str2, ignore_case: true) + JaroWinkler.similarity(str1, str2, ignore_case: true) end end end diff --git a/solargraph.gemspec b/solargraph.gemspec index 7be8dcb73..31a80b4c9 100755 --- a/solargraph.gemspec +++ b/solargraph.gemspec @@ -29,8 +29,11 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'diff-lcs', '~> 1.4' s.add_runtime_dependency 'e2mmap' s.add_runtime_dependency 'jaro_winkler', '~> 1.5' + s.add_runtime_dependency 'logger', '~> 1.6' s.add_runtime_dependency 'kramdown', '~> 2.3' s.add_runtime_dependency 'kramdown-parser-gfm', '~> 1.1' + s.add_runtime_dependency 'observer', '~> 0.1' + s.add_runtime_dependency 'ostruct', '~> 0.6' s.add_runtime_dependency 'parser', '~> 3.0' s.add_runtime_dependency 'rbs', '~> 2.0' s.add_runtime_dependency 'reverse_markdown', '~> 2.0' @@ -41,6 +44,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'pry' s.add_development_dependency 'public_suffix', '~> 3.1' + s.add_development_dependency 'rake', '~> 13.2' s.add_development_dependency 'rspec', '~> 3.5' s.add_development_dependency 'simplecov', '~> 0.14' s.add_development_dependency 'webmock', '~> 3.6'