utils 0.51.1 → 0.52.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/discover +9 -2
- data/lib/utils/finder.rb +12 -6
- data/lib/utils/version.rb +1 -1
- data/utils.gemspec +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af8e1e554e81bff32ff0e5a382b722f1e98b9a3c200b3d3f8dfd875235169ce8
|
4
|
+
data.tar.gz: 4e1f75f8db3e951a3ef7304843029b6519b7caf3ec936d8b7942d32f1c152440
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2664375885faa1a8f3b747d790308eb7c2929dd5a95cf0f21ebb35d25c68a7e8e23c1968646e1214babb91edb1e7a6a7972b3d873b364f4fd119efcfeb9e8103
|
7
|
+
data.tar.gz: d5c4db5b7a10a889bc6d1bc01e7dcf578623a3b0a2eebc85f3e40c0e206bd1a396423a9bad6aaad55e9f464beb9b2daa8d8375c48b0ea94a55a61c0b328bd927
|
data/bin/discover
CHANGED
@@ -6,6 +6,7 @@ require 'tins/xt'
|
|
6
6
|
include Tins::GO
|
7
7
|
require 'search_ui'
|
8
8
|
include SearchUI
|
9
|
+
require 'pathname'
|
9
10
|
|
10
11
|
def edit_files(*paths, pick: false, wait: true)
|
11
12
|
editor = Utils::Editor.new
|
@@ -46,6 +47,8 @@ Options are
|
|
46
47
|
-v be verbose
|
47
48
|
-n NUMBER the first NUMBER of matches is returned
|
48
49
|
-s search by interactively inputting PATTERN
|
50
|
+
-l list all paths in cache relative to current directory
|
51
|
+
-L list all paths in cahce as absolute pathes from root
|
49
52
|
-h display this help
|
50
53
|
|
51
54
|
Version is #{File.basename($0)} #{Utils::VERSION}.
|
@@ -53,7 +56,7 @@ Version is #{File.basename($0)} #{Utils::VERSION}.
|
|
53
56
|
exit 1
|
54
57
|
end
|
55
58
|
|
56
|
-
args = go 'n:I:i:a:p:
|
59
|
+
args = go 'n:I:i:a:p:lLcreEvdsDh', defaults: { ?a => '\\w' }
|
57
60
|
args[?h] and usage
|
58
61
|
|
59
62
|
Term::ANSIColor.coloring = (STDIN.tty? && ENV['TERM'] !~ /dumb/) && !args[?c]
|
@@ -61,7 +64,7 @@ STDOUT.sync = true
|
|
61
64
|
config = Utils::ConfigFile.new
|
62
65
|
config.configure_from_paths
|
63
66
|
args[?b] ||= config.discover.binary
|
64
|
-
args[?n] ||= args[?l] ? 1 << 60 : config.discover.max_matches
|
67
|
+
args[?n] ||= (args[?l] || args[?L]) ? 1 << 60 : config.discover.max_matches
|
65
68
|
|
66
69
|
if args[?s]
|
67
70
|
pattern = ''
|
@@ -112,6 +115,10 @@ search = -> * {
|
|
112
115
|
|
113
116
|
case
|
114
117
|
when args[?l]
|
118
|
+
puts finder.().search_index.paths.map {
|
119
|
+
Pathname.new(_1).expand_path.relative_path_from(Dir.pwd)
|
120
|
+
}
|
121
|
+
when args[?L]
|
115
122
|
puts finder.().search_index.paths
|
116
123
|
when args[?s]
|
117
124
|
search.()
|
data/lib/utils/finder.rb
CHANGED
@@ -18,11 +18,15 @@ class Utils::Finder
|
|
18
18
|
@args = opts[:args] || {}
|
19
19
|
@roots = discover_roots(opts[:roots])
|
20
20
|
@config = opts[:config] || Utils::ConfigFile.new
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
if @args[?l] || @args[?L]
|
22
|
+
@pattern = nil
|
23
|
+
else
|
24
|
+
pattern_opts = opts.subhash(:pattern) | {
|
25
|
+
:cset => @args[?a],
|
26
|
+
:icase => @args[?i] != ?n,
|
27
|
+
}
|
28
|
+
@pattern = choose(@args[?p], pattern_opts)
|
29
|
+
end
|
26
30
|
@paths = []
|
27
31
|
reset_index
|
28
32
|
end
|
@@ -112,7 +116,9 @@ class Utils::Finder
|
|
112
116
|
paths.select! { |path| s.include?(File.extname(path)[1..-1]) }
|
113
117
|
end
|
114
118
|
paths = paths.map! do |path|
|
115
|
-
if
|
119
|
+
if @pattern.nil?
|
120
|
+
[ [ path.count(?/), path ], path, path ]
|
121
|
+
elsif match = @pattern.match(path)
|
116
122
|
if FuzzyPattern === @pattern
|
117
123
|
current = 0
|
118
124
|
marked_path = ''
|
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.52.1 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.52.1".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]
|