rbbt-util 5.5.34 → 5.5.35
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 +8 -8
- data/lib/rbbt/resource/path.rb +25 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjM2NWExYzgzODc2ZDUwYWI3N2NkZmRlYjY0MTE4MDkwOGY0ZWMyMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmFjOTY5NDgzMmE4ODI5NjE1NTdhZTVkZDFlN2Y0MTRjMTMxZjIxZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MGIyZmU0MzYyZmVkMzlhMzgyNGZhNzQ1OGRjOWZlMWJmYzgyMDhlZTg0OTk1
|
10
|
+
N2MwMTYzZDA1M2VjNjliMjUxMTQxMDdiNDM0OWNmOGNlYzI1OTJiZjMxZDIw
|
11
|
+
OTI1MmQ1ZjUyOTdlNGNlMjg3OWMyYmU0ZDgyMjNkYWEzOTM5ZmE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDgwOGEwYTMzZGY3NjkzN2JmZjE4ODhjZjdkMTM2NzljOGU2ZDNjYjIxMmUw
|
14
|
+
MGM1NDJmY2NkMjY2MDA3MWU5ZDRiNDYxNjVmZGM1ZWRjZWRjZDU2Y2U1NmQy
|
15
|
+
M2FmOGU0ZWE0ZTVmZGYwMGNkMDYzN2Q0NjQ2NmRhZTNmYjFhY2I=
|
data/lib/rbbt/resource/path.rb
CHANGED
@@ -2,22 +2,27 @@ require 'rbbt/resource/util'
|
|
2
2
|
require 'yaml'
|
3
3
|
|
4
4
|
module Path
|
5
|
-
attr_accessor :resource, :pkgdir
|
5
|
+
attr_accessor :resource, :pkgdir, :search_paths
|
6
6
|
|
7
|
-
def self.setup(string, pkgdir = nil, resource = nil)
|
7
|
+
def self.setup(string, pkgdir = nil, resource = nil, search_paths = nil)
|
8
8
|
string.extend Path
|
9
9
|
string.pkgdir = pkgdir || 'rbbt'
|
10
10
|
string.resource = resource
|
11
|
+
string.search_paths = search_paths
|
11
12
|
string
|
12
13
|
end
|
13
14
|
|
15
|
+
def sub(*args)
|
16
|
+
self.annotate super(*args)
|
17
|
+
end
|
18
|
+
|
14
19
|
def annotate(name)
|
15
|
-
Path.setup name.to_s, @pkgdir, @resource
|
20
|
+
Path.setup name.to_s, @pkgdir, @resource, @search_paths
|
16
21
|
end
|
17
22
|
|
18
23
|
def join(name)
|
19
24
|
if self.empty?
|
20
|
-
self.annotate name.to_s
|
25
|
+
self.annotate name.to_s.dup
|
21
26
|
else
|
22
27
|
self.annotate File.join(self, name.to_s)
|
23
28
|
end
|
@@ -77,9 +82,9 @@ module Path
|
|
77
82
|
end
|
78
83
|
end
|
79
84
|
|
80
|
-
def find(where = nil, caller_lib = nil,
|
81
|
-
|
82
|
-
|
85
|
+
def find(where = nil, caller_lib = nil, paths = nil)
|
86
|
+
paths = (self.search_paths || SEARCH_PATHS).merge(paths || {})
|
87
|
+
where = paths[:default] if where == :default
|
83
88
|
return self if located?
|
84
89
|
if self.match(/(.*?)\/(.*)/)
|
85
90
|
toplevel, subpath = self.match(/(.*?)\/(.*)/).values_at 1, 2
|
@@ -91,22 +96,28 @@ module Path
|
|
91
96
|
if where.nil?
|
92
97
|
%w(current user local global lib).each do |w|
|
93
98
|
w = w.to_sym
|
94
|
-
next unless
|
95
|
-
path = find(w, caller_lib,
|
99
|
+
next unless paths.include? w
|
100
|
+
path = find(w, caller_lib, paths)
|
96
101
|
return path if File.exists? path
|
97
102
|
end
|
98
|
-
if
|
99
|
-
find((
|
103
|
+
if paths.include? :default
|
104
|
+
find((paths[:default] || :user), caller_lib, paths)
|
100
105
|
else
|
101
|
-
raise "Path '#{ path }' not found, and no default specified in search paths: #{
|
106
|
+
raise "Path '#{ path }' not found, and no default specified in search paths: #{paths.inspect}"
|
102
107
|
end
|
103
108
|
else
|
104
109
|
where = where.to_sym
|
105
|
-
raise "Did not recognize the 'where' tag: #{where}. Options: #{
|
110
|
+
raise "Did not recognize the 'where' tag: #{where}. Options: #{paths.keys}" unless paths.include? where
|
106
111
|
libdir = where == :lib ? Path.caller_lib_dir(caller_lib) : ""
|
107
112
|
libdir ||= ""
|
108
113
|
pwd = FileUtils.pwd
|
109
|
-
|
114
|
+
self.annotate paths[where].
|
115
|
+
sub('{PKGDIR}', pkgdir).
|
116
|
+
sub('{PWD}', pwd).
|
117
|
+
sub('{TOPLEVEL}', toplevel).
|
118
|
+
sub('{SUBPATH}', subpath).
|
119
|
+
sub('{PATH}', self).
|
120
|
+
sub('{LIBDIR}', libdir) #, @pkgdir, @resource, @search_paths
|
110
121
|
end
|
111
122
|
end
|
112
123
|
|
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.5.
|
4
|
+
version: 5.5.35
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|