rbfind 1.6 → 1.7
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/rbfind +5 -1
- data/lib/rbfind.rb +31 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d413b6a0596612705aacf768c8af9407c2c64161
|
4
|
+
data.tar.gz: 3ed66abdf7704a6c3b90698049f00cac540334b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6458cc0c355cdd83fecaadf2deca6d139bd2300e5316a3664976b9491636d5e15fe51a5d0e684fdc0359f38cfecc22c9fb09be27bebadae90dd4a7e50f22506
|
7
|
+
data.tar.gz: 4768b3d7faa520c476bcc75c9e8803f06d2edb9682231e001b3d3b12fabb711de6eb109d39850707beb0c88bcf212b36f42c52afba7523488c32fc2b8e3c0b35
|
data/bin/rbfind
CHANGED
@@ -353,12 +353,16 @@ def error_handle
|
|
353
353
|
show_error $!
|
354
354
|
if $!.message[ "invalid byte sequence"] then
|
355
355
|
$stderr.puts <<-EOT
|
356
|
-
Hint: Try to give
|
356
|
+
Hint: Try to give a different default encoding by explicitly setting one or
|
357
357
|
by changing the locale.
|
358
358
|
|
359
359
|
$ rbfind -K ascii-8bit ...
|
360
360
|
$ LC_ALL="C" rbfind ...
|
361
361
|
|
362
|
+
Alternatively, you may prefer to scrub the invalid encodings yourself.
|
363
|
+
|
364
|
+
$ rbfind -P 'name.scrub =~ /Fu.ball/'
|
365
|
+
|
362
366
|
EOT
|
363
367
|
end
|
364
368
|
exit 1
|
data/lib/rbfind.rb
CHANGED
@@ -58,6 +58,7 @@ In Ruby programs, you may call:
|
|
58
58
|
RbFind.run do puts path end
|
59
59
|
RbFind.run "dir" do puts path end
|
60
60
|
|
61
|
+
|
61
62
|
== File properties
|
62
63
|
|
63
64
|
f.name # file name (*)
|
@@ -199,6 +200,29 @@ Derivated from stat:
|
|
199
200
|
f.suffix # ls-like suffixes |@=/%* for pipe, ..., executable
|
200
201
|
|
201
202
|
|
203
|
+
== Encoding issues
|
204
|
+
|
205
|
+
Ruby raises an ArgumentError if, for example, an ISO8859-1-encoded
|
206
|
+
string gets read in as UTF-8-encoded and then is matched against a
|
207
|
+
UTF-8-encoded regular expression. This will happen if you are
|
208
|
+
running RbFind from an environment with something like
|
209
|
+
LC_ALL="de_DE.UTF-8" and if you are searching directories containing
|
210
|
+
single-byte encoded file names or files with single-byte or binary
|
211
|
+
content.
|
212
|
+
|
213
|
+
The #grep facility will will condone encoding mismatches by calling
|
214
|
+
the String#scrub! method. But neither the #lines and #read function
|
215
|
+
will do any transformation nor will the file names and the path
|
216
|
+
specifications be changed.
|
217
|
+
|
218
|
+
In short, if you are using the #grep method, or the -g option on the
|
219
|
+
command line you will not need to care about encoding problems. On
|
220
|
+
the other hand, if you specify the =~ operator, you will be
|
221
|
+
responsible for calling the String#scrub method yourself. Please do
|
222
|
+
not try to call the String#scrub! (bang) method for the name and path
|
223
|
+
variables because these will be used in the further processing.
|
224
|
+
|
225
|
+
|
202
226
|
== Examples
|
203
227
|
|
204
228
|
Find them all:
|
@@ -253,7 +277,7 @@ Sort without case sensitivity and preceding dot:
|
|
253
277
|
|
254
278
|
class RbFind
|
255
279
|
|
256
|
-
VERSION = "1.
|
280
|
+
VERSION = "1.7".freeze
|
257
281
|
|
258
282
|
class <<self
|
259
283
|
private :new
|
@@ -646,6 +670,7 @@ class RbFind
|
|
646
670
|
else raise "Illegal color spec: #{color}"
|
647
671
|
end
|
648
672
|
lines { |l,i|
|
673
|
+
l.scrub!
|
649
674
|
l =~ re or next
|
650
675
|
if color then
|
651
676
|
l = "#$`\e[#{color}m#$&\e[m#$'"
|
@@ -742,8 +767,9 @@ class RbFind
|
|
742
767
|
nb = File.basename newname
|
743
768
|
newname == nb or raise RuntimeError,
|
744
769
|
"#{self.class}: rename to `#{newname}' may not be a path."
|
770
|
+
nb.freeze
|
745
771
|
@levels.pop
|
746
|
-
@levels.push
|
772
|
+
@levels.push nb
|
747
773
|
build_path
|
748
774
|
File.rename p, @path
|
749
775
|
nil
|
@@ -784,6 +810,8 @@ class RbFind
|
|
784
810
|
@path
|
785
811
|
end
|
786
812
|
if @path.empty? then @path = Dir::CUR_DIR end
|
813
|
+
@fullpath.freeze
|
814
|
+
@path.freeze
|
787
815
|
end
|
788
816
|
|
789
817
|
def walk
|
@@ -853,6 +881,7 @@ class RbFind
|
|
853
881
|
dir.reverse! if @sort < 0
|
854
882
|
end
|
855
883
|
dir.each { |f|
|
884
|
+
f.freeze
|
856
885
|
begin
|
857
886
|
@levels.push f
|
858
887
|
walk
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbfind
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.7'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bertram Scharpf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
A replacement for the standard UNIX command find.
|
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
52
|
requirements:
|
53
53
|
- just Ruby
|
54
54
|
rubyforge_project:
|
55
|
-
rubygems_version: 2.
|
55
|
+
rubygems_version: 2.6.2
|
56
56
|
signing_key:
|
57
57
|
specification_version: 4
|
58
58
|
summary: Ruby replacement for the standard Unix find tool
|