class Solargraph::LanguageServer::Message::Extended::CheckGemVersion


is true, notify the client when the gem is up to date.
Notify the client when an update exists. If the ‘verbose` parameter
Check if a more recent version of the Solargraph gem is available.

def process

def process
  o, s = Open3.capture2("gem search solargraph")
  match = o.match(/solargraph \(([\d]*\.[\d]*\.[\d]*)\)/)
  # @todo Error if no match or status code != 0
  available = Gem::Version.new(match[1])
  current = Gem::Version.new(Solargraph::VERSION)
  if available > current
    host.show_message_request "Solagraph gem version #{available} is available.",
                              LanguageServer::MessageTypes::INFO,
                              ['Update now'] do |result|
                                break unless result == 'Update now'
                                o, s = Open3.capture2("gem update solargraph")
                                if s == 0
                                  host.show_message 'Successfully updated the Solargraph gem.', LanguageServer::MessageTypes::INFO
                                else
                                  host.show_message 'An error occurred while updating the gem.', LanguageServer::MessageTypes::ERROR
                                end
                              end
  elsif params['verbose']
    host.show_message "The Solargraph gem is up to date (version #{Solargraph::VERSION})."
  end
  set_result({
    installed: current,
    available: available
  })
end