rbfind 1.12 → 1.13

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rbfind.rb +27 -15
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a5b34b291fdb3dcfd8ee289b1885bbd0ff848a3f46192f0ffdd174b19d6542f
4
- data.tar.gz: 66be0c062a8d7d00d42f5535c3aefa958676ffaacfb6f50e0d3d0f90eb9aeaa5
3
+ metadata.gz: b2e088901eba3d900228dba6ffb052866b3ffcf282622838625bbeb7ebfbf3b9
4
+ data.tar.gz: 7651789fed1a8d3963210d8c9efcc131c08840f94e00dcec518c7daae4072fc8
5
5
  SHA512:
6
- metadata.gz: 986974e1493ece3aac8896a8c262412bbf2e14687d6ff0f39647d4b1f7c324fbd7f263598049883b631c6bccc137cee982de52c5d170a9454c143738a7ee4a95
7
- data.tar.gz: d477bafd992ed7387d7cc4614a55650576f0414bab2fdcfc77981cbf69ca1b9eb068252fcbe75dda520fc2b6989b040c2face8d9d1c258f1f9a728178156ac1e
6
+ metadata.gz: 170d599e93cd82d128f3ea4541b6d4c92f04d21b79e15cd09a7c1de1f18d5a3bf4862b56bfa2ab2ccfb8229eef6e428135591f59f84b6b59266f129bb2e932be
7
+ data.tar.gz: 2f3dba6cca4000d736d77f054962bb0265a22414a3db2fc837d97bd2c68d17cb7e8d1c94f30e22725ead2d974fefec34e4acfc46df893a46c3df541c6ffa03aa
data/lib/rbfind.rb CHANGED
@@ -164,6 +164,8 @@ Derivated from stat:
164
164
  In case you did not call RbFind.colors, the environment variables
165
165
  RBFIND_COLORS and RBFIND_COLOURS are looked up. If neither is given
166
166
  but LSCOLORS is set, the fields 2-13 default to that.
167
+ A Gnu LS_COLOR-style string may also be given, though glob patterns will
168
+ not be unregarded. If LS_COLORS is set, the colors default to that.
167
169
 
168
170
  The letters mean:
169
171
  a = black, b = red, c = green, d = brown, e = blue,
@@ -269,7 +271,7 @@ Sort without case sensitivity and preceding dot:
269
271
 
270
272
  class RbFind
271
273
 
272
- VERSION = "1.12".freeze
274
+ VERSION = "1.13".freeze
273
275
 
274
276
  class <<self
275
277
  private :new
@@ -494,25 +496,35 @@ class RbFind
494
496
  class <<self
495
497
 
496
498
  def colors str
497
- @cols = []
498
- str.scan /(.)(.)/i do
499
- fg, bg = $~.captures.map { |x| x.downcase.ord - ?a.ord }
500
- a = []
501
- case fg
502
- when 0..7 then a.push 30 + fg
503
- end
504
- a.push 1 if $1 == $1.upcase
505
- case bg
506
- when 0..7 then a.push 40 + bg
499
+ if str =~ /:/ then
500
+ h = {}
501
+ (str.split ":").each { |a|
502
+ t, c = a.split "="
503
+ h[ t] = c
504
+ }
505
+ %w(rs or di ln so pi ex bd cd su sg tw ow - -).map { |t| h[ t] }
506
+ else
507
+ cols = []
508
+ str.scan /(.)(.)/i do
509
+ fg, bg = $~.captures.map { |x| x.downcase.ord - ?a.ord }
510
+ a = []
511
+ case fg
512
+ when 0..7 then a.push 30 + fg
513
+ end
514
+ a.push 1 if $1 == $1.upcase
515
+ case bg
516
+ when 0..7 then a.push 40 + bg
517
+ end
518
+ e = a.join ";"
519
+ cols.push e
507
520
  end
508
- e = a.join ";"
509
- @cols.push e
521
+ cols
510
522
  end
511
523
  end
512
524
  alias colours colors
513
525
 
514
526
  def colored arg, num
515
- @cols or colors col_str
527
+ @cols ||= colors col_str
516
528
  "\e[#{@cols[num]}m#{arg}\e[m"
517
529
  end
518
530
  alias coloured colored
@@ -520,7 +532,7 @@ class RbFind
520
532
  private
521
533
 
522
534
  def col_str
523
- ENV[ "RBFIND_COLORS"] || ENV[ "RBFIND_COLOURS"] || (
535
+ ENV[ "RBFIND_COLORS"] || ENV[ "RBFIND_COLOURS"] || ENV[ "LS_COLORS"] || (
524
536
  env = DEFAULT_COLORS.dup
525
537
  els = ENV[ "LSCOLORS"]
526
538
  if els then
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.12'
4
+ version: '1.13'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bertram Scharpf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-26 00:00:00.000000000 Z
11
+ date: 2020-05-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  A replacement for the standard UNIX command find.