utils 0.60.1 → 0.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/code_comment +55 -18
- data/bin/git-versions +11 -11
- data/bin/strip_spaces +1 -4
- data/lib/utils/finder.rb +0 -4
- data/lib/utils/grepper.rb +0 -4
- data/lib/utils/version.rb +1 -1
- data/lib/utils.rb +0 -1
- data/utils.gemspec +6 -6
- metadata +3 -5
- data/lib/utils/file_xt.rb +0 -46
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/bin/git-versions
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require 'tins
|
3
|
+
require 'tins'
|
4
4
|
require 'term/ansicolor'
|
5
|
-
include Tins::GO
|
6
|
-
|
7
|
-
$opts = go 'r:v'
|
8
|
-
|
9
5
|
class String
|
10
6
|
include Term::ANSIColor
|
7
|
+
include Tins::StringVersion
|
11
8
|
end
|
9
|
+
require 'shellwords'
|
12
10
|
|
13
|
-
|
11
|
+
args = ARGV.dup
|
12
|
+
args.empty? and args.concat %w[ --color --stat ]
|
13
|
+
|
14
|
+
regexp = ENV['GIT_VERSIONS_REGEXP']
|
15
|
+
regexp = regexp ? Regexp.new(regexp) : /^v((?:\d+\.)*\d+)/
|
14
16
|
|
15
17
|
versions = `git tag`.lines.map(&:chomp).grep(regexp).sort_by { |x|
|
16
18
|
x[regexp, 1].version
|
17
19
|
}.reverse
|
20
|
+
|
21
|
+
git_options = args.empty? ? ' ' : " #{Shellwords.join(args)} "
|
18
22
|
versions.each_cons(2) do |new, old|
|
19
23
|
puts "Version #{new}".red.bold
|
20
|
-
|
21
|
-
puts `git log --color --stat -u #{old}..#{new}`
|
22
|
-
else
|
23
|
-
puts `git log --color --stat #{old}..#{new}`
|
24
|
-
end
|
24
|
+
puts `git log #{git_options}#{old}..#{new}`
|
25
25
|
end
|
data/bin/strip_spaces
CHANGED
@@ -6,12 +6,9 @@ require 'tins/secure_write'
|
|
6
6
|
include Tins::SecureWrite
|
7
7
|
require 'tins/find'
|
8
8
|
include Tins::Find
|
9
|
+
require 'tins/xt/file_binary'
|
9
10
|
require 'utils'
|
10
11
|
|
11
|
-
class ::File
|
12
|
-
include Utils::FileXt
|
13
|
-
end
|
14
|
-
|
15
12
|
def usage
|
16
13
|
puts <<-EOT
|
17
14
|
Usage: #{File.basename($0)} [OPTS] [PATHS]
|
data/lib/utils/finder.rb
CHANGED
data/lib/utils/grepper.rb
CHANGED
data/lib/utils/version.rb
CHANGED
data/lib/utils.rb
CHANGED
data/utils.gemspec
CHANGED
@@ -1,23 +1,23 @@
|
|
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-
|
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]
|
15
|
-
s.extra_rdoc_files = ["README.md".freeze, "lib/utils.rb".freeze, "lib/utils/config_file.rb".freeze, "lib/utils/editor.rb".freeze, "lib/utils/
|
16
|
-
s.files = [".github/dependabot.yml".freeze, ".github/workflows/codeql-analysis.yml".freeze, "COPYING".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "bin/ascii7".freeze, "bin/blameline".freeze, "bin/changes".freeze, "bin/classify".freeze, "bin/code_comment".freeze, "bin/commit_message".freeze, "bin/create_cstags".freeze, "bin/create_tags".freeze, "bin/discover".freeze, "bin/edit".freeze, "bin/edit_wait".freeze, "bin/enum".freeze, "bin/git-empty".freeze, "bin/git-versions".freeze, "bin/json_check".freeze, "bin/long_lines".freeze, "bin/myex".freeze, "bin/number_files".freeze, "bin/on_change".freeze, "bin/path".freeze, "bin/print_method".freeze, "bin/probe".freeze, "bin/rd2md".freeze, "bin/search".freeze, "bin/sedit".freeze, "bin/serve".freeze, "bin/ssh-tunnel".freeze, "bin/strip_spaces".freeze, "bin/sync_dir".freeze, "bin/untest".freeze, "bin/utils-utilsrc".freeze, "bin/vcf2alias".freeze, "bin/yaml_check".freeze, "lib/utils.rb".freeze, "lib/utils/config_file.rb".freeze, "lib/utils/editor.rb".freeze, "lib/utils/
|
15
|
+
s.extra_rdoc_files = ["README.md".freeze, "lib/utils.rb".freeze, "lib/utils/config_file.rb".freeze, "lib/utils/editor.rb".freeze, "lib/utils/finder.rb".freeze, "lib/utils/grepper.rb".freeze, "lib/utils/irb.rb".freeze, "lib/utils/line_blamer.rb".freeze, "lib/utils/line_formatter.rb".freeze, "lib/utils/md5.rb".freeze, "lib/utils/patterns.rb".freeze, "lib/utils/probe_server.rb".freeze, "lib/utils/ssh_tunnel_specification.rb".freeze, "lib/utils/version.rb".freeze, "lib/utils/xt/source_location_extension.rb".freeze]
|
16
|
+
s.files = [".github/dependabot.yml".freeze, ".github/workflows/codeql-analysis.yml".freeze, "COPYING".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "bin/ascii7".freeze, "bin/blameline".freeze, "bin/changes".freeze, "bin/classify".freeze, "bin/code_comment".freeze, "bin/commit_message".freeze, "bin/create_cstags".freeze, "bin/create_tags".freeze, "bin/discover".freeze, "bin/edit".freeze, "bin/edit_wait".freeze, "bin/enum".freeze, "bin/git-empty".freeze, "bin/git-versions".freeze, "bin/json_check".freeze, "bin/long_lines".freeze, "bin/myex".freeze, "bin/number_files".freeze, "bin/on_change".freeze, "bin/path".freeze, "bin/print_method".freeze, "bin/probe".freeze, "bin/rd2md".freeze, "bin/search".freeze, "bin/sedit".freeze, "bin/serve".freeze, "bin/ssh-tunnel".freeze, "bin/strip_spaces".freeze, "bin/sync_dir".freeze, "bin/untest".freeze, "bin/utils-utilsrc".freeze, "bin/vcf2alias".freeze, "bin/yaml_check".freeze, "lib/utils.rb".freeze, "lib/utils/config_file.rb".freeze, "lib/utils/editor.rb".freeze, "lib/utils/finder.rb".freeze, "lib/utils/grepper.rb".freeze, "lib/utils/irb.rb".freeze, "lib/utils/line_blamer.rb".freeze, "lib/utils/line_formatter.rb".freeze, "lib/utils/md5.rb".freeze, "lib/utils/patterns.rb".freeze, "lib/utils/probe_server.rb".freeze, "lib/utils/ssh_tunnel_specification.rb".freeze, "lib/utils/version.rb".freeze, "lib/utils/xt/source_location_extension.rb".freeze, "utils.gemspec".freeze]
|
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.5.
|
20
|
+
s.rubygems_version = "3.5.23".freeze
|
21
21
|
s.summary = "Some useful command line utilities".freeze
|
22
22
|
|
23
23
|
s.specification_version = 4
|
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-
|
11
|
+
date: 2024-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|
@@ -248,7 +248,6 @@ extra_rdoc_files:
|
|
248
248
|
- lib/utils.rb
|
249
249
|
- lib/utils/config_file.rb
|
250
250
|
- lib/utils/editor.rb
|
251
|
-
- lib/utils/file_xt.rb
|
252
251
|
- lib/utils/finder.rb
|
253
252
|
- lib/utils/grepper.rb
|
254
253
|
- lib/utils/irb.rb
|
@@ -303,7 +302,6 @@ files:
|
|
303
302
|
- lib/utils.rb
|
304
303
|
- lib/utils/config_file.rb
|
305
304
|
- lib/utils/editor.rb
|
306
|
-
- lib/utils/file_xt.rb
|
307
305
|
- lib/utils/finder.rb
|
308
306
|
- lib/utils/grepper.rb
|
309
307
|
- lib/utils/irb.rb
|
@@ -339,7 +337,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
339
337
|
- !ruby/object:Gem::Version
|
340
338
|
version: '0'
|
341
339
|
requirements: []
|
342
|
-
rubygems_version: 3.5.
|
340
|
+
rubygems_version: 3.5.23
|
343
341
|
signing_key:
|
344
342
|
specification_version: 4
|
345
343
|
summary: Some useful command line utilities
|
data/lib/utils/file_xt.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'tins'
|
2
|
-
|
3
|
-
module Utils
|
4
|
-
module FileXt
|
5
|
-
extend DSLKit::Concern
|
6
|
-
include File::Constants
|
7
|
-
|
8
|
-
SEEK_SET = File::SEEK_SET
|
9
|
-
|
10
|
-
ZERO = "\x00"
|
11
|
-
BINARY = "\x01-\x1f\x7f-\xff"
|
12
|
-
|
13
|
-
if defined?(::Encoding)
|
14
|
-
ZERO.force_encoding(Encoding::ASCII_8BIT)
|
15
|
-
BINARY.force_encoding(Encoding::ASCII_8BIT)
|
16
|
-
end
|
17
|
-
|
18
|
-
def binary?
|
19
|
-
old_pos = tell
|
20
|
-
seek 0, SEEK_SET
|
21
|
-
data = read 2 ** 13
|
22
|
-
!data or data.empty? and return nil
|
23
|
-
data.count(ZERO) > 0 and return true
|
24
|
-
data.count(BINARY).to_f / data.size > 0.3
|
25
|
-
ensure
|
26
|
-
seek old_pos, SEEK_SET
|
27
|
-
end
|
28
|
-
|
29
|
-
def ascii?
|
30
|
-
case binary?
|
31
|
-
when true then false
|
32
|
-
when false then true
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
module ClassMethods
|
37
|
-
def binary?(name)
|
38
|
-
File.open(name, 'rb') { |f| f.binary? }
|
39
|
-
end
|
40
|
-
|
41
|
-
def ascii?(name)
|
42
|
-
File.open(name, 'rb') { |f| f.ascii? }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|