#!/usr/bin/env ruby require 'utils' require 'ollama' include Ollama def fetch_method(filename_linenumber) result = '' source_location = filename_linenumber.source_location lf = Tins::LinesFile.for_filename(source_location.filename, source_location.linenumber) if spaces = lf.match_backward(/^(\s*)def\s+(?:\S+?)(?:\(|\s*$)/)&.first line_number_begin = lf.line_number lf.match_forward(/^#{spaces}end/) line_number_end = lf.line_number line_number_begin.upto(line_number_end) do |line_number| lf.line_number = line_number result << lf.line end end result end def fetch_file(filename_linenumber) source_location = filename_linenumber.source_location File.read(source_location.filename) end filename_linenumber = ARGV.shift or fail "require file_name as second argument" method = fetch_method(filename_linenumber) #file = fetch_file(filename_linenumber) files = Dir['{lib,spec,test}/**/*.rb'] base_url = ENV['OLLAMA_URL'] || 'http://%s' % ENV.fetch('OLLAMA_HOST') model = ENV.fetch('OLLAMA_MODEL', 'llama3.1') #file = File.read(file_name) #call_sites = %x(cscope -L -3 "#{method_name}" $(find . -name '*.rb') | awk '{ print $1 ":" $3 }').lines.map(&:chomp).uniq #methods = call_sites.map { fetch_method(_1) } * ?\n cheatsheet = <] args the arguments passed from input. This # array will be modified. # @param [Array] list the list of strings and symbols. # # The options parsed out of the commandline. # Default options are: # :format => :dot # # @example Reverse a string # "mystring.reverse" #=> "gnirtsym" # # @example Parse a glob of files # YARD.parse('lib/**/*.rb') # # @raise [ExceptionClass] description # # @return [optional, types, ...] description # @return [true] always returns true # @return [void] # @return [String, nil] the contents of our object or nil # if the object has not been filled with data. # # We don't care about the "type" here: # @return the object # # @return [String, #read] a string or object that responds to #read # @return description here with no types ## Anywhere # @todo Add support for Jabberwocky service # There is an open source Jabberwocky library available # at http://somesite.com that can be integrated easily # into the project. ## Blocks # for block {|a, b, c| ... } # @yield [a, b, c] Description of block # # @yieldparam [optional, types, ...] argname description # @yieldreturn [optional, types, ...] description EOT system = <