utils 0.93.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/bin/discover +4 -4
- data/bin/search +2 -1
- data/lib/utils/finder.rb +3 -3
- data/lib/utils/grepper.rb +15 -1
- data/lib/utils/line_formatter.rb +2 -2
- data/lib/utils/version.rb +1 -1
- data/utils.gemspec +4 -4
- metadata +6 -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/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:P: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/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],
|
|
@@ -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
|
|
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]
|
|
@@ -17,13 +17,13 @@ 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 = "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
|
|
@@ -430,7 +430,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
430
430
|
- !ruby/object:Gem::Version
|
|
431
431
|
version: '0'
|
|
432
432
|
requirements: []
|
|
433
|
-
rubygems_version: 4.0.
|
|
433
|
+
rubygems_version: 4.0.4
|
|
434
434
|
specification_version: 4
|
|
435
435
|
summary: Some useful command line utilities
|
|
436
436
|
test_files:
|