utils 0.92.0 → 0.94.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/.contexts/lib.rb +23 -0
- data/bin/discover +4 -4
- data/bin/search +2 -1
- data/lib/utils/config_file.rb +3 -2
- data/lib/utils/finder/files.rb +1 -1
- data/lib/utils/finder.rb +3 -3
- data/lib/utils/grepper.rb +16 -2
- data/lib/utils/line_formatter.rb +5 -5
- data/lib/utils/version.rb +1 -1
- data/utils.gemspec +5 -5
- metadata +7 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9e75e4da900a5682f8be3d521d422a48b201f1ba9868468f703b420d344860e8
|
|
4
|
+
data.tar.gz: 2f1317551005fd0e0c413a76f790dcfd670c60124a1c88376b4b8d60001861b5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7bd6708c73311146fab0a0f14e4dfb5b470b958bee9911630c12cc40468ff359be46680a53f12c48310f058680d89d5693ab7040ff91c1dd778ca6f618f305b5
|
|
7
|
+
data.tar.gz: 6093657c875f1f276b3e8b95b1f799521200baca5d29568c06e032059b5a5888c01c333028e63adac91d8eeb75a05fba5adf2d2c7e73bf171e4cb53048515480
|
data/.contexts/lib.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
context do
|
|
2
|
+
namespace "structure" do
|
|
3
|
+
command "tree", tags: %w[ project_structure ]
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
namespace "lib" do
|
|
7
|
+
Dir['lib/**/*.rb'].each do |filename|
|
|
8
|
+
file filename, tags: 'lib'
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
namespace "gems" do
|
|
13
|
+
file Dir['*.gemspec'].first
|
|
14
|
+
file 'Gemfile'
|
|
15
|
+
file 'Gemfile.lock'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
file 'Rakefile', tags: 'gem_hadar'
|
|
19
|
+
|
|
20
|
+
file 'README.md', tags: 'documentation'
|
|
21
|
+
|
|
22
|
+
meta ruby: RUBY_DESCRIPTION
|
|
23
|
+
end
|
data/bin/discover
CHANGED
|
@@ -82,7 +82,7 @@ Options are
|
|
|
82
82
|
-d match also directories
|
|
83
83
|
-D list all search leaf directories
|
|
84
84
|
-v be verbose
|
|
85
|
-
-
|
|
85
|
+
-m NUMBER the maximum NUMBER of matches that is returned
|
|
86
86
|
-s search by interactively inputting PATTERN
|
|
87
87
|
-l list all paths in cache relative to current directory
|
|
88
88
|
-L list all paths in cache as absolute pathes from root
|
|
@@ -94,14 +94,14 @@ Version is #{File.basename($0)} #{Utils::VERSION}.
|
|
|
94
94
|
exit 1
|
|
95
95
|
end
|
|
96
96
|
|
|
97
|
-
args = go '
|
|
97
|
+
args = go 'm:I:i:a:p:P:lLcreEvdsDgh', defaults: { ?a => '\\w' }
|
|
98
98
|
args[?h] and usage
|
|
99
99
|
|
|
100
100
|
Term::ANSIColor.coloring = (STDIN.tty? && ENV['TERM'] !~ /dumb/) && !args[?c]
|
|
101
101
|
STDOUT.sync = true
|
|
102
102
|
config = Utils::ConfigFile.new
|
|
103
103
|
config.configure_from_paths
|
|
104
|
-
args[?
|
|
104
|
+
args[?m] ||= (args[?l] || args[?L]) ? 1 << 60 : config.discover.max_matches
|
|
105
105
|
|
|
106
106
|
if args[?s]
|
|
107
107
|
pattern = ''
|
|
@@ -125,7 +125,7 @@ finder = -> * {
|
|
|
125
125
|
search = -> * {
|
|
126
126
|
f = nil
|
|
127
127
|
pattern = pattern.dup
|
|
128
|
-
args[?
|
|
128
|
+
args[?m] = Term::ANSIColor.terminal_lines - 1
|
|
129
129
|
found = Search.new(
|
|
130
130
|
match: -> answer {
|
|
131
131
|
pattern.replace answer
|
data/bin/search
CHANGED
|
@@ -200,6 +200,7 @@ def usage
|
|
|
200
200
|
|
|
201
201
|
-n PATTERN only search files whose names match fuzzy PATTERN
|
|
202
202
|
-N PATTERN only search files whose names match regexp PATTERN
|
|
203
|
+
-m NUMBER maximum number of files to return
|
|
203
204
|
-s PATTERN skip lines that match fuzzy PATTERN
|
|
204
205
|
-S PATTERN skip lines that match regexp PATTERN
|
|
205
206
|
-A NUMBER displays NUMBER lines of context after the match
|
|
@@ -227,7 +228,7 @@ def usage
|
|
|
227
228
|
exit 1
|
|
228
229
|
end
|
|
229
230
|
|
|
230
|
-
args = go 'r:p:I:A:B:C:s:S:n:N:a:i:G:cfFlLeEvgh'
|
|
231
|
+
args = go 'r:p:I:A:B:C:s:S:n:N:m:a:i:G:P:cfFlLeEvgh'
|
|
231
232
|
args[?h] and usage
|
|
232
233
|
pattern = ARGV.shift or usage
|
|
233
234
|
roots = (ARGV.empty? ? [ Dir.pwd ] : ARGV).map { |f| File.expand_path(f) }
|
data/lib/utils/config_file.rb
CHANGED
|
@@ -205,8 +205,9 @@ class Utils::ConfigFile
|
|
|
205
205
|
#
|
|
206
206
|
# @return [ TrueClass, FalseClass ] true if the basename matches any prune pattern,
|
|
207
207
|
# false otherwise
|
|
208
|
-
def prune?(basename)
|
|
209
|
-
Array(prune_dirs)
|
|
208
|
+
def prune?(basename, additional_dirs: nil)
|
|
209
|
+
([ Array(prune_dirs), Array(additional_dirs) ].compact.flatten).
|
|
210
|
+
any? { |pd| pd.match(basename.to_s) }
|
|
210
211
|
end
|
|
211
212
|
|
|
212
213
|
# The skip? method determines whether a file should be skipped based on
|
data/lib/utils/finder/files.rb
CHANGED
|
@@ -155,7 +155,7 @@ module Utils::Finder::Files
|
|
|
155
155
|
s = filename.stat
|
|
156
156
|
bn = filename.pathname.basename
|
|
157
157
|
if !s ||
|
|
158
|
-
s.directory? && @config.discover.prune?(bn) ||
|
|
158
|
+
s.directory? && @config.discover.prune?(bn, additional_dirs: @args[?P]) ||
|
|
159
159
|
s.file? && @config.discover.skip?(bn)
|
|
160
160
|
then
|
|
161
161
|
@args[?v] and warn "Pruning #{filename.inspect}."
|
data/lib/utils/finder.rb
CHANGED
|
@@ -150,9 +150,9 @@ class Utils::Finder
|
|
|
150
150
|
end
|
|
151
151
|
paths.compact!
|
|
152
152
|
@paths, @output = paths.sort.transpose.values_at(-2, -1)
|
|
153
|
-
if
|
|
154
|
-
@paths = @paths&.first(
|
|
155
|
-
@output = @output&.first(
|
|
153
|
+
if m = @args[?m]&.to_i
|
|
154
|
+
@paths = @paths&.first(m) || []
|
|
155
|
+
@output = @output&.first(m) || []
|
|
156
156
|
end
|
|
157
157
|
self
|
|
158
158
|
end
|
data/lib/utils/grepper.rb
CHANGED
|
@@ -88,6 +88,11 @@ class Utils::Grepper
|
|
|
88
88
|
raise ArgumentError, "needs to be an integer number >= 1"
|
|
89
89
|
end
|
|
90
90
|
end
|
|
91
|
+
|
|
92
|
+
if max_files = @args[?m].to_i and max_files > 0
|
|
93
|
+
@max_files = max_files
|
|
94
|
+
end
|
|
95
|
+
|
|
91
96
|
@paths = []
|
|
92
97
|
pattern_opts = opts.subhash(:pattern) | {
|
|
93
98
|
:cset => @args[?a],
|
|
@@ -138,7 +143,7 @@ class Utils::Grepper
|
|
|
138
143
|
@filename = filename
|
|
139
144
|
@output = []
|
|
140
145
|
bn, s = File.basename(filename), File.stat(filename)
|
|
141
|
-
if !s || s.directory? && @config.search.prune?(bn)
|
|
146
|
+
if !s || s.directory? && @config.search.prune?(bn, additional_dirs: @args[?P])
|
|
142
147
|
@args[?v] and warn "Pruning #{filename.inspect}."
|
|
143
148
|
prune
|
|
144
149
|
end
|
|
@@ -260,8 +265,17 @@ class Utils::Grepper
|
|
|
260
265
|
end
|
|
261
266
|
}
|
|
262
267
|
find(*@roots, visit: visit) do |filename|
|
|
263
|
-
|
|
268
|
+
if @max_files && @paths.length >= @max_files
|
|
269
|
+
break
|
|
270
|
+
else
|
|
271
|
+
match(filename)
|
|
272
|
+
end
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
if @max_files
|
|
276
|
+
@paths = @paths.first(@max_files)
|
|
264
277
|
end
|
|
278
|
+
|
|
265
279
|
@paths = @paths.sort_by(&:source_location)
|
|
266
280
|
self
|
|
267
281
|
end
|
data/lib/utils/line_formatter.rb
CHANGED
|
@@ -33,13 +33,13 @@ else
|
|
|
33
33
|
# The start method initializes the error logging output.
|
|
34
34
|
#
|
|
35
35
|
# This method writes a header message to the output indicating where the
|
|
36
|
-
#
|
|
36
|
+
# errors list will be stored, followed by a separator line made of dashes
|
|
37
37
|
# that spans the width of the terminal.
|
|
38
38
|
#
|
|
39
39
|
# @param _ignore [ Object ] this parameter is ignored and exists for
|
|
40
40
|
# interface compatibility
|
|
41
41
|
def start(_ignore)
|
|
42
|
-
output.puts "Storing
|
|
42
|
+
output.puts "Storing errors list in #{@errors_lst.path.inspect}: "
|
|
43
43
|
output.puts ?━ * Tins::Terminal.columns
|
|
44
44
|
end
|
|
45
45
|
|
|
@@ -335,7 +335,7 @@ else
|
|
|
335
335
|
#
|
|
336
336
|
# @return [ String ] the input text wrapped with green color ANSI escape codes
|
|
337
337
|
def success_color(text)
|
|
338
|
-
Term::ANSIColor.
|
|
338
|
+
Term::ANSIColor.bright_green(text)
|
|
339
339
|
end
|
|
340
340
|
|
|
341
341
|
# The failure_color method applies red color formatting to the provided
|
|
@@ -349,7 +349,7 @@ else
|
|
|
349
349
|
#
|
|
350
350
|
# @return [ String ] the colorized text wrapped with red formatting codes
|
|
351
351
|
def failure_color(text)
|
|
352
|
-
Term::ANSIColor.
|
|
352
|
+
Term::ANSIColor.bright_red(text)
|
|
353
353
|
end
|
|
354
354
|
|
|
355
355
|
# The pending_color method applies yellow color formatting to the
|
|
@@ -363,7 +363,7 @@ else
|
|
|
363
363
|
#
|
|
364
364
|
# @return [ String ] the colorized text with yellow formatting applied
|
|
365
365
|
def pending_color(text)
|
|
366
|
-
Term::ANSIColor.
|
|
366
|
+
Term::ANSIColor.bright_yellow(text)
|
|
367
367
|
end
|
|
368
368
|
|
|
369
369
|
# The location method extracts and formats the file path and line number
|
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.94.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.94.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]
|
|
@@ -13,17 +13,17 @@ Gem::Specification.new do |s|
|
|
|
13
13
|
s.email = "flori@ping.de".freeze
|
|
14
14
|
s.executables = ["ascii7".freeze, "blameline".freeze, "changes".freeze, "classify".freeze, "code_comment".freeze, "code_indexer".freeze, "commit_message".freeze, "discover".freeze, "edit".freeze, "edit_wait".freeze, "enum".freeze, "git-empty".freeze, "git-versions".freeze, "irb_client".freeze, "json_check".freeze, "long_lines".freeze, "myex".freeze, "on_change".freeze, "path".freeze, "print_method".freeze, "probe".freeze, "rainbow".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
15
|
s.extra_rdoc_files = ["README.md".freeze, "lib/utils.rb".freeze, "lib/utils/config_file.rb".freeze, "lib/utils/config_file/block_config.rb".freeze, "lib/utils/editor.rb".freeze, "lib/utils/finder.rb".freeze, "lib/utils/finder/files.rb".freeze, "lib/utils/grepper.rb".freeze, "lib/utils/irb.rb".freeze, "lib/utils/irb/irb_server.rb".freeze, "lib/utils/irb/regexp.rb".freeze, "lib/utils/irb/shell.rb".freeze, "lib/utils/irb/shell/wrappers.rb".freeze, "lib/utils/irb/string.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.rb".freeze, "lib/utils/probe/probe_client.rb".freeze, "lib/utils/probe/probe_server.rb".freeze, "lib/utils/probe/process_job.rb".freeze, "lib/utils/probe/server_handling.rb".freeze, "lib/utils/ssh_tunnel_specification.rb".freeze, "lib/utils/version.rb".freeze, "lib/utils/xdg.rb".freeze, "lib/utils/xt/source_location_extension.rb".freeze]
|
|
16
|
-
s.files = ["Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "bin/ascii7".freeze, "bin/blameline".freeze, "bin/changes".freeze, "bin/classify".freeze, "bin/code_comment".freeze, "bin/code_indexer".freeze, "bin/commit_message".freeze, "bin/discover".freeze, "bin/edit".freeze, "bin/edit_wait".freeze, "bin/enum".freeze, "bin/git-empty".freeze, "bin/git-versions".freeze, "bin/irb_client".freeze, "bin/json_check".freeze, "bin/long_lines".freeze, "bin/myex".freeze, "bin/on_change".freeze, "bin/path".freeze, "bin/print_method".freeze, "bin/probe".freeze, "bin/rainbow".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/config_file/block_config.rb".freeze, "lib/utils/editor.rb".freeze, "lib/utils/finder.rb".freeze, "lib/utils/finder/files.rb".freeze, "lib/utils/grepper.rb".freeze, "lib/utils/irb.rb".freeze, "lib/utils/irb/irb_server.rb".freeze, "lib/utils/irb/regexp.rb".freeze, "lib/utils/irb/shell.rb".freeze, "lib/utils/irb/shell/wrappers.rb".freeze, "lib/utils/irb/string.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.rb".freeze, "lib/utils/probe/probe_client.rb".freeze, "lib/utils/probe/probe_server.rb".freeze, "lib/utils/probe/process_job.rb".freeze, "lib/utils/probe/server_handling.rb".freeze, "lib/utils/ssh_tunnel_specification.rb".freeze, "lib/utils/version.rb".freeze, "lib/utils/xdg.rb".freeze, "lib/utils/xt/source_location_extension.rb".freeze, "tests/test_helper.rb".freeze, "tests/utils_test.rb".freeze, "utils.gemspec".freeze]
|
|
16
|
+
s.files = [".contexts/lib.rb".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "bin/ascii7".freeze, "bin/blameline".freeze, "bin/changes".freeze, "bin/classify".freeze, "bin/code_comment".freeze, "bin/code_indexer".freeze, "bin/commit_message".freeze, "bin/discover".freeze, "bin/edit".freeze, "bin/edit_wait".freeze, "bin/enum".freeze, "bin/git-empty".freeze, "bin/git-versions".freeze, "bin/irb_client".freeze, "bin/json_check".freeze, "bin/long_lines".freeze, "bin/myex".freeze, "bin/on_change".freeze, "bin/path".freeze, "bin/print_method".freeze, "bin/probe".freeze, "bin/rainbow".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/config_file/block_config.rb".freeze, "lib/utils/editor.rb".freeze, "lib/utils/finder.rb".freeze, "lib/utils/finder/files.rb".freeze, "lib/utils/grepper.rb".freeze, "lib/utils/irb.rb".freeze, "lib/utils/irb/irb_server.rb".freeze, "lib/utils/irb/regexp.rb".freeze, "lib/utils/irb/shell.rb".freeze, "lib/utils/irb/shell/wrappers.rb".freeze, "lib/utils/irb/string.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.rb".freeze, "lib/utils/probe/probe_client.rb".freeze, "lib/utils/probe/probe_server.rb".freeze, "lib/utils/probe/process_job.rb".freeze, "lib/utils/probe/server_handling.rb".freeze, "lib/utils/ssh_tunnel_specification.rb".freeze, "lib/utils/version.rb".freeze, "lib/utils/xdg.rb".freeze, "lib/utils/xt/source_location_extension.rb".freeze, "tests/test_helper.rb".freeze, "tests/utils_test.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 = "4.0.
|
|
20
|
+
s.rubygems_version = "4.0.4".freeze
|
|
21
21
|
s.summary = "Some useful command line utilities".freeze
|
|
22
22
|
s.test_files = ["tests/test_helper.rb".freeze, "tests/utils_test.rb".freeze]
|
|
23
23
|
|
|
24
24
|
s.specification_version = 4
|
|
25
25
|
|
|
26
|
-
s.add_development_dependency(%q<gem_hadar>.freeze, ["
|
|
26
|
+
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 2.8".freeze])
|
|
27
27
|
s.add_development_dependency(%q<test-unit>.freeze, [">= 0".freeze])
|
|
28
28
|
s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.51".freeze])
|
|
29
29
|
s.add_runtime_dependency(%q<term-ansicolor>.freeze, ["~> 1.11".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.94.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Florian Frank
|
|
@@ -13,16 +13,16 @@ dependencies:
|
|
|
13
13
|
name: gem_hadar
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
15
15
|
requirements:
|
|
16
|
-
- - "
|
|
16
|
+
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 2.
|
|
18
|
+
version: '2.8'
|
|
19
19
|
type: :development
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
|
-
- - "
|
|
23
|
+
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 2.
|
|
25
|
+
version: '2.8'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: test-unit
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -341,6 +341,7 @@ extra_rdoc_files:
|
|
|
341
341
|
- lib/utils/xdg.rb
|
|
342
342
|
- lib/utils/xt/source_location_extension.rb
|
|
343
343
|
files:
|
|
344
|
+
- ".contexts/lib.rb"
|
|
344
345
|
- Gemfile
|
|
345
346
|
- LICENSE
|
|
346
347
|
- README.md
|
|
@@ -429,7 +430,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
429
430
|
- !ruby/object:Gem::Version
|
|
430
431
|
version: '0'
|
|
431
432
|
requirements: []
|
|
432
|
-
rubygems_version: 4.0.
|
|
433
|
+
rubygems_version: 4.0.4
|
|
433
434
|
specification_version: 4
|
|
434
435
|
summary: Some useful command line utilities
|
|
435
436
|
test_files:
|