rbbt-util 5.26.72 → 5.26.73
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbbt/resource/path.rb +37 -15
- data/lib/rbbt/util/cmd.rb +47 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb3feb1e58b84ace085492fd7084cc1f86bb60544c9d25a1cc069a5217db9c27
|
4
|
+
data.tar.gz: 57863cf771d3ad64f651180e27f28ef4f6c88ea6a478d049e0a98d2acd717677
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56ae37215ec051636f1077815587e1cc7d2cd47ecf853a062c2a13f15ae9583e6cb43f6c222ee90f2a5e662d149967e53d1a63e79ab2b46803446e2c2ef7fd80
|
7
|
+
data.tar.gz: 25df8edcc598354c7f1e1311ab90b4545ba3f8ca76d70cd6f5f8f35df0ce727db9842294de443a855d25a84d799e529140fd848e22779f68cb521c22e64fc01b
|
data/lib/rbbt/resource/path.rb
CHANGED
@@ -51,11 +51,13 @@ module Path
|
|
51
51
|
|
52
52
|
def join(name)
|
53
53
|
raise "Invalid path: #{ self }" if self.nil?
|
54
|
-
if self.empty?
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
54
|
+
new = if self.empty?
|
55
|
+
self.annotate name.to_s.dup
|
56
|
+
else
|
57
|
+
self.annotate File.join(self, name.to_s)
|
58
|
+
end
|
59
|
+
new.original = File.join(self.original, name.to_s) if self.original
|
60
|
+
new
|
59
61
|
end
|
60
62
|
|
61
63
|
def dirname
|
@@ -72,9 +74,37 @@ module Path
|
|
72
74
|
self.glob_all
|
73
75
|
else
|
74
76
|
return [] unless self.exists?
|
75
|
-
|
76
|
-
|
77
|
+
found = self.find
|
78
|
+
exp = File.join(found, pattern)
|
79
|
+
paths = Dir.glob(exp).collect{|f| Path.setup(f, self.resource, self.pkgdir)}
|
80
|
+
|
81
|
+
paths.each do |p|
|
82
|
+
p.original = File.join(found.original, p.sub(/^#{found}/, ''))
|
83
|
+
end
|
84
|
+
|
85
|
+
paths
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def glob_all(pattern = nil, caller_lib = nil, search_paths = nil)
|
90
|
+
search_paths ||= @search_paths || SEARCH_PATHS
|
91
|
+
search_paths = search_paths.dup
|
92
|
+
|
93
|
+
location_paths = {}
|
94
|
+
search_paths.keys.collect do |where|
|
95
|
+
found = find(where, Path.caller_lib_dir, search_paths)
|
96
|
+
paths = pattern ? Dir.glob(File.join(found, pattern)) : Dir.glob(found)
|
97
|
+
|
98
|
+
paths.each do |p|
|
99
|
+
self.annotate p
|
100
|
+
p.original = File.join(found.original, p.sub(/^#{found}/, ''))
|
101
|
+
end
|
102
|
+
|
103
|
+
location_paths[where] = paths
|
77
104
|
end
|
105
|
+
|
106
|
+
#location_paths.values.compact.flatten.collect{|file| File.expand_path(file) }.uniq.collect{|path| Path.setup(path, self.resource, self.pkgdir)}
|
107
|
+
location_paths.values.compact.flatten.uniq
|
78
108
|
end
|
79
109
|
|
80
110
|
def [](name, orig = false)
|
@@ -232,14 +262,6 @@ module Path
|
|
232
262
|
compact.select{|file| file.exists? }.uniq
|
233
263
|
end
|
234
264
|
|
235
|
-
def glob_all(pattern = nil, caller_lib = nil, search_paths = nil)
|
236
|
-
search_paths ||= @search_paths || SEARCH_PATHS
|
237
|
-
search_paths = search_paths.dup
|
238
|
-
|
239
|
-
search_paths.keys.
|
240
|
-
collect{|where| pattern ? Dir.glob(File.join(find(where, Path.caller_lib_dir, search_paths), pattern)) : Dir.glob(find(where, Path.caller_lib_dir, search_paths)) }.
|
241
|
-
compact.flatten.collect{|file| File.expand_path(file)}.uniq.collect{|path| Path.setup(path, self.resource, self.pkgdir)}
|
242
|
-
end
|
243
265
|
#{{{ Methods
|
244
266
|
|
245
267
|
def in_dir?(dir)
|
data/lib/rbbt/util/cmd.rb
CHANGED
@@ -1,9 +1,40 @@
|
|
1
1
|
require 'rbbt/util/log'
|
2
2
|
require 'stringio'
|
3
3
|
require 'open3'
|
4
|
+
require 'rbbt/util/misc/indiferent_hash'
|
4
5
|
|
5
6
|
module CMD
|
6
7
|
|
8
|
+
TOOLS = IndiferentHash.setup({})
|
9
|
+
def self.tool(tool, claim = nil, test = nil, &block)
|
10
|
+
TOOLS[tool] = [claim, test, block]
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.get_tool(tool)
|
14
|
+
return tool.to_s unless TOOLS[tool]
|
15
|
+
|
16
|
+
@@init_cmd_tool ||= IndiferentHash.setup({})
|
17
|
+
if !@@init_cmd_tool[tool]
|
18
|
+
claim, test, block = TOOLS[tool]
|
19
|
+
begin
|
20
|
+
if test
|
21
|
+
CMD.cmd(test)
|
22
|
+
else
|
23
|
+
CMD.cmd("#{cmd} --help")
|
24
|
+
end
|
25
|
+
rescue
|
26
|
+
if claim
|
27
|
+
claim.produce
|
28
|
+
else
|
29
|
+
block.call
|
30
|
+
end
|
31
|
+
end
|
32
|
+
@@init_cmd_tool[tool] = true
|
33
|
+
end
|
34
|
+
|
35
|
+
tool.to_s
|
36
|
+
end
|
37
|
+
|
7
38
|
def self.gzip_pipe(file)
|
8
39
|
Open.gzip?(file) ? "<(gunzip -c '#{file}')" : "'#{file}'"
|
9
40
|
end
|
@@ -39,7 +70,9 @@ module CMD
|
|
39
70
|
string.strip
|
40
71
|
end
|
41
72
|
|
42
|
-
def self.cmd(cmd, options = {}, &block)
|
73
|
+
def self.cmd(tool, cmd = nil, options = {}, &block)
|
74
|
+
options, cmd = cmd, nil if Hash === cmd
|
75
|
+
|
43
76
|
options = Misc.add_defaults options, :stderr => Log::DEBUG
|
44
77
|
in_content = options.delete(:in)
|
45
78
|
stderr = options.delete(:stderr)
|
@@ -52,6 +85,18 @@ module CMD
|
|
52
85
|
dont_close_in = options.delete(:dont_close_in)
|
53
86
|
|
54
87
|
log = true if log.nil?
|
88
|
+
|
89
|
+
if cmd.nil? and ! Symbol === tool
|
90
|
+
cmd = tool
|
91
|
+
else
|
92
|
+
tool = get_tool(tool)
|
93
|
+
if cmd.nil?
|
94
|
+
cmd = tool
|
95
|
+
else
|
96
|
+
cmd = tool + ' ' + cmd
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
55
100
|
|
56
101
|
if stderr == true
|
57
102
|
stderr = Log::HIGH
|
@@ -170,4 +215,5 @@ module CMD
|
|
170
215
|
|
171
216
|
nil
|
172
217
|
end
|
218
|
+
|
173
219
|
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.26.
|
4
|
+
version: 5.26.73
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|