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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4412a2649cf7a18654f0cdec0cf7fa86ba33cb15c8cf88e2ef1ba10267753cd4
4
- data.tar.gz: 30095f823b5fad6f66e79667d82f88757d47f04d28cde52fe7706c1731331d6b
3
+ metadata.gz: 9e75e4da900a5682f8be3d521d422a48b201f1ba9868468f703b420d344860e8
4
+ data.tar.gz: 2f1317551005fd0e0c413a76f790dcfd670c60124a1c88376b4b8d60001861b5
5
5
  SHA512:
6
- metadata.gz: 0aa5db98d16b760637beb04b4fa5fcd99cb951854b9bb6f8714bc350f2351bb2acbe26fc2220e35b7caf3e079f0b19c3fa74f218bc44107ad03d98c7cbbcb5c2
7
- data.tar.gz: fdb6289ad43454ed499fbdf9ae17051d5b24e93c474dc9ddc81c1f34661135e1c5275bc9dfee6b0b505a017c5a64b9c8c8a28e1caa744f9d7ae255e4ea115951
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
- -n NUMBER the first NUMBER of matches is returned
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 'n:I:i:a:p:P:lLcreEvdsDgh', defaults: { ?a => '\\w' }
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[?n] ||= (args[?l] || args[?L]) ? 1 << 60 : config.discover.max_matches
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[?n] = Term::ANSIColor.terminal_lines - 1
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 n = @args[?n]&.to_i
154
- @paths = @paths&.first(n) || []
155
- @output = @output&.first(n) || []
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
- match(filename)
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
@@ -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
- # error list will be stored, followed by a separator line made of dashes
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 error list in #{@errors_lst.path.inspect}: "
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
@@ -1,6 +1,6 @@
1
1
  module Utils
2
2
  # Utils version
3
- VERSION = '0.93.0'
3
+ VERSION = '0.94.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/utils.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: utils 0.93.0 ruby lib
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.93.0".freeze
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.3".freeze
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, [">= 2.17.0".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.93.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.17.0
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.17.0
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.3
433
+ rubygems_version: 4.0.4
434
434
  specification_version: 4
435
435
  summary: Some useful command line utilities
436
436
  test_files: