rbbt-util 5.37.6 → 5.37.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6099d98f98d577fdbd0905ff42af44894701583fafab809b35c163f9d3482cb8
4
- data.tar.gz: 8b8ab79b18d6dc143b823afa52e8ab3833a2268cdaa9f22e1b9053d1ee84edcc
3
+ metadata.gz: b5c4e63f52c80871ada12e77c2c2cfe0d2cacb9d4bb3cf13fde88f814d30987b
4
+ data.tar.gz: e3859c1668e92be90edf4ca5637480e8d74aa26822c0f3181f8d9a1689e6dc0b
5
5
  SHA512:
6
- metadata.gz: e64c7bd047bf9eb108c9e8176daf9aac8d2f198b65c365d55e628119435b5392299414ada948f7fece30572a26223b150bb2a6bc631f6f25f2225e59adc9ded4
7
- data.tar.gz: 79edde0ca6ea40b5c178603f530605cc18a2f4ea44eed731393015fe16ae33a8579ce1254f761890d81fdc12e0e90664708a5c54d0bd10cbbf2a2a36a6ee8538
6
+ metadata.gz: 1f15f9954cf3f4ad93859d98155c6b34af5beeba3286367732a71c2e9093d97477ec405d300eded639e93470bf8b8f466014e79eaaddedb621c0df2862ac0e01
7
+ data.tar.gz: 80f82e5ca9262aad1ce8300de0a486234017c6a3a450ae9579bbbeeca1062dac4ab42d3c31276d5546d882a3efa32520658efec18847099c0ae5f8ee93daab7b
data/lib/rbbt/resource.rb CHANGED
@@ -351,6 +351,7 @@ url='#{url}'
351
351
 
352
352
  def identify(path)
353
353
  path = File.expand_path(path)
354
+ path += "/" if File.directory?(path)
354
355
  resource ||= Rbbt
355
356
  locations = (Path::STANDARD_SEARCH + resource.search_order + resource.search_paths.keys)
356
357
  locations -= [:current, "current"]
@@ -363,7 +364,10 @@ url='#{url}'
363
364
 
364
365
  pattern = pattern.sub('{PWD}', Dir.pwd)
365
366
  if String === pattern and pattern.include?('{')
366
- regexp = "^" + pattern.gsub(/{([^}]+)}/,'(?<\1>[^/]+)') + "(?:/(?<REST>.*))?/?$"
367
+ regexp = "^" + pattern
368
+ .gsub(/{(TOPLEVEL)}/,'(?<\1>[^/]+)')
369
+ .gsub(/{([^}]+)}/,'(?<\1>[^/]+)?') +
370
+ "(?:/(?<REST>.*))?/?$"
367
371
  if m = path.match(regexp)
368
372
  if ! m.named_captures.include?("PKGDIR") || m["PKGDIR"] == resource.pkgdir
369
373
  return self[m["TOPLEVEL"]][m["SUBPATH"]][m["REST"]]
@@ -17,13 +17,20 @@ puts path.glob_all.collect{|p| File.directory?(p) ? p + "/" : p } * "\n"
17
17
 
18
18
  [path, paths.collect{|p| [source, p] * ":"}, lpath]
19
19
  else
20
+ original_path = Path.setup(path)
20
21
  if File.exist?(path)
21
22
  path = resource.identify(path)
22
23
  else
23
24
  path = Path.setup(path)
24
25
  end
25
26
 
26
- [path, (path.directory? ? path.glob_all : path.find_all), path]
27
+ if original_path.located?
28
+ paths = [original_path]
29
+ else
30
+ paths = (path.directory? ? path.glob_all : path.find_all)
31
+ end
32
+
33
+ [path, paths, path]
27
34
  end
28
35
  end
29
36
 
@@ -54,9 +61,9 @@ puts resource[path].find(search_path)
54
61
 
55
62
  real_paths.each do |source_path|
56
63
  Log.medium "Migrating #{source_path} #{options[:files].length} files to #{target} - #{Misc.fingerprint(options[:files])}}" if options[:files]
57
- if File.directory?(source_path) || source_path =~ /\/$/
58
- source_path += "/" unless source_path[-1] == "/"
59
- target += "/" unless target[-1] == "/"
64
+ if File.directory?(source_path) || source_path.ends_with?("/")
65
+ source_path += "/" unless source_path.end_with? '/'
66
+ target += "/" unless target.end_with? '/'
60
67
  end
61
68
 
62
69
  next if source_path == target
@@ -1,4 +1,3 @@
1
- #require 'rbbt/util/chain_methods'
2
1
  require 'rbbt/util/misc'
3
2
 
4
3
  module NamedArray
@@ -505,4 +505,3 @@ yellow2 #eeee00
505
505
  yellow3 #cdcd00
506
506
  yellow4 #8b8b00
507
507
  YellowGreen #9acd32
508
-
@@ -94,8 +94,12 @@ class TestTSV < Test::Unit::TestCase
94
94
  end
95
95
 
96
96
  def test_identify
97
+ assert_equal 'etc/', Rbbt.identify(File.join(ENV["HOME"], '.rbbt/etc/'))
98
+ assert_equal 'share/databases/', Rbbt.identify('/usr/local/share/rbbt/databases/')
99
+ assert_equal 'share/databases/DATABASE', Rbbt.identify('/usr/local/share/rbbt/databases/DATABASE')
97
100
  assert_equal 'share/databases/DATABASE/FILE', Rbbt.identify('/usr/local/share/rbbt/databases/DATABASE/FILE')
98
101
  assert_equal 'share/databases/DATABASE/FILE', Rbbt.identify(File.join(ENV["HOME"], '.rbbt/share/databases/DATABASE/FILE'))
102
+ assert_equal 'share/databases/DATABASE/FILE', Rbbt.identify('/usr/local/share/rbbt/databases/DATABASE/FILE')
99
103
  end
100
104
 
101
105
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.37.6
4
+ version: 5.37.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-09 00:00:00.000000000 Z
11
+ date: 2023-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake