rbfind 1.4 → 1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/rbfind +4 -4
- data/lib/rbfind.rb +27 -16
- metadata +8 -10
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 280a77034256c49e824e1f17d34f4203ba674928
|
4
|
+
data.tar.gz: 88f8c7ba6ccdef27cc598b0d8a0886791ea8f6ec
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 829dfbb87533f8042ad9ed3b663d032858bd13e9987855b253a9745859c441dca8944d8df67d9f113589bdc06fe285f59c304817479ec78df3ca65cc1d60c2d1
|
7
|
+
data.tar.gz: 6f920a815b6710ef37c9d2e169cebbc7b9208cf6cb68b870aead72b1983ed905237d2b99ecdc408270100d8f430a9e73535bf6363ba93d1bbe9698819fd9d24e
|
data/bin/rbfind
CHANGED
@@ -209,7 +209,7 @@ def set_encoding extern, intern = nil
|
|
209
209
|
end
|
210
210
|
|
211
211
|
|
212
|
-
class
|
212
|
+
class RbFindApp < RbFind
|
213
213
|
|
214
214
|
# Alias the question marks away from all method names because
|
215
215
|
# they're a nuisance on the command line.
|
@@ -375,9 +375,9 @@ error_handle do
|
|
375
375
|
opath = co ? "cpath" : "path"
|
376
376
|
case @lines
|
377
377
|
when :plain then
|
378
|
-
@puts and @block = "( #@block ) and colsep #{opath},
|
378
|
+
@puts and @block = "( #@block ) and colsep #{opath}, num, line"
|
379
379
|
@real and @block = "break if ~/\0/o ; #@block"
|
380
|
-
@block = "lines { |line,num|
|
380
|
+
@block = "lines { |line,num| #@block }"
|
381
381
|
|
382
382
|
when :grep then
|
383
383
|
RE = Regexp.new @block, @icase && Regexp::IGNORECASE
|
@@ -474,7 +474,7 @@ end
|
|
474
474
|
EOT
|
475
475
|
|
476
476
|
eval @blkbegin if @blkbegin
|
477
|
-
|
477
|
+
RbFindApp.open args, @params do |f| f.instance_eval @block end
|
478
478
|
eval @blkend if @blkend
|
479
479
|
end
|
480
480
|
|
data/lib/rbfind.rb
CHANGED
@@ -249,7 +249,7 @@ Sort without case sensitivity and preceding dot:
|
|
249
249
|
|
250
250
|
class RbFind
|
251
251
|
|
252
|
-
VERSION = "1.
|
252
|
+
VERSION = "1.5".freeze
|
253
253
|
|
254
254
|
class <<self
|
255
255
|
private :new
|
@@ -259,12 +259,13 @@ class RbFind
|
|
259
259
|
end
|
260
260
|
args.flatten!
|
261
261
|
if args.any? then
|
262
|
-
|
263
|
-
|
264
|
-
count
|
262
|
+
count = 0
|
263
|
+
args.each do |path|
|
264
|
+
f = new path, count, params, &block
|
265
|
+
count = f.count
|
265
266
|
end
|
266
267
|
else
|
267
|
-
f = new nil, params, &block
|
268
|
+
f = new nil, 0, params, &block
|
268
269
|
f.count
|
269
270
|
end
|
270
271
|
end
|
@@ -275,17 +276,15 @@ class RbFind
|
|
275
276
|
|
276
277
|
attr_reader :count, :wd, :start
|
277
278
|
|
278
|
-
def initialize path, params = nil, &block
|
279
|
+
def initialize path, count, params = nil, &block
|
279
280
|
@levels = []
|
280
281
|
@block = block
|
281
282
|
|
282
283
|
if params then
|
283
284
|
params = params.dup
|
284
285
|
dl = :do_level_depth if params.delete :depth
|
285
|
-
md = params.delete :max_depth
|
286
|
-
|
287
|
-
st = params.delete :sort
|
288
|
-
@sort = sort_parser st
|
286
|
+
md = params.delete :max_depth ; @max_depth = md.to_i if md
|
287
|
+
st = params.delete :sort ; @sort = sort_parser st
|
289
288
|
@follow = params.delete :follow
|
290
289
|
@error = params.delete :error
|
291
290
|
params.empty? or
|
@@ -293,7 +292,7 @@ class RbFind
|
|
293
292
|
end
|
294
293
|
@do_level = method dl||:do_level
|
295
294
|
|
296
|
-
@start, @count = Time.now,
|
295
|
+
@start, @count = Time.now, count
|
297
296
|
@wd = Dir.getwd
|
298
297
|
if path then
|
299
298
|
File.lstat path
|
@@ -616,10 +615,11 @@ class RbFind
|
|
616
615
|
block_given? or return lines do end
|
617
616
|
open { |file|
|
618
617
|
n = 0
|
619
|
-
file.each_line { |
|
618
|
+
file.each_line { |l|
|
619
|
+
l.chomp!
|
620
620
|
n += 1
|
621
|
-
|
622
|
-
yield
|
621
|
+
set_predefs l, n
|
622
|
+
yield l, n
|
623
623
|
}
|
624
624
|
n
|
625
625
|
}
|
@@ -781,7 +781,7 @@ class RbFind
|
|
781
781
|
|
782
782
|
def do_level
|
783
783
|
begin
|
784
|
-
|
784
|
+
call_block
|
785
785
|
rescue Prune
|
786
786
|
return
|
787
787
|
end
|
@@ -796,12 +796,23 @@ class RbFind
|
|
796
796
|
@path, @fullpath = path, fullpath
|
797
797
|
end
|
798
798
|
begin
|
799
|
-
|
799
|
+
call_block
|
800
800
|
rescue Prune
|
801
801
|
raise RuntimeError, "#{self.class}: prune doesn't work with :depth."
|
802
802
|
end
|
803
803
|
end
|
804
804
|
|
805
|
+
def call_block
|
806
|
+
set_predefs name, count
|
807
|
+
@block.call self
|
808
|
+
end
|
809
|
+
|
810
|
+
def set_predefs l, n
|
811
|
+
b = @block.binding
|
812
|
+
b.local_variable_set "_", [ l, n]
|
813
|
+
b.eval "$_, $. = *_"
|
814
|
+
end
|
815
|
+
|
805
816
|
def read_dir
|
806
817
|
handle_error Errno::EACCES do
|
807
818
|
Dir.new @path
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbfind
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
5
|
-
prerelease:
|
4
|
+
version: '1.5'
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Bertram Scharpf
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-07-14 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: |
|
15
14
|
A replacement for the standard UNIX command find.
|
@@ -23,14 +22,15 @@ extensions: []
|
|
23
22
|
extra_rdoc_files:
|
24
23
|
- LICENSE
|
25
24
|
files:
|
26
|
-
- README
|
27
|
-
- lib/rbfind.rb
|
28
|
-
- lib/humansiz.rb
|
29
25
|
- LICENSE
|
26
|
+
- README
|
30
27
|
- bin/rbfind
|
28
|
+
- lib/humansiz.rb
|
29
|
+
- lib/rbfind.rb
|
31
30
|
homepage: http://www.bertram-scharpf.de/software/rbfind
|
32
31
|
licenses:
|
33
32
|
- BSD
|
33
|
+
metadata: {}
|
34
34
|
post_install_message:
|
35
35
|
rdoc_options:
|
36
36
|
- "--charset"
|
@@ -40,13 +40,11 @@ rdoc_options:
|
|
40
40
|
require_paths:
|
41
41
|
- lib
|
42
42
|
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
43
|
requirements:
|
45
44
|
- - ">="
|
46
45
|
- !ruby/object:Gem::Version
|
47
46
|
version: '0'
|
48
47
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
48
|
requirements:
|
51
49
|
- - ">="
|
52
50
|
- !ruby/object:Gem::Version
|
@@ -54,8 +52,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
52
|
requirements:
|
55
53
|
- just Ruby
|
56
54
|
rubyforge_project:
|
57
|
-
rubygems_version:
|
55
|
+
rubygems_version: 2.4.8
|
58
56
|
signing_key:
|
59
|
-
specification_version:
|
57
|
+
specification_version: 4
|
60
58
|
summary: Ruby replacement for the standard Unix find tool
|
61
59
|
test_files: []
|