scout-gear 2.0.0 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/.vimproject +65 -2
  3. data/Rakefile +2 -0
  4. data/VERSION +1 -1
  5. data/bin/scout +233 -24
  6. data/lib/scout/cmd.rb +344 -0
  7. data/lib/scout/concurrent_stream.rb +259 -0
  8. data/lib/scout/exceptions.rb +15 -8
  9. data/lib/scout/indiferent_hash/options.rb +8 -26
  10. data/lib/scout/log/color.rb +2 -2
  11. data/lib/scout/log/fingerprint.rb +11 -1
  12. data/lib/scout/log/progress/report.rb +0 -1
  13. data/lib/scout/log/progress/util.rb +1 -1
  14. data/lib/scout/log/progress.rb +4 -4
  15. data/lib/scout/log.rb +10 -2
  16. data/lib/scout/meta_extension.rb +19 -3
  17. data/lib/scout/misc/digest.rb +56 -0
  18. data/lib/scout/misc/filesystem.rb +26 -0
  19. data/lib/scout/misc/format.rb +17 -6
  20. data/lib/scout/misc/insist.rb +56 -0
  21. data/lib/scout/misc/monitor.rb +23 -0
  22. data/lib/scout/misc.rb +5 -11
  23. data/lib/scout/open/lock.rb +61 -0
  24. data/lib/scout/open/remote.rb +120 -0
  25. data/lib/scout/open/stream.rb +373 -0
  26. data/lib/scout/open/util.rb +225 -0
  27. data/lib/scout/open.rb +169 -0
  28. data/lib/scout/path/find.rb +68 -21
  29. data/lib/scout/path/tmpfile.rb +8 -0
  30. data/lib/scout/path/util.rb +14 -1
  31. data/lib/scout/path.rb +6 -30
  32. data/lib/scout/persist/open.rb +17 -0
  33. data/lib/scout/persist/path.rb +15 -0
  34. data/lib/scout/persist/serialize.rb +151 -0
  35. data/lib/scout/persist.rb +54 -0
  36. data/lib/scout/resource/path.rb +20 -0
  37. data/lib/scout/resource/produce/rake.rb +69 -0
  38. data/lib/scout/resource/produce.rb +246 -0
  39. data/lib/scout/resource/scout.rb +3 -0
  40. data/lib/scout/resource/util.rb +48 -0
  41. data/lib/scout/resource.rb +39 -0
  42. data/lib/scout/simple_opt/accessor.rb +1 -1
  43. data/lib/scout/simple_opt/doc.rb +29 -23
  44. data/lib/scout/simple_opt/parse.rb +4 -3
  45. data/lib/scout/tmpfile.rb +39 -1
  46. data/lib/scout/workflow/definition.rb +78 -0
  47. data/lib/scout/workflow/documentation.rb +83 -0
  48. data/lib/scout/workflow/step/info.rb +77 -0
  49. data/lib/scout/workflow/step/load.rb +18 -0
  50. data/lib/scout/workflow/step.rb +132 -0
  51. data/lib/scout/workflow/task/inputs.rb +114 -0
  52. data/lib/scout/workflow/task.rb +155 -0
  53. data/lib/scout/workflow/usage.rb +314 -0
  54. data/lib/scout/workflow/util.rb +11 -0
  55. data/lib/scout/workflow.rb +40 -0
  56. data/lib/scout-gear.rb +4 -0
  57. data/lib/scout.rb +1 -0
  58. data/lib/workflow-scout.rb +2 -0
  59. data/scout-gear.gemspec +77 -5
  60. data/scout_commands/alias +48 -0
  61. data/scout_commands/find +83 -0
  62. data/scout_commands/glob +0 -0
  63. data/scout_commands/rbbt +23 -0
  64. data/scout_commands/workflow/info +29 -0
  65. data/scout_commands/workflow/list +27 -0
  66. data/scout_commands/workflow/task +58 -0
  67. data/scout_commands/workflow/task_old +706 -0
  68. data/test/scout/indiferent_hash/test_options.rb +11 -1
  69. data/test/scout/misc/test_digest.rb +30 -0
  70. data/test/scout/misc/test_filesystem.rb +30 -0
  71. data/test/scout/misc/test_insist.rb +13 -0
  72. data/test/scout/open/test_lock.rb +52 -0
  73. data/test/scout/open/test_remote.rb +25 -0
  74. data/test/scout/open/test_stream.rb +515 -0
  75. data/test/scout/open/test_util.rb +73 -0
  76. data/test/scout/path/test_find.rb +28 -0
  77. data/test/scout/persist/test_open.rb +37 -0
  78. data/test/scout/persist/test_path.rb +37 -0
  79. data/test/scout/persist/test_serialize.rb +114 -0
  80. data/test/scout/resource/test_path.rb +40 -0
  81. data/test/scout/resource/test_produce.rb +62 -0
  82. data/test/scout/resource/test_util.rb +27 -0
  83. data/test/scout/simple_opt/test_doc.rb +16 -0
  84. data/test/scout/test_cmd.rb +85 -0
  85. data/test/scout/test_concurrent_stream.rb +29 -0
  86. data/test/scout/test_meta_extension.rb +9 -0
  87. data/test/scout/test_misc.rb +0 -7
  88. data/test/scout/test_open.rb +146 -0
  89. data/test/scout/test_path.rb +3 -1
  90. data/test/scout/test_persist.rb +83 -0
  91. data/test/scout/test_resource.rb +26 -0
  92. data/test/scout/test_workflow.rb +87 -0
  93. data/test/scout/workflow/step/test_info.rb +30 -0
  94. data/test/scout/workflow/step/test_load.rb +65 -0
  95. data/test/scout/workflow/task/test_inputs.rb +182 -0
  96. data/test/scout/workflow/test_definition.rb +0 -0
  97. data/test/scout/workflow/test_documentation.rb +30 -0
  98. data/test/scout/workflow/test_step.rb +36 -0
  99. data/test/scout/workflow/test_task.rb +179 -0
  100. data/test/scout/workflow/test_usage.rb +35 -0
  101. data/test/scout/workflow/test_util.rb +17 -0
  102. data/test/test_helper.rb +17 -0
  103. data/test/test_scout-gear.rb +0 -0
  104. metadata +75 -3
@@ -0,0 +1,314 @@
1
+ require 'scout/simple_opt'
2
+
3
+ module Task
4
+ def usage(workflow = nil, deps = nil)
5
+ str = StringIO.new
6
+ str.puts Log.color(:yellow, name)
7
+ str.puts Log.color(:yellow, "-" * name.length)
8
+ str.puts "\n" << Misc.format_paragraph(description.strip) << "\n" if description and not description.empty?
9
+ str.puts
10
+
11
+ selects = []
12
+ if inputs && inputs.any?
13
+ str.puts Log.color(:magenta, "Inputs")
14
+ str.puts
15
+ str.puts SOPT.input_array_doc(inputs)
16
+ str.puts
17
+ end
18
+
19
+ if deps and deps.any?
20
+ seen = inputs.collect{|name,_| name }
21
+ dep_inputs = {}
22
+ deps.each do |dep_workflow,task_name|
23
+ task = dep_workflow.tasks[task_name]
24
+ next if task.inputs.nil?
25
+ inputs = task.inputs.reject{|name, _| seen.include? name }
26
+ next unless inputs.any?
27
+ dep = workflow.nil? || dep_workflow.name != workflow.name ? ["#{dep_workflow.name}", task_name.to_s] *"#" : task_name.to_s
28
+ dep_inputs[dep] = inputs
29
+ end
30
+
31
+ str.puts Log.color(:magenta, "Inputs from dependencies:") if dep_inputs.any?
32
+ dep_inputs.each do |dep,inputs|
33
+ str.puts
34
+ str.puts Log.color :yellow, dep + ":"
35
+ str.puts
36
+ str.puts SOPT.input_array_doc(inputs)
37
+ str.puts
38
+ end
39
+
40
+ #task_inputs = dep_inputs deps, workflow
41
+ #task_inputs.each do |task,new_inputs|
42
+ # new_inputs.zip(task.input_types.values_at(*new_inputs)).select do |i,t|
43
+ # t.to_sym == :select and task.input_options[i][:select_options]
44
+ # end.each do |i,t|
45
+ # selects << [i, task.input_options[i][:select_options]]
46
+ # end
47
+
48
+ # next if new_inputs.empty?
49
+
50
+ # if task.workflow and task.workflow != workflow
51
+ # puts " #{Log.color :yellow, ["[#{task.workflow.to_s}]", task.name.to_s] *" "}:"
52
+ # else
53
+ # puts " #{Log.color :yellow, task.name.to_s}:"
54
+ # end
55
+ # puts unless Log.compact
56
+ # puts SOPT.input_doc(new_inputs, task.input_types, task.input_descriptions, task.input_defaults, true)
57
+ # puts unless Log.compact
58
+ #end
59
+ #puts
60
+ end
61
+
62
+ case
63
+ when inputs && inputs.select{|name,type| type == :array }.any?
64
+ str.puts Log.color(:green, Misc.format_paragraph("Lists are specified as arguments using ',' or '|'. When specified as files the '\\n'
65
+ also works in addition to the others. You may use the '--array_separator' option
66
+ the change this default. Whenever a file is specified it may also accept STDIN using
67
+ the '-' character."))
68
+ str.puts
69
+
70
+ when inputs && inputs.select{|name,type| type == :file || type == :tsv }.any?
71
+ str.puts Log.color(:green, Misc.format_paragraph("Whenever a file is specified it may also accept STDIN using the '-' character."))
72
+ str.puts
73
+ end
74
+
75
+ str.puts Log.color(:magenta, "Returns: ") << Log.color(:blue, type.to_s) << "\n"
76
+ str.puts
77
+
78
+ if selects.any?
79
+ str.puts Log.color(:magenta, "Input select options")
80
+ str.puts
81
+ selects.collect{|p| p}.uniq.each do |input,options|
82
+ str.puts Log.color(:blue, input.to_s + ": ") << Misc.format_paragraph(options.collect{|o| Array === o ? o.first.to_s : o.to_s} * ", ") << "\n"
83
+ str.puts unless Log.compact
84
+ end
85
+ str.puts
86
+ end
87
+ str.rewind
88
+ str.read
89
+ end
90
+
91
+ def SOPT_str
92
+ sopt_options = []
93
+ self.recursive_inputs.each do |name,type,desc,default,options|
94
+ shortcut = (options && options[:shortcut]) || name.to_s.slice(0,1)
95
+ boolean = type == :boolean
96
+
97
+ sopt_options << "-#{shortcut}--#{name}#{boolean ? "" : "*"}"
98
+ end
99
+
100
+ sopt_options * ":"
101
+ end
102
+
103
+ def get_SOPT(task)
104
+ sopt_option_string = self.SOPT_str
105
+ SOPT.get sopt_option_string
106
+ end
107
+ end
108
+
109
+ module Workflow
110
+
111
+ def dep_tree(task_name, seen = nil)
112
+ @dep_tree ||= {}
113
+ key = [self, task_name]
114
+
115
+ return @dep_tree[key] if @dep_tree.include?(key)
116
+ save = seen.nil?
117
+ seen = Set.new if seen.nil?
118
+
119
+ dep_tree = {}
120
+ task = self.tasks[task_name]
121
+ task.deps.each do |dep|
122
+ next if seen.include? dep
123
+ seen << dep
124
+ workflow, task, *rest = dep
125
+
126
+ key = [workflow, task]
127
+
128
+ dep_tree[key] = workflow.dep_tree(task, seen)
129
+ end if task.deps
130
+
131
+ @dep_tree[key] = dep_tree if save
132
+
133
+ dep_tree
134
+ end
135
+
136
+ def recursive_deps(task_name)
137
+ dependencies = []
138
+ dep_tree(task_name, dependencies)
139
+ dependencies
140
+ end
141
+
142
+ def _prov_tasks(tree)
143
+ tasks = []
144
+ heap = [tree]
145
+ while heap.any?
146
+ t = heap.pop
147
+ t.each do |k,v|
148
+ tasks << k
149
+ heap << v
150
+ end
151
+ end
152
+ tasks
153
+ end
154
+
155
+ def prov_string(tree)
156
+ description = ""
157
+
158
+ last = nil
159
+ seen = Set.new
160
+
161
+ tasks = _prov_tasks(tree)
162
+ tasks.each do |workflow,task_name|
163
+
164
+ next if seen.include?([workflow,task_name])
165
+
166
+ child = last && last.include?([workflow, task_name])
167
+ first = last.nil?
168
+ last = _prov_tasks(workflow.dep_tree(task_name))
169
+
170
+ break if child
171
+
172
+ if child
173
+ description << "->" << task_name.to_s
174
+ elsif first
175
+ description << "" << task_name.to_s
176
+ else
177
+ description << ";" << task_name.to_s
178
+ end
179
+
180
+ seen << [workflow, task_name]
181
+ end
182
+ description
183
+ end
184
+
185
+ def prov_tree(tree, offset = 0, seen = [])
186
+
187
+ return "" if tree.empty?
188
+
189
+ lines = []
190
+
191
+ offset_str = " " * offset
192
+
193
+ lines << offset_str
194
+
195
+ tree.each do |p,dtree|
196
+ next if seen.include?(p)
197
+ seen.push(p)
198
+ workflow, task = p
199
+ lines << offset_str + [workflow.to_s, task.to_s] * "#" + "\n" + workflow.prov_tree(dtree, offset + 1, seen)
200
+ end
201
+
202
+ lines * "\n"
203
+ end
204
+
205
+ def usage(task = nil, abridge = false)
206
+
207
+ str = StringIO.new
208
+
209
+ if self.documentation[:title] and not self.documentation[:title].empty?
210
+ title = self.name + " - " + self.documentation[:title]
211
+ str.puts Log.color :magenta, title
212
+ str.puts Log.color :magenta, "=" * title.length
213
+ else
214
+ str.puts Log.color :magenta, self.name
215
+ str.puts Log.color :magenta, "=" * self.name.length
216
+ end
217
+
218
+ if self.documentation[:description] and not self.documentation[:description].empty?
219
+ str.puts
220
+ str.puts Misc.format_paragraph self.documentation[:description]
221
+ str.puts
222
+ end
223
+
224
+
225
+ if task.nil?
226
+
227
+ str.puts Log.color :magenta, "## TASKS"
228
+ if self.documentation[:task_description] and not self.documentation[:task_description].empty?
229
+ str.puts
230
+ str.puts Misc.format_paragraph self.documentation[:task_description]
231
+ end
232
+ str.puts
233
+
234
+ final = Set.new
235
+ not_final = Set.new
236
+ tasks.each do |name,task|
237
+ tree = dep_tree(name)
238
+ not_final += tree.keys
239
+ final << name unless not_final.include?(name)
240
+ end
241
+
242
+ not_final.each do |p|
243
+ final -= [p.last]
244
+ end
245
+
246
+ tasks.each do |name,task|
247
+ description = task.description || ""
248
+ description = description.split("\n\n").first
249
+
250
+ next if abridge && ! final.include?(name)
251
+ str.puts Misc.format_definition_list_item(name.to_s, description, nil, nil, :yellow)
252
+
253
+ prov_string = prov_string(dep_tree(name))
254
+ str.puts Misc.format_paragraph Log.color(:blue, "->" + prov_string) if prov_string && ! prov_string.empty?
255
+ end
256
+
257
+ else
258
+
259
+ if Task === task
260
+ task_name = task.name
261
+ else
262
+ task_name = task
263
+ task = self.tasks[task_name]
264
+ end
265
+
266
+ #dependencies = self.rec_dependencies(task_name).collect{|dep_name| Array === dep_name ? dep_name.first.tasks[dep_name[1].to_sym] : self.tasks[dep_name.to_sym]}
267
+ str.puts task.usage(self, self.recursive_deps(task_name))
268
+
269
+ dep_tree = {[self, task_name] => dep_tree(task_name)}
270
+ prov_tree = prov_tree(dep_tree)
271
+ if prov_tree && ! prov_tree.empty? && prov_tree.split("\n").length > 2
272
+
273
+ str.puts Log.color :magenta, "## DEPENDENCY GRAPH (abridged)"
274
+ str.puts
275
+ prov_tree.split("\n").each do |line|
276
+ next if line.strip.empty?
277
+ if m = line.match(/^( *)(\w+?)#(\w*)/i)
278
+ offset, workflow, task_name = m.values_at 1, 2, 3
279
+ str.puts [offset, Log.color(:magenta, workflow), "#", Log.color(:yellow, task_name)] * ""
280
+ else
281
+ str.puts Log.color :blue, line
282
+ end
283
+ end
284
+ str.puts
285
+ end
286
+ end
287
+
288
+ str.rewind
289
+ str.read
290
+ end
291
+
292
+ def SOPT_str(task)
293
+ sopt_options = []
294
+ self.tasks[task].recursive_inputs.each do |name,type,desc,default,options|
295
+ shortcut = options[:shortcut] || name.to_s.slice(0,1)
296
+ boolean = type == :boolean
297
+
298
+ sopt_options << "-#{short}--#{name}#{boolean ? "" : "*"}"
299
+ end
300
+
301
+ sopt_options * ":"
302
+ end
303
+
304
+ def get_SOPT(task)
305
+ sopt_option_string = self.SOPT_str(task)
306
+ SOPT.get sopt_option_string
307
+ end
308
+
309
+ def self.get_SOPT(workflow, task)
310
+ workflow = Workflow.require_workflow workflow if String === workflow
311
+ task = workflow.tasks[task.to_sym] if String === task || Symbol === task
312
+ workflow.get_SOPT(task)
313
+ end
314
+ end
@@ -0,0 +1,11 @@
1
+ module Workflow
2
+ def self.annonymous_workflow(name = nil, &block)
3
+ mod = Module.new
4
+ mod.extend Workflow
5
+ mod.name = name
6
+ mod.directory = Workflow.directory[name] if name
7
+ mod.instance_eval(&block)
8
+ mod
9
+ end
10
+ end
11
+
@@ -0,0 +1,40 @@
1
+ require_relative 'workflow/definition'
2
+ require_relative 'workflow/util'
3
+ require_relative 'workflow/task'
4
+ require_relative 'workflow/step'
5
+ require_relative 'workflow/documentation'
6
+ require_relative 'workflow/usage'
7
+
8
+ require_relative 'resource'
9
+ require_relative 'resource/scout'
10
+
11
+ module Workflow
12
+ class << self
13
+ attr_accessor :workflows
14
+ def workflows
15
+ @workflows ||= []
16
+ end
17
+ end
18
+
19
+ attr_accessor :libdir
20
+ def self.extended(base)
21
+ self.workflows << base
22
+ libdir = Path.caller_lib_dir
23
+ return if libdir.nil?
24
+ base.libdir = Path.setup(libdir).tap{|p| p.resource = base}
25
+ end
26
+
27
+ def self.require_workflow(workflow)
28
+ workflow = Path.setup('workflows')[workflow]["workflow.rb"] unless Open.exists?(workflow)
29
+ if Open.exists?(workflow)
30
+ workflow = workflow.find if Path === workflow
31
+ load workflow
32
+ end
33
+ workflows.last
34
+ end
35
+
36
+ def job(name, *args)
37
+ task = tasks[name]
38
+ task.job(*args)
39
+ end
40
+ end
data/lib/scout-gear.rb CHANGED
@@ -1,5 +1,9 @@
1
+ require_relative 'scout/exceptions'
1
2
  require_relative 'scout/indiferent_hash'
2
3
  require_relative 'scout/tmpfile'
3
4
  require_relative 'scout/log'
4
5
  require_relative 'scout/path'
5
6
  require_relative 'scout/simple_opt'
7
+ require_relative 'scout/resource'
8
+ require_relative 'scout/resource/scout'
9
+ require_relative 'scout/persist'
data/lib/scout.rb ADDED
@@ -0,0 +1 @@
1
+ require 'workflow-scout'
@@ -0,0 +1,2 @@
1
+ require 'scout-gear'
2
+ require 'scout/workflow'
data/scout-gear.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: scout-gear 2.0.0 ruby lib
5
+ # stub: scout-gear 5.2.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "scout-gear".freeze
9
- s.version = "2.0.0"
9
+ s.version = "5.2.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Miguel Vazquez".freeze]
14
- s.date = "2023-03-30"
14
+ s.date = "2023-04-28"
15
15
  s.description = "Temporary files, logs, etc.".freeze
16
16
  s.email = "mikisvaz@gmail.com".freeze
17
17
  s.executables = ["scout".freeze]
@@ -29,6 +29,9 @@ Gem::Specification.new do |s|
29
29
  "VERSION",
30
30
  "bin/scout",
31
31
  "lib/scout-gear.rb",
32
+ "lib/scout.rb",
33
+ "lib/scout/cmd.rb",
34
+ "lib/scout/concurrent_stream.rb",
32
35
  "lib/scout/exceptions.rb",
33
36
  "lib/scout/indiferent_hash.rb",
34
37
  "lib/scout/indiferent_hash/case_insensitive.rb",
@@ -42,10 +45,30 @@ Gem::Specification.new do |s|
42
45
  "lib/scout/log/progress/util.rb",
43
46
  "lib/scout/meta_extension.rb",
44
47
  "lib/scout/misc.rb",
48
+ "lib/scout/misc/digest.rb",
49
+ "lib/scout/misc/filesystem.rb",
45
50
  "lib/scout/misc/format.rb",
51
+ "lib/scout/misc/insist.rb",
52
+ "lib/scout/misc/monitor.rb",
53
+ "lib/scout/open.rb",
54
+ "lib/scout/open/lock.rb",
55
+ "lib/scout/open/remote.rb",
56
+ "lib/scout/open/stream.rb",
57
+ "lib/scout/open/util.rb",
46
58
  "lib/scout/path.rb",
47
59
  "lib/scout/path/find.rb",
60
+ "lib/scout/path/tmpfile.rb",
48
61
  "lib/scout/path/util.rb",
62
+ "lib/scout/persist.rb",
63
+ "lib/scout/persist/open.rb",
64
+ "lib/scout/persist/path.rb",
65
+ "lib/scout/persist/serialize.rb",
66
+ "lib/scout/resource.rb",
67
+ "lib/scout/resource/path.rb",
68
+ "lib/scout/resource/produce.rb",
69
+ "lib/scout/resource/produce/rake.rb",
70
+ "lib/scout/resource/scout.rb",
71
+ "lib/scout/resource/util.rb",
49
72
  "lib/scout/simple_opt.rb",
50
73
  "lib/scout/simple_opt/accessor.rb",
51
74
  "lib/scout/simple_opt/doc.rb",
@@ -53,26 +76,75 @@ Gem::Specification.new do |s|
53
76
  "lib/scout/simple_opt/parse.rb",
54
77
  "lib/scout/simple_opt/setup.rb",
55
78
  "lib/scout/tmpfile.rb",
79
+ "lib/scout/workflow.rb",
80
+ "lib/scout/workflow/definition.rb",
81
+ "lib/scout/workflow/documentation.rb",
82
+ "lib/scout/workflow/step.rb",
83
+ "lib/scout/workflow/step/info.rb",
84
+ "lib/scout/workflow/step/load.rb",
85
+ "lib/scout/workflow/task.rb",
86
+ "lib/scout/workflow/task/inputs.rb",
87
+ "lib/scout/workflow/usage.rb",
88
+ "lib/scout/workflow/util.rb",
89
+ "lib/workflow-scout.rb",
56
90
  "scout-gear.gemspec",
91
+ "scout_commands/alias",
92
+ "scout_commands/find",
93
+ "scout_commands/glob",
94
+ "scout_commands/rbbt",
95
+ "scout_commands/workflow/info",
96
+ "scout_commands/workflow/list",
97
+ "scout_commands/workflow/task",
98
+ "scout_commands/workflow/task_old",
57
99
  "test/scout/indiferent_hash/test_case_insensitive.rb",
58
100
  "test/scout/indiferent_hash/test_options.rb",
59
101
  "test/scout/log/test_progress.rb",
102
+ "test/scout/misc/test_digest.rb",
103
+ "test/scout/misc/test_filesystem.rb",
104
+ "test/scout/misc/test_insist.rb",
105
+ "test/scout/open/test_lock.rb",
106
+ "test/scout/open/test_remote.rb",
107
+ "test/scout/open/test_stream.rb",
108
+ "test/scout/open/test_util.rb",
60
109
  "test/scout/path/test_find.rb",
61
110
  "test/scout/path/test_util.rb",
111
+ "test/scout/persist/test_open.rb",
112
+ "test/scout/persist/test_path.rb",
113
+ "test/scout/persist/test_serialize.rb",
114
+ "test/scout/resource/test_path.rb",
115
+ "test/scout/resource/test_produce.rb",
116
+ "test/scout/resource/test_util.rb",
117
+ "test/scout/simple_opt/test_doc.rb",
62
118
  "test/scout/simple_opt/test_get.rb",
63
119
  "test/scout/simple_opt/test_parse.rb",
64
120
  "test/scout/simple_opt/test_setup.rb",
121
+ "test/scout/test_cmd.rb",
122
+ "test/scout/test_concurrent_stream.rb",
65
123
  "test/scout/test_indiferent_hash.rb",
66
124
  "test/scout/test_log.rb",
67
125
  "test/scout/test_meta_extension.rb",
68
126
  "test/scout/test_misc.rb",
127
+ "test/scout/test_open.rb",
69
128
  "test/scout/test_path.rb",
129
+ "test/scout/test_persist.rb",
130
+ "test/scout/test_resource.rb",
70
131
  "test/scout/test_tmpfile.rb",
71
- "test/test_helper.rb"
132
+ "test/scout/test_workflow.rb",
133
+ "test/scout/workflow/step/test_info.rb",
134
+ "test/scout/workflow/step/test_load.rb",
135
+ "test/scout/workflow/task/test_inputs.rb",
136
+ "test/scout/workflow/test_definition.rb",
137
+ "test/scout/workflow/test_documentation.rb",
138
+ "test/scout/workflow/test_step.rb",
139
+ "test/scout/workflow/test_task.rb",
140
+ "test/scout/workflow/test_usage.rb",
141
+ "test/scout/workflow/test_util.rb",
142
+ "test/test_helper.rb",
143
+ "test/test_scout-gear.rb"
72
144
  ]
73
145
  s.homepage = "http://github.com/mikisvaz/scout-gear".freeze
74
146
  s.licenses = ["MIT".freeze]
75
- s.rubygems_version = "3.4.6".freeze
147
+ s.rubygems_version = "3.4.11".freeze
76
148
  s.summary = "basic gear for scouts".freeze
77
149
 
78
150
  s.specification_version = 4
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'scout-gear'
4
+
5
+ $0 = "scout #{$previous_commands.any? ? $previous_commands*" " + " " : "" }#{ File.basename(__FILE__) }" if $previous_commands
6
+
7
+ options = SOPT.setup <<EOF
8
+
9
+ Creates a one work comman alias.
10
+
11
+ $ #{$0} <alias> [<options>] [<othercmd>]*
12
+
13
+ The other commands might include options. But beware the some might reach the alias if they where consumed
14
+ earlier, like --dev or --log. Edit #{Scout.ect.cmd_alias.find} to fine tune.
15
+
16
+ -h--help Print this help
17
+ EOF
18
+ if options[:help]
19
+ if defined? scout_usage
20
+ scout_usage
21
+ else
22
+ puts SOPT.doc
23
+ end
24
+ exit 0
25
+ end
26
+
27
+ cmd, *rest = ARGV
28
+
29
+ aliases ||= Scout.etc.cmd_alias.exists? ? Scout.etc.cmd_alias.yaml : {}
30
+
31
+ if cmd.nil?
32
+ aliases.each do |name, parts|
33
+ parts = parts.collect{|p|
34
+ p =~ /^[\w:_\/-]*$/ ? p : "'" << p << "'"
35
+ }
36
+ puts [Log.color(:magenta, name), parts * " "] * ": "
37
+ end
38
+ exit 0
39
+ end
40
+
41
+ if rest.empty?
42
+ aliases.delete cmd
43
+ else
44
+ aliases[cmd] = rest
45
+ end
46
+
47
+ Open.write(Scout.etc.cmd_alias.find,(aliases.to_yaml))
48
+
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'scout-gear'
4
+
5
+ $0 = "scout #{$previous_commands.any? ? $previous_commands*" " + " " : "" }#{ File.basename(__FILE__) }" if $previous_commands
6
+
7
+ options = SOPT.setup <<EOF
8
+
9
+ Find files
10
+
11
+ $ #{$0} [<options>] (<resource> <path>|<path>)
12
+
13
+ -h--help Print this help
14
+ -r--requires* Files to require; 'all' for all in Scout.etc.requires
15
+ -lw--load_workflow* Files to require; 'all' for all in Scout.etc.requires
16
+ -w--where* Where to look for the path
17
+ EOF
18
+ if options[:help]
19
+ if defined? scout_usage
20
+ scout_usage
21
+ else
22
+ puts SOPT.doc
23
+ end
24
+ exit 0
25
+ end
26
+
27
+ resource, path = ARGV
28
+ path, resource = resource, nil if path.nil?
29
+
30
+ raise MissingParameterException.new(:path) if path.nil?
31
+
32
+ case options[:workflows]
33
+ when nil, false, "false", "none"
34
+ when "all"
35
+ Scout.etc.workflows.list.each do |workflow|
36
+ Workflow.require_workflow file
37
+ end if Scout.etc.workflows.exists?
38
+ else
39
+ options[:workflows].split(/[ ,;|]/).each do |workflow|
40
+ Workflow.require_workflow workflow
41
+ end
42
+ end
43
+
44
+ case options[:requires]
45
+ when nil, false, "false", "none"
46
+ when "all"
47
+ Scout.etc.requires.list.each do |file|
48
+ require file
49
+ end if Scout.etc.requires.exists?
50
+ else
51
+ options[:requires].split(/[ ,;|]/).each do |file|
52
+ require file
53
+ end
54
+ end
55
+
56
+ location = nil
57
+ where = options[:where]
58
+ all = options[:all]
59
+
60
+ begin
61
+ resource = Workflow.require_workflow resource
62
+ rescue
63
+ begin
64
+ resource = Kernel.const_get(resource)
65
+ rescue
66
+ raise "Resource not found: #{ resource }"
67
+ end
68
+ end if resource
69
+
70
+ path = (resource || Scout)[path.dup]
71
+
72
+ if where.nil? || where == 'all' || path.search_paths.include?(where.to_sym)
73
+ location = path.find(where)
74
+
75
+ if Array === location
76
+ puts location * "\n"
77
+ else
78
+ location = nil if ! Open.exists?(location)
79
+ puts location
80
+ end
81
+ else
82
+ puts SSHLine.command(where, $0, ARGV, options.merge("where" => :all))
83
+ end
File without changes
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ case
3
+ when File.exist?(file = File.join(__dir__, '../modules/rbbt-util/bin/rbbt'))
4
+ $LOAD_PATH.unshift(lib_dir = File.join(file, '../..', 'lib'))
5
+ require_relative File.join(lib_dir,'rbbt-util')
6
+ Path.add_path(:rbbt, File.expand_path(File.join(File.dirname(lib_dir), "/{TOPLEVEL}/{SUBPATH}")))
7
+ Path.default_pkgdir = Rbbt
8
+ load file
9
+ when File.exist?(file = File.join(ENV["HOME"], 'git/scout-gear/modules/rbbt-util/bin/rbbt'))
10
+ $LOAD_PATH.unshift(lib_dir = File.join(file, '../..', 'lib'))
11
+ require_relative File.join(lib_dir,'rbbt-util')
12
+ Path.add_path(:rbbt, File.expand_path(File.join(File.dirname(lib_dir), "/{TOPLEVEL}/{SUBPATH}")))
13
+ Path.default_pkgdir = Rbbt
14
+ load file
15
+ when File.exist?(file = File.join(ENV["HOME"], 'git/rbbt-util/bin/rbbt'))
16
+ $LOAD_PATH.unshift(lib_dir = File.join(file, '../..', 'lib'))
17
+ require_relative File.join(lib_dir,'rbbt-util')
18
+ Path.add_path(:rbbt, File.expand_path(File.join(File.dirname(lib_dir), "/{TOPLEVEL}/{SUBPATH}")))
19
+ Path.default_pkgdir = Rbbt
20
+ load file
21
+ else
22
+ raise "Cant find rbbt"
23
+ end