utils 0.60.2 → 0.62.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/bin/discover +0 -1
- data/bin/search +1 -2
- data/bin/strip_spaces +0 -1
- data/lib/utils/config_file.rb +0 -4
- data/lib/utils/grepper.rb +4 -8
- data/lib/utils/version.rb +1 -1
- data/utils.gemspec +4 -4
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb608b3d361742306cafe1b44729d2de4d4dcd01df60ae727d6317e4225e932e
|
4
|
+
data.tar.gz: d3a0e74795e6dd0b84d0482b65c654e215d748e8631898850a3b6d6c84fe75f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60dc92c6645f507de9ccc6ecc46eed3c7575d5a6ad8f095747059768fb8ffb984442c8421475813f3c960a99ae9724d1a6a2e4ddf54364f4c7c03a9a73bb0190
|
7
|
+
data.tar.gz: 52cbbc17bf192017e1f6d271f1891039b5e1a06717582da89ccd8af3596145a8f0d5c9997612d871d3c523982c2d3ab1b116e04dbee82c70ca9e95a19a84085e
|
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/bin/discover
CHANGED
@@ -63,7 +63,6 @@ Term::ANSIColor.coloring = (STDIN.tty? && ENV['TERM'] !~ /dumb/) && !args[?c]
|
|
63
63
|
STDOUT.sync = true
|
64
64
|
config = Utils::ConfigFile.new
|
65
65
|
config.configure_from_paths
|
66
|
-
args[?b] ||= config.discover.binary
|
67
66
|
args[?n] ||= (args[?l] || args[?L]) ? 1 << 60 : config.discover.max_matches
|
68
67
|
|
69
68
|
if args[?s]
|
data/bin/search
CHANGED
@@ -134,7 +134,6 @@ def usage
|
|
134
134
|
-e open the matching files with edit command
|
135
135
|
-E pick one file to edit
|
136
136
|
-r REPLACE replace the searched match with REPLACE
|
137
|
-
-b also search binary files
|
138
137
|
-g use git to determine author of the line
|
139
138
|
-G AUTHOR only display lines authored by AUTHOR
|
140
139
|
-a CSET use only character set CSET from PATTERN
|
@@ -146,7 +145,7 @@ def usage
|
|
146
145
|
exit 1
|
147
146
|
end
|
148
147
|
|
149
|
-
args = go 'r:p:I:A:B:C:s:S:n:N:a:i:G:
|
148
|
+
args = go 'r:p:I:A:B:C:s:S:n:N:a:i:G:cfFlLeEvgh'
|
150
149
|
args[?h] and usage
|
151
150
|
pattern = ARGV.shift or usage
|
152
151
|
roots = (ARGV.empty? ? [ Dir.pwd ] : ARGV).map { |f| File.expand_path(f) }
|
data/bin/strip_spaces
CHANGED
data/lib/utils/config_file.rb
CHANGED
@@ -132,8 +132,6 @@ class Utils::ConfigFile
|
|
132
132
|
|
133
133
|
config :skip_files, /(\A\.|\.sw[pon]\z|\.log\z|~\z)/
|
134
134
|
|
135
|
-
config :binary, false
|
136
|
-
|
137
135
|
config :max_matches, 10
|
138
136
|
|
139
137
|
config :index_expire_after
|
@@ -150,8 +148,6 @@ class Utils::ConfigFile
|
|
150
148
|
config :prune_dirs, /\A(\.svn|\.git|CVS|tmp)\z/
|
151
149
|
|
152
150
|
config :skip_files, /(\A\.|\.sw[pon]\z|\.log\z|~\z)/
|
153
|
-
|
154
|
-
config :binary, false
|
155
151
|
end
|
156
152
|
|
157
153
|
def scope(&block)
|
data/lib/utils/grepper.rb
CHANGED
@@ -72,15 +72,11 @@ class Utils::Grepper
|
|
72
72
|
(!@name_pattern || @name_pattern.match(bn))
|
73
73
|
then
|
74
74
|
File.open(filename, 'rb', encoding: Encoding::UTF_8) do |file|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
@output << filename
|
79
|
-
else
|
80
|
-
match_lines file
|
81
|
-
end
|
75
|
+
@args[?v] and warn "Matching #{filename.inspect}."
|
76
|
+
if @args[?f]
|
77
|
+
@output << filename
|
82
78
|
else
|
83
|
-
|
79
|
+
match_lines file
|
84
80
|
end
|
85
81
|
end
|
86
82
|
else
|
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.62.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.62.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 = "
|
11
|
+
s.date = "2025-01-10"
|
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]
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.homepage = "http://github.com/flori/utils".freeze
|
18
18
|
s.licenses = ["GPL-2.0".freeze]
|
19
19
|
s.rdoc_options = ["--title".freeze, "Utils - Some useful command line utilities".freeze, "--main".freeze, "README.md".freeze]
|
20
|
-
s.rubygems_version = "3.
|
20
|
+
s.rubygems_version = "3.6.2".freeze
|
21
21
|
s.summary = "Some useful command line utilities".freeze
|
22
22
|
|
23
23
|
s.specification_version = 4
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.62.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-01-10 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: gem_hadar
|
@@ -318,7 +317,6 @@ homepage: http://github.com/flori/utils
|
|
318
317
|
licenses:
|
319
318
|
- GPL-2.0
|
320
319
|
metadata: {}
|
321
|
-
post_install_message:
|
322
320
|
rdoc_options:
|
323
321
|
- "--title"
|
324
322
|
- Utils - Some useful command line utilities
|
@@ -337,8 +335,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
337
335
|
- !ruby/object:Gem::Version
|
338
336
|
version: '0'
|
339
337
|
requirements: []
|
340
|
-
rubygems_version: 3.
|
341
|
-
signing_key:
|
338
|
+
rubygems_version: 3.6.2
|
342
339
|
specification_version: 4
|
343
340
|
summary: Some useful command line utilities
|
344
341
|
test_files: []
|