utils 0.83.0 → 0.84.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 +2 -1
- data/lib/utils/irb.rb +57 -31
- data/lib/utils/probe/probe_client.rb +2 -2
- data/lib/utils/version.rb +1 -1
- data/utils.gemspec +4 -3
- metadata +18 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9dda5615db1b6e0a3ceb342ec83ca1d2a9db169f45f4c0207daec1ba456e6456
|
|
4
|
+
data.tar.gz: 90a9bc8dd0937badb77c947d9e98abae918b6098cee076cff40868021727905d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '08cb02b22c75148956266066e107e8ea2e1b90162479df973ba010b7c2edf6d339240e8cbc7f5c4957eb249b56cde34f17216aa24b70bcc162fd8c05775d8c52'
|
|
7
|
+
data.tar.gz: fe9c4966eb16d5ee1344626789232c939653841af8f7ecd132d5b1cf0ab96f953e2019e3d0e9238dc93442d1ec90b9dc9f87a2d8886d51b803a2bd2cce70e29c
|
data/Rakefile
CHANGED
|
@@ -26,7 +26,8 @@ GemHadar do
|
|
|
26
26
|
dependency 'pstree', '~> 0.3'
|
|
27
27
|
dependency 'infobar', '~> 0.8'
|
|
28
28
|
dependency 'mize', '~> 0.6'
|
|
29
|
-
dependency '
|
|
29
|
+
dependency 'amatch', '~> 0.6'
|
|
30
|
+
dependency 'search_ui', '>= 0.0.9'
|
|
30
31
|
dependency 'all_images', '~> 0.5.0'
|
|
31
32
|
dependency 'ollama-ruby', '~> 1.6'
|
|
32
33
|
dependency 'kramdown-ansi', '~> 0.1'
|
data/lib/utils/irb.rb
CHANGED
|
@@ -4,6 +4,9 @@ require 'tempfile'
|
|
|
4
4
|
require 'pp'
|
|
5
5
|
require 'shellwords'
|
|
6
6
|
require 'utils'
|
|
7
|
+
require 'fileutils'
|
|
8
|
+
require 'amatch'
|
|
9
|
+
require 'search_ui'
|
|
7
10
|
require_maybe 'ap'
|
|
8
11
|
|
|
9
12
|
$editor = Utils::Editor.new
|
|
@@ -24,7 +27,7 @@ module Utils
|
|
|
24
27
|
# Provides enhanced regexp operations including match highlighting and
|
|
25
28
|
# shell command integration.
|
|
26
29
|
module Shell
|
|
27
|
-
|
|
30
|
+
include SearchUI
|
|
28
31
|
include FileUtils
|
|
29
32
|
include Tins::Find
|
|
30
33
|
|
|
@@ -672,36 +675,59 @@ module Utils
|
|
|
672
675
|
end
|
|
673
676
|
end
|
|
674
677
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
678
|
+
# The irb_load! method loads Ruby files by their names into the current
|
|
679
|
+
# environment through an interactive selection interface.
|
|
680
|
+
#
|
|
681
|
+
# This method takes a glob pattern and finds matching Ruby files, then
|
|
682
|
+
# presents an interactive search interface for selecting which file to load.
|
|
683
|
+
# It ensures that each file is loaded only once by tracking loaded files
|
|
684
|
+
# using their paths. The method outputs messages to standard error
|
|
685
|
+
# indicating which file has been successfully loaded.
|
|
686
|
+
#
|
|
687
|
+
# @param glob [String] the glob pattern to search for Ruby files (defaults to
|
|
688
|
+
# ENV['UTILS_IRB_LOAD_GLOB'] or 'lib/**/*.rb')
|
|
689
|
+
#
|
|
690
|
+
# @return [Boolean] true if a file was successfully loaded, false if no file
|
|
691
|
+
# was selected or loaded
|
|
692
|
+
#
|
|
693
|
+
# @example
|
|
694
|
+
# # Load a file interactively with default glob pattern
|
|
695
|
+
# irb_load!
|
|
696
|
+
#
|
|
697
|
+
# # Load files matching a custom pattern
|
|
698
|
+
# irb_load!('app/models/**/*.rb')
|
|
699
|
+
#
|
|
700
|
+
# # Set environment variable for default pattern
|
|
701
|
+
# ENV['UTILS_IRB_LOAD_GLOB'] = 'lib/**/*.rb'
|
|
702
|
+
# irb_load!
|
|
703
|
+
#
|
|
704
|
+
# @note This method uses fuzzy matching to help find files when typing
|
|
705
|
+
# partial names. It respects the terminal height to limit the number of
|
|
706
|
+
# displayed results.
|
|
707
|
+
#
|
|
708
|
+
# @see SearchUI for the interactive search interface implementation
|
|
709
|
+
# @see Amatch::PairDistance for the fuzzy matching algorithm
|
|
710
|
+
def irb_load!(glob = ENV.fetch('UTILS_IRB_LOAD_GLOB', 'lib/**/*.rb'))
|
|
711
|
+
files = Dir.glob(glob)
|
|
712
|
+
found = Search.new(
|
|
713
|
+
match: -> answer {
|
|
714
|
+
matcher = Amatch::PairDistance.new(answer.downcase)
|
|
715
|
+
matches = files.map { |n| [ n, -matcher.similar(n.downcase) ] }.
|
|
716
|
+
sort.select { _2 < 0 }.sort_by(&:last).map(&:first)
|
|
717
|
+
matches.empty? and matches = files
|
|
718
|
+
matches.first(Tins::Terminal.lines - 1)
|
|
719
|
+
},
|
|
720
|
+
query: -> _answer, matches, selector {
|
|
721
|
+
matches.each_with_index.
|
|
722
|
+
map { |m, i| i == selector ? "→ " + Search.on_blue(m) : " " + m } * ?\n
|
|
723
|
+
},
|
|
724
|
+
found: -> _answer, matches, selector {
|
|
725
|
+
matches[selector]
|
|
726
|
+
},
|
|
727
|
+
output: STDOUT
|
|
728
|
+
).start
|
|
729
|
+
found or return false
|
|
730
|
+
load found
|
|
705
731
|
end
|
|
706
732
|
|
|
707
733
|
# The irb_server method provides access to an IRB server instance for
|
|
@@ -35,7 +35,7 @@ module Utils::Probe
|
|
|
35
35
|
#
|
|
36
36
|
# @return [ String ] the updated environment variable value returned by the server
|
|
37
37
|
def []=(key, value)
|
|
38
|
-
response = @server.transmit_with_response(type: 'set_env', key:, value:)
|
|
38
|
+
response = @server.transmit_with_response({ type: 'set_env', key:, value: })
|
|
39
39
|
response.env
|
|
40
40
|
end
|
|
41
41
|
|
|
@@ -48,7 +48,7 @@ module Utils::Probe
|
|
|
48
48
|
#
|
|
49
49
|
# @return [ String ] the value of the specified environment variable
|
|
50
50
|
def [](key)
|
|
51
|
-
response = @server.transmit_with_response(type: 'get_env', key:)
|
|
51
|
+
response = @server.transmit_with_response({ type: 'get_env', key: })
|
|
52
52
|
response.env
|
|
53
53
|
end
|
|
54
54
|
|
data/lib/utils/version.rb
CHANGED
data/utils.gemspec
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# stub: utils 0.
|
|
2
|
+
# stub: utils 0.84.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.84.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]
|
|
@@ -31,7 +31,8 @@ Gem::Specification.new do |s|
|
|
|
31
31
|
s.add_runtime_dependency(%q<pstree>.freeze, ["~> 0.3".freeze])
|
|
32
32
|
s.add_runtime_dependency(%q<infobar>.freeze, ["~> 0.8".freeze])
|
|
33
33
|
s.add_runtime_dependency(%q<mize>.freeze, ["~> 0.6".freeze])
|
|
34
|
-
s.add_runtime_dependency(%q<
|
|
34
|
+
s.add_runtime_dependency(%q<amatch>.freeze, ["~> 0.6".freeze])
|
|
35
|
+
s.add_runtime_dependency(%q<search_ui>.freeze, [">= 0.0.9".freeze])
|
|
35
36
|
s.add_runtime_dependency(%q<all_images>.freeze, ["~> 0.5.0".freeze])
|
|
36
37
|
s.add_runtime_dependency(%q<ollama-ruby>.freeze, ["~> 1.6".freeze])
|
|
37
38
|
s.add_runtime_dependency(%q<kramdown-ansi>.freeze, ["~> 0.1".freeze])
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: utils
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.84.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Florian Frank
|
|
@@ -122,19 +122,33 @@ dependencies:
|
|
|
122
122
|
- !ruby/object:Gem::Version
|
|
123
123
|
version: '0.6'
|
|
124
124
|
- !ruby/object:Gem::Dependency
|
|
125
|
-
name:
|
|
125
|
+
name: amatch
|
|
126
126
|
requirement: !ruby/object:Gem::Requirement
|
|
127
127
|
requirements:
|
|
128
128
|
- - "~>"
|
|
129
129
|
- !ruby/object:Gem::Version
|
|
130
|
-
version: '0.
|
|
130
|
+
version: '0.6'
|
|
131
131
|
type: :runtime
|
|
132
132
|
prerelease: false
|
|
133
133
|
version_requirements: !ruby/object:Gem::Requirement
|
|
134
134
|
requirements:
|
|
135
135
|
- - "~>"
|
|
136
136
|
- !ruby/object:Gem::Version
|
|
137
|
-
version: '0.
|
|
137
|
+
version: '0.6'
|
|
138
|
+
- !ruby/object:Gem::Dependency
|
|
139
|
+
name: search_ui
|
|
140
|
+
requirement: !ruby/object:Gem::Requirement
|
|
141
|
+
requirements:
|
|
142
|
+
- - ">="
|
|
143
|
+
- !ruby/object:Gem::Version
|
|
144
|
+
version: 0.0.9
|
|
145
|
+
type: :runtime
|
|
146
|
+
prerelease: false
|
|
147
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
148
|
+
requirements:
|
|
149
|
+
- - ">="
|
|
150
|
+
- !ruby/object:Gem::Version
|
|
151
|
+
version: 0.0.9
|
|
138
152
|
- !ruby/object:Gem::Dependency
|
|
139
153
|
name: all_images
|
|
140
154
|
requirement: !ruby/object:Gem::Requirement
|