utils 0.59.2 → 0.60.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/Rakefile +1 -0
- data/bin/code_comment +47 -90
- data/lib/utils/version.rb +1 -1
- data/lib/utils.rb +0 -2
- data/utils.gemspec +7 -6
- metadata +16 -10
- data/bin/git-md +0 -51
- data/bin/md +0 -16
- data/lib/utils/markdown.rb +0 -11
- data/lib/utils/pager.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d5a13dd0dc3c72e4110c54d7b218275b8ffe0aaffb79d1ad14d0e8c4de2201f
|
4
|
+
data.tar.gz: e35c204313debe613cbe39e915f986d84faf6ff0ef9c0a7d3529eeabcab8f628
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2755da93986eb39d4c2736578fa26acba7b8a3a4d8a56baaf30c509eb008260eb30281ad26dfba430ab5d031381f5f84ae8a0f4e2fdacc635e96aa105f0ec72
|
7
|
+
data.tar.gz: 8169b9827f29e237e589e76cc98a732a0bda047f524eeccdeaf2e1a0aadc18accdc879fecdbb00c1b19fdb318b52dac193c795bba4cfddf4043db7ebaedd90fc
|
data/Rakefile
CHANGED
data/bin/code_comment
CHANGED
@@ -36,96 +36,53 @@ model = ENV.fetch('OLLAMA_MODEL', 'llama3.1')
|
|
36
36
|
#methods = call_sites.map { fetch_method(_1) } * ?\n
|
37
37
|
|
38
38
|
cheatsheet = <<EOT
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
# @param [OptionParser] opts the option parser object
|
87
|
-
# @param [Array<String>] args the arguments passed from input. This
|
88
|
-
# array will be modified.
|
89
|
-
# @param [Array<String, Symbol>] list the list of strings and symbols.
|
90
|
-
#
|
91
|
-
# The options parsed out of the commandline.
|
92
|
-
# Default options are:
|
93
|
-
# :format => :dot
|
94
|
-
#
|
95
|
-
# @example Reverse a string
|
96
|
-
# "mystring.reverse" #=> "gnirtsym"
|
97
|
-
#
|
98
|
-
# @example Parse a glob of files
|
99
|
-
# YARD.parse('lib/**/*.rb')
|
100
|
-
#
|
101
|
-
# @raise [ExceptionClass] description
|
102
|
-
#
|
103
|
-
# @return [optional, types, ...] description
|
104
|
-
# @return [true] always returns true
|
105
|
-
# @return [void]
|
106
|
-
# @return [String, nil] the contents of our object or nil
|
107
|
-
# if the object has not been filled with data.
|
108
|
-
#
|
109
|
-
# We don't care about the "type" here:
|
110
|
-
# @return the object
|
111
|
-
#
|
112
|
-
# @return [String, #read] a string or object that responds to #read
|
113
|
-
# @return description here with no types
|
114
|
-
|
115
|
-
## Anywhere
|
116
|
-
|
117
|
-
# @todo Add support for Jabberwocky service
|
118
|
-
# There is an open source Jabberwocky library available
|
119
|
-
# at http://somesite.com that can be integrated easily
|
120
|
-
# into the project.
|
121
|
-
|
122
|
-
## Blocks
|
123
|
-
|
124
|
-
# for block {|a, b, c| ... }
|
125
|
-
# @yield [a, b, c] Description of block
|
126
|
-
#
|
127
|
-
# @yieldparam [optional, types, ...] argname description
|
128
|
-
# @yieldreturn [optional, types, ...] description
|
39
|
+
Documenting Code with YARD
|
40
|
+
|
41
|
+
By default, YARD is compatible with the same RDoc syntax most Ruby developers
|
42
|
+
are already familiar with. However, one of the biggest advantages of YARD is
|
43
|
+
the extended meta-data syntax, commonly known as "tags", that you can use to
|
44
|
+
express small bits of information in a structured and formal manner. While RDoc
|
45
|
+
syntax expects you to describe your method in a completely free-form manner,
|
46
|
+
YARD recommends declaring your parameters, return types, etc. with the @tag
|
47
|
+
syntax, which makes outputting the documentation more consistent and easier to
|
48
|
+
read. Consider the RDoc documentation for a method to_format:
|
49
|
+
|
50
|
+
# Converts the object into textual markup given a specific `format`
|
51
|
+
# (defaults to `:html`)
|
52
|
+
#
|
53
|
+
# == Parameters:
|
54
|
+
# format::
|
55
|
+
# A Symbol declaring the format to convert the object to. This
|
56
|
+
# can be `:text` or `:html`.
|
57
|
+
#
|
58
|
+
# == Returns:
|
59
|
+
# A string representing the object in a specified
|
60
|
+
# format.
|
61
|
+
#
|
62
|
+
def to_format(format = :html)
|
63
|
+
# format the object
|
64
|
+
end
|
65
|
+
|
66
|
+
While this may seem easy enough to read and understand, it's hard for a machine
|
67
|
+
to properly pull this data back out of our documentation. Also we've tied our
|
68
|
+
markup to our content, and now our documentation becomes hard to maintain if we
|
69
|
+
decide later to change our markup style (maybe we don't want the ":" suffix on
|
70
|
+
our headers anymore).
|
71
|
+
|
72
|
+
In YARD, we would simply define our method as:
|
73
|
+
|
74
|
+
# Converts the object into textual markup given a specific format.
|
75
|
+
#
|
76
|
+
# @param format [Symbol] the format type, `:text` or `:html`
|
77
|
+
# @return [String] the object converted into the expected format.
|
78
|
+
# @raise [CannotFormatException] the object cannot be formatted
|
79
|
+
def to_format(format = :html)
|
80
|
+
# format the object
|
81
|
+
end
|
82
|
+
|
83
|
+
Using tags we can add semantic metadata to our code without worrying about
|
84
|
+
presentation. YARD will handle presentation for us when we decide to generate
|
85
|
+
documentation later.
|
129
86
|
EOT
|
130
87
|
|
131
88
|
system = <<EOT
|
data/lib/utils/version.rb
CHANGED
data/lib/utils.rb
CHANGED
data/utils.gemspec
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: utils 0.
|
2
|
+
# stub: utils 0.60.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.60.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-10-
|
11
|
+
s.date = "2024-10-31"
|
12
12
|
s.description = "This ruby gem provides some useful command line utilities".freeze
|
13
13
|
s.email = "flori@ping.de".freeze
|
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-
|
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/file_xt.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/
|
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-
|
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/file_xt.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/file_xt.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]
|
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.add_runtime_dependency(%q<search_ui>.freeze, ["~> 0.0".freeze])
|
34
34
|
s.add_runtime_dependency(%q<all_images>.freeze, ["~> 0.5.0".freeze])
|
35
35
|
s.add_runtime_dependency(%q<ollama-ruby>.freeze, [">= 0".freeze])
|
36
|
+
s.add_runtime_dependency(%q<kramdown-ansi>.freeze, [">= 0".freeze])
|
36
37
|
s.add_runtime_dependency(%q<simplecov>.freeze, [">= 0".freeze])
|
37
38
|
s.add_runtime_dependency(%q<debug>.freeze, [">= 0".freeze])
|
38
39
|
end
|
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.60.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-10-
|
11
|
+
date: 2024-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: kramdown-ansi
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
182
|
name: simplecov
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -208,11 +222,9 @@ executables:
|
|
208
222
|
- edit_wait
|
209
223
|
- enum
|
210
224
|
- git-empty
|
211
|
-
- git-md
|
212
225
|
- git-versions
|
213
226
|
- json_check
|
214
227
|
- long_lines
|
215
|
-
- md
|
216
228
|
- myex
|
217
229
|
- number_files
|
218
230
|
- on_change
|
@@ -242,9 +254,7 @@ extra_rdoc_files:
|
|
242
254
|
- lib/utils/irb.rb
|
243
255
|
- lib/utils/line_blamer.rb
|
244
256
|
- lib/utils/line_formatter.rb
|
245
|
-
- lib/utils/markdown.rb
|
246
257
|
- lib/utils/md5.rb
|
247
|
-
- lib/utils/pager.rb
|
248
258
|
- lib/utils/patterns.rb
|
249
259
|
- lib/utils/probe_server.rb
|
250
260
|
- lib/utils/ssh_tunnel_specification.rb
|
@@ -270,11 +280,9 @@ files:
|
|
270
280
|
- bin/edit_wait
|
271
281
|
- bin/enum
|
272
282
|
- bin/git-empty
|
273
|
-
- bin/git-md
|
274
283
|
- bin/git-versions
|
275
284
|
- bin/json_check
|
276
285
|
- bin/long_lines
|
277
|
-
- bin/md
|
278
286
|
- bin/myex
|
279
287
|
- bin/number_files
|
280
288
|
- bin/on_change
|
@@ -301,9 +309,7 @@ files:
|
|
301
309
|
- lib/utils/irb.rb
|
302
310
|
- lib/utils/line_blamer.rb
|
303
311
|
- lib/utils/line_formatter.rb
|
304
|
-
- lib/utils/markdown.rb
|
305
312
|
- lib/utils/md5.rb
|
306
|
-
- lib/utils/pager.rb
|
307
313
|
- lib/utils/patterns.rb
|
308
314
|
- lib/utils/probe_server.rb
|
309
315
|
- lib/utils/ssh_tunnel_specification.rb
|
data/bin/git-md
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'utils/markdown'
|
4
|
-
include Utils::Markdown
|
5
|
-
require 'utils/pager'
|
6
|
-
require 'term/ansicolor'
|
7
|
-
include Term::ANSIColor
|
8
|
-
require 'shellwords'
|
9
|
-
|
10
|
-
cmd = %{git log --color=always --pretty=format:"commit %H%C(auto)%d%nDate: %Cgreen%cD (%cr)%Creset%nAuthor: %Cblue%an <%ae>%Creset%n%nMARKUP%n%s%n%n%b%nMARKDOWN%n"}
|
11
|
-
|
12
|
-
core_pager = `git config get core.pager`.chomp.full?
|
13
|
-
git_pager = ENV['GIT_PAGER'].full?
|
14
|
-
default_pager = ENV['PAGER'].full?
|
15
|
-
if fallback_pager = `which less`.chomp.full? || `which more`.chomp.full?
|
16
|
-
fallback_pager << ' -r'
|
17
|
-
end
|
18
|
-
my_pager = git_pager || core_pager || default_pager || fallback_pager
|
19
|
-
|
20
|
-
repo_url = case git_origin_url = `git remote get-url origin`.chomp
|
21
|
-
when %r(\Ahttps://)
|
22
|
-
u = git_origin_url.sub(%r(\.git\z), '')
|
23
|
-
u << '/commit/'
|
24
|
-
when %r(\Agit@github.com:([^.]+))
|
25
|
-
"https://github.com/#$1/commit/"
|
26
|
-
end
|
27
|
-
|
28
|
-
Utils::Pager.pager(command: my_pager) do |output|
|
29
|
-
IO.popen("#{cmd} #{Shellwords.join(ARGV)}") do |log|
|
30
|
-
until log.eof?
|
31
|
-
message = nil
|
32
|
-
log.each do |line|
|
33
|
-
case line
|
34
|
-
when /^MARKUP$/
|
35
|
-
message = ''
|
36
|
-
when /^MARKDOWN$/
|
37
|
-
output.puts markdown(message + "\n---\n")
|
38
|
-
message = nil
|
39
|
-
else
|
40
|
-
if message
|
41
|
-
message << line
|
42
|
-
else
|
43
|
-
output.puts line.sub(/(?<=^commit )(\h{40})/) {
|
44
|
-
yellow { repo_url ? hyperlink(repo_url + $1) { $1 } : $1 }
|
45
|
-
}
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
data/bin/md
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'utils/markdown'
|
4
|
-
include Utils::Markdown
|
5
|
-
require 'utils/pager'
|
6
|
-
|
7
|
-
rendered = markdown(ARGF.read)
|
8
|
-
default_pager = ENV['PAGER'].full?
|
9
|
-
if fallback_pager = `which less`.chomp.full? || `which more`.chomp.full?
|
10
|
-
fallback_pager << ' -r'
|
11
|
-
end
|
12
|
-
my_pager = default_pager || fallback_pager
|
13
|
-
|
14
|
-
Utils::Pager.pager(lines: rendered.count(?\n), command: my_pager) do |output|
|
15
|
-
output.puts rendered
|
16
|
-
end
|
data/lib/utils/markdown.rb
DELETED
data/lib/utils/pager.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'tins'
|
2
|
-
|
3
|
-
module Utils
|
4
|
-
module Pager
|
5
|
-
module_function
|
6
|
-
|
7
|
-
def pager(command: nil, lines: nil, &block)
|
8
|
-
if block
|
9
|
-
if my_pager = pager(command:, lines:)
|
10
|
-
IO.popen(my_pager, 'w') do |output|
|
11
|
-
output.sync = true
|
12
|
-
yield output
|
13
|
-
output.close
|
14
|
-
end
|
15
|
-
else
|
16
|
-
yield STDOUT
|
17
|
-
end
|
18
|
-
else
|
19
|
-
return unless STDOUT.tty?
|
20
|
-
if lines
|
21
|
-
if lines >= Tins::Terminal.lines
|
22
|
-
pager(command:)
|
23
|
-
end
|
24
|
-
else
|
25
|
-
command
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|