classPrymoduleDefaultCommandsDocumentation=Pry::CommandSet.newdocommand"ri","View ri documentation. e.g `ri Array#each`"do|*args|run".ri",*argsendcommand"show-doc","Show the comments above METH. Type `show-doc --help` for more info. Aliases: \?",:shellwords=>falsedo|*args|opts,meth=parse_options!(args,:method_object)do|opt|opt.bannerunindent<<-USAGE
Usage: show-doc [OPTIONS] [METH]
Show the comments above method METH. Tries instance methods first and then methods by default.
e.g show-doc hello_method
USAGEopt.on:f,:flood,"Do not use a pager to view text longer than one screen."endraisePry::CommandError,"No documentation found."ifmeth.doc.nil?||meth.doc.empty?doc=process_comment_markup(meth.doc,meth.source_type)output.putsmake_header(meth,doc)output.puts"#{text.bold("Owner:")}#{meth.owner||"N/A"}"output.puts"#{text.bold("Visibility:")}#{meth.visibility}"output.puts"#{text.bold("Signature:")}#{meth.signature}"output.putsrender_output(opts.present?(:flood),false,doc)endalias_command"?","show-doc"command"stat","View method information and set _file_ and _dir_ locals. Type `stat --help` for more info.",:shellwords=>falsedo|*args|target=target()opts,meth=parse_options!(args,:method_object)do|opt|opt.bannerunindent<<-USAGE
Usage: stat [OPTIONS] [METH]
Show method information for method METH and set _file_ and _dir_ locals.
e.g: stat hello_method
USAGEendoutput.putsunindent<<-EOS
Method Information:
--
Name: #{meth.name}
Owner: #{meth.owner?meth.owner:"Unknown"}
Visibility: #{meth.visibility}
Type: #{meth.is_a?(::Method)?"Bound":"Unbound"}
Arity: #{meth.arity}
Method Signature: #{meth.signature}
Source Location: #{meth.source_location?meth.source_location.join(":"):"Not found."} EOSendcommand"gist","Gist a method or expression history to github. Type `gist --help` for more info.",:requires_gem=>"gist",:shellwords=>falsedo|*args|require'gist'target=target()opts=parse_options!(args)do|opt|opt.bannerunindent<<-USAGE
Usage: gist [OPTIONS] [METH]
Gist method (doc or source) or input expression to github.
Ensure the `gist` gem is properly working before use. http://github.com/defunkt/gist for instructions.
e.g: gist -m my_method
e.g: gist -d my_method
e.g: gist -i 1..10
USAGEopt.on:d,:doc,"Gist a method's documentation.",trueopt.on:m,:method,"Gist a method's source.",trueopt.on:p,:public,"Create a public gist (default: false)",:default=>falseopt.on:i,:in,"Gist entries from Pry's input expression history. Takes an index or range.",:optional=>true,:as=>Range,:default=>-5..-1endtype_map={:ruby=>"rb",:c=>"c",:plain=>"plain"}ifopts.present?(:in)code_type=:rubycontent=""normalized_range=absolute_index_range(opts[:i],_pry_.input_array.length)input_items=_pry_.input_array[normalized_range]||[]input_items.each_with_index.mapdo|code,index|corrected_index=index+normalized_range.firstifcode&&code!=""content<<codecontent<<"#{comment_expression_result_for_gist(Pry.config.gist.inspecter.call(_pry_.output_array[corrected_index]))}"ifcode!~/;\Z/endendelsifopts.present?(:doc)meth=get_method_or_raise(opts[:d],target,{})content=meth.doccode_type=meth.source_typetext.no_colordocontent=process_comment_markup(content,code_type)endcode_type=:plainelsifopts.present?(:method)meth=get_method_or_raise(opts[:m],target,{})content=meth.sourcecode_type=meth.source_typeend# prevent Gist from exiting the session on errorbeginlink=Gist.write([:extension=>".#{type_map[code_type]}",:input=>content],!opts[:p])rescueSystemExitendiflinkGist.copy(link)output.puts"Gist created at #{link} and added to clipboard."endendhelpersdodefcomment_expression_result_for_gist(result)content=""result.lines.each_with_indexdo|line,index|ifindex==0content<<"# => #{line}"elsecontent<<"# #{line}"endendcontentendendendendend