utils 0.60.2 → 0.61.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/code_comment +55 -18
- data/lib/utils/version.rb +1 -1
- data/utils.gemspec +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c49b13b25be28b485a47834d29a84674332532062a752b3cae2da1877fca4b38
|
4
|
+
data.tar.gz: a2a8292a3b73c5527915f81218be45a9f48af681827aa342c0d79bfc2172ce9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9233604e38ee99da756da940174ccaadf801fef1be301e4cd58bdbfd076fc448a412e48d436ccb8f607729c521bb32096e459282607815888c582be72cded64a
|
7
|
+
data.tar.gz: 60f5a01d279a88784aa6c717b2baf11396d0fc5703f30b1353144e650bfba49c9b473114f8817fbfd70326358e99cf6952d18c8a301d233035ef1d095e37d18f
|
data/bin/code_comment
CHANGED
@@ -8,7 +8,7 @@ def fetch_method(filename_linenumber)
|
|
8
8
|
result = ''
|
9
9
|
source_location = filename_linenumber.source_location
|
10
10
|
lf = Tins::LinesFile.for_filename(source_location.filename, source_location.linenumber)
|
11
|
-
if spaces = lf.match_backward(/^(\s
|
11
|
+
if spaces = lf.match_backward(/^(\s*|.*?(private|protected)\s+)def\s+(?:\S+?)(?:\(|\s*$)/)&.first
|
12
12
|
line_number_begin = lf.line_number
|
13
13
|
lf.match_forward(/^#{spaces}end/)
|
14
14
|
line_number_end = lf.line_number
|
@@ -26,11 +26,12 @@ def fetch_file(filename_linenumber)
|
|
26
26
|
end
|
27
27
|
|
28
28
|
filename_linenumber = ARGV.shift or fail "require file_name as second argument"
|
29
|
-
method
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
method = fetch_method(filename_linenumber)
|
30
|
+
method_indent = method[/\A( *)/, 1].size
|
31
|
+
#file = fetch_file(filename_linenumber)
|
32
|
+
files = Dir['{lib,spec,test}/**/*.rb']
|
33
|
+
base_url = ENV['OLLAMA_URL'] || 'http://%s' % ENV.fetch('OLLAMA_HOST')
|
34
|
+
model = ENV.fetch('OLLAMA_MODEL', 'llama3.2')
|
34
35
|
#file = File.read(file_name)
|
35
36
|
#call_sites = %x(cscope -L -3 "#{method_name}" $(find . -name '*.rb') | awk '{ print $1 ":" $3 }').lines.map(&:chomp).uniq
|
36
37
|
#methods = call_sites.map { fetch_method(_1) } * ?\n
|
@@ -86,7 +87,10 @@ documentation later.
|
|
86
87
|
EOT
|
87
88
|
|
88
89
|
system = <<EOT
|
89
|
-
|
90
|
+
Provide high-quality YARD comments for the given Ruby method, including a brief
|
91
|
+
description of its purpose, parameters, raised exceptions (and why), and
|
92
|
+
return values, assuming an expert-level understanding of the programming
|
93
|
+
concepts involved.
|
90
94
|
EOT
|
91
95
|
system = nil
|
92
96
|
|
@@ -95,20 +99,52 @@ Analyze this code:
|
|
95
99
|
|
96
100
|
#{files.map { File.read(_1) } * ?\n}
|
97
101
|
|
98
|
-
|
102
|
+
Here's an example for how you should document a method.
|
103
|
+
|
104
|
+
# The foo method computes the bar result by processing…
|
105
|
+
# then it returns the result.
|
106
|
+
#
|
107
|
+
# @param first [ String ] the foo string
|
108
|
+
# @param second [ Integer ] the number of bars lengthy detailed mutltiline
|
109
|
+
# detailed explanation including a newline.
|
110
|
+
# @param third [ TrueClass, FalseClass ]
|
111
|
+
#
|
112
|
+
# @yield [ a, b ]
|
113
|
+
#
|
114
|
+
# @raise [ ArgumentError ] if block argument wasn't provided
|
115
|
+
# @raise [ ArgumentError ] if second parameter was too small.
|
116
|
+
#
|
117
|
+
# @example
|
118
|
+
# bar.foo("blub", 4) { |a, b| … } #=> …
|
119
|
+
#
|
120
|
+
# @return [ ProcessResult ]
|
121
|
+
def foo(first, second, third: false, &block)
|
122
|
+
block or raise ArgumentError, 'no &block'
|
123
|
+
a = first * 2
|
124
|
+
if second < 0
|
125
|
+
raise ArgumentError, 'too small'
|
126
|
+
end
|
127
|
+
b = "foo" * second
|
128
|
+
if third
|
129
|
+
a = a * b
|
130
|
+
end
|
131
|
+
block_result = block.(a, b)
|
132
|
+
result = process block_result
|
133
|
+
return result
|
134
|
+
end
|
99
135
|
|
100
|
-
|
101
|
-
- Do not repeat the ruby method code.
|
102
|
-
- Do not use `, `ruby, ```, ```ruby in your response.
|
103
|
-
- Start each line of your comment with a single # character.
|
136
|
+
And this is the method you should document:
|
104
137
|
|
105
|
-
|
138
|
+
#{method}
|
106
139
|
|
107
|
-
|
140
|
+
Output a YARD comment for this method:
|
108
141
|
|
109
|
-
|
142
|
+
Format requirements:
|
110
143
|
|
111
|
-
|
144
|
+
1. Focus on providing a description of the method's purpose, without including any code snippets.
|
145
|
+
2. Never use `, `ruby, ```, ```ruby in your response.
|
146
|
+
3. Never add any other remarks or explanation to your response.
|
147
|
+
4. Start each line of your comment with a single # character.
|
112
148
|
EOT
|
113
149
|
|
114
150
|
options = Ollama::Options.new(
|
@@ -131,5 +167,6 @@ if ENV['DEBUG'].to_i == 1
|
|
131
167
|
end
|
132
168
|
end
|
133
169
|
|
134
|
-
ollama
|
135
|
-
ollama.generate(model:, system:, prompt:, options:, stream: false
|
170
|
+
ollama = Client.new(base_url:, read_timeout: 120)
|
171
|
+
response = ollama.generate(model:, system:, prompt:, options:, stream: false).response
|
172
|
+
puts response.gsub(/^/) { ' ' * method_indent }
|
data/lib/utils/version.rb
CHANGED
data/utils.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: utils 0.
|
2
|
+
# stub: utils 0.61.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "utils".freeze
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.61.0".freeze
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
10
10
|
s.authors = ["Florian Frank".freeze]
|
11
|
-
s.date = "2024-12-
|
11
|
+
s.date = "2024-12-14"
|
12
12
|
s.description = "This ruby gem provides some useful command line utilities".freeze
|
13
13
|
s.email = "flori@ping.de".freeze
|
14
14
|
s.executables = ["ascii7".freeze, "blameline".freeze, "changes".freeze, "classify".freeze, "code_comment".freeze, "commit_message".freeze, "create_cstags".freeze, "create_tags".freeze, "discover".freeze, "edit".freeze, "edit_wait".freeze, "enum".freeze, "git-empty".freeze, "git-versions".freeze, "json_check".freeze, "long_lines".freeze, "myex".freeze, "number_files".freeze, "on_change".freeze, "path".freeze, "print_method".freeze, "probe".freeze, "rd2md".freeze, "search".freeze, "sedit".freeze, "serve".freeze, "ssh-tunnel".freeze, "strip_spaces".freeze, "sync_dir".freeze, "untest".freeze, "utils-utilsrc".freeze, "vcf2alias".freeze, "yaml_check".freeze]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.61.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|