1. ErrorHighlight::
  2. CoreExt

module ErrorHighlight::CoreExt

Constants

SKIP_TO_S_FOR_SUPER_LOOKUP

This is a marker to let ‘DidYouMean::Correctable#original_message` skip the following method definition of `to_s`. Seegithub.com/ruby/did_you_mean/pull/152

Public Instance Methods

Source
# File lib/error_highlight/core_ext.rb, line 41defdetailed_message(highlight:false,error_highlight:true,**)returnsuperunlesserror_highlightsnippet =generate_snippetifhighlightsnippet =snippet.gsub(/.+/) {"\e[1m"+$&+"\e[m" }endsuper+snippetend
Calls superclass method
Source
# File lib/error_highlight/core_ext.rb, line 56defto_smsg =supersnippet =generate_snippetifsnippet!=""&&!msg.include?(snippet)msg+snippetelsemsgendend
Calls superclass method

Private Instance Methods

Source
# File lib/error_highlight/core_ext.rb, line 5defgenerate_snippetifArgumentError===self&&message=~/\A(?:wrong number of arguments|missing keyword[s]?|unknown keyword[s]?|no keywords accepted)\b/locs =self.backtrace_locationsreturn""iflocs.size<2callee_loc,caller_loc =locscallee_spot =ErrorHighlight.spot(self,backtrace_location:callee_loc,point_type::name)caller_spot =ErrorHighlight.spot(self,backtrace_location:caller_loc,point_type::name)ifcaller_spot&&callee_spot&&caller_loc.path==callee_loc.path&&caller_loc.lineno==callee_loc.lineno&&caller_spot==callee_spotcallee_loc =callee_spot =nilendret =+"\n"    [["caller",caller_loc,caller_spot], ["callee",callee_loc,callee_spot]].eachdo|header,loc,spot|out =niliflocout ="    #{ header }: #{ loc.path }:#{ loc.lineno }"ifspot_,_,snippet,highlight =ErrorHighlight.formatter.message_for(spot).linesout+="\n    | #{ snippet }      #{ highlight }"elseout+="\n    (cannot highlight method definition; try Ruby 3.5 or later)"endendret<<"\n"+outifoutendretelsespot =ErrorHighlight.spot(self)return""unlessspotreturnErrorHighlight.formatter.message_for(spot)endend