scout-gear 1.2.0 → 5.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +4 -0
  3. data/.vimproject +663 -4
  4. data/Rakefile +1 -0
  5. data/VERSION +1 -1
  6. data/bin/scout +235 -0
  7. data/lib/scout/cmd.rb +344 -0
  8. data/lib/scout/concurrent_stream.rb +259 -0
  9. data/lib/scout/exceptions.rb +15 -8
  10. data/lib/scout/indiferent_hash/options.rb +8 -26
  11. data/lib/scout/indiferent_hash.rb +0 -30
  12. data/lib/scout/log/color.rb +2 -2
  13. data/lib/scout/log/fingerprint.rb +11 -1
  14. data/lib/scout/log/progress/report.rb +0 -1
  15. data/lib/scout/log/progress/util.rb +1 -1
  16. data/lib/scout/log/progress.rb +4 -4
  17. data/lib/scout/log.rb +10 -2
  18. data/lib/scout/meta_extension.rb +15 -1
  19. data/lib/scout/misc/digest.rb +56 -0
  20. data/lib/scout/misc/filesystem.rb +26 -0
  21. data/lib/scout/misc/format.rb +226 -0
  22. data/lib/scout/misc/insist.rb +56 -0
  23. data/lib/scout/misc.rb +5 -11
  24. data/lib/scout/open/lock.rb +61 -0
  25. data/lib/scout/open/remote.rb +120 -0
  26. data/lib/scout/open/stream.rb +372 -0
  27. data/lib/scout/open/util.rb +225 -0
  28. data/lib/scout/open.rb +169 -0
  29. data/lib/scout/path/find.rb +78 -26
  30. data/lib/scout/path/tmpfile.rb +8 -0
  31. data/lib/scout/path/util.rb +17 -5
  32. data/lib/scout/path.rb +13 -31
  33. data/lib/scout/persist/open.rb +17 -0
  34. data/lib/scout/persist/path.rb +15 -0
  35. data/lib/scout/persist/serialize.rb +140 -0
  36. data/lib/scout/persist.rb +54 -0
  37. data/lib/scout/resource/path.rb +15 -0
  38. data/lib/scout/resource/produce/rake.rb +69 -0
  39. data/lib/scout/resource/produce.rb +246 -0
  40. data/lib/scout/resource/scout.rb +3 -0
  41. data/lib/scout/resource.rb +37 -0
  42. data/lib/scout/simple_opt/accessor.rb +54 -0
  43. data/lib/scout/simple_opt/doc.rb +102 -0
  44. data/lib/scout/simple_opt/get.rb +57 -0
  45. data/lib/scout/simple_opt/parse.rb +67 -0
  46. data/lib/scout/simple_opt/setup.rb +26 -0
  47. data/lib/scout/simple_opt.rb +5 -0
  48. data/lib/scout/tmpfile.rb +39 -1
  49. data/lib/scout/workflow/definition.rb +72 -0
  50. data/lib/scout/workflow/documentation.rb +77 -0
  51. data/lib/scout/workflow/step/info.rb +77 -0
  52. data/lib/scout/workflow/step.rb +96 -0
  53. data/lib/scout/workflow/task/inputs.rb +112 -0
  54. data/lib/scout/workflow/task.rb +141 -0
  55. data/lib/scout/workflow/usage.rb +294 -0
  56. data/lib/scout/workflow/util.rb +11 -0
  57. data/lib/scout/workflow.rb +39 -0
  58. data/lib/scout-gear.rb +5 -0
  59. data/lib/scout.rb +1 -0
  60. data/lib/workflow-scout.rb +2 -0
  61. data/scout-gear.gemspec +78 -5
  62. data/scout_commands/alias +48 -0
  63. data/scout_commands/find +83 -0
  64. data/scout_commands/glob +0 -0
  65. data/scout_commands/rbbt +23 -0
  66. data/scout_commands/workflow/task +707 -0
  67. data/test/scout/indiferent_hash/test_case_insensitive.rb +16 -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 +37 -1
  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/simple_opt/test_get.rb +11 -0
  83. data/test/scout/simple_opt/test_parse.rb +10 -0
  84. data/test/scout/simple_opt/test_setup.rb +77 -0
  85. data/test/scout/test_cmd.rb +85 -0
  86. data/test/scout/test_concurrent_stream.rb +29 -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 +28 -0
  94. data/test/scout/workflow/task/test_inputs.rb +182 -0
  95. data/test/scout/workflow/test_step.rb +36 -0
  96. data/test/scout/workflow/test_task.rb +178 -0
  97. data/test/scout/workflow/test_usage.rb +26 -0
  98. data/test/scout/workflow/test_util.rb +17 -0
  99. data/test/test_helper.rb +17 -0
  100. data/test/test_scout-gear.rb +0 -0
  101. metadata +76 -3
@@ -0,0 +1,294 @@
1
+ require 'scout/simple_opt'
2
+
3
+ module Task
4
+ def doc(workflow = nil, deps = nil)
5
+ puts Log.color(:yellow, "## #{ name }") << ":"
6
+ puts "\n" << Misc.format_paragraph(description.strip) << "\n" if description and not description.empty?
7
+ puts
8
+
9
+ selects = []
10
+ if inputs && inputs.any?
11
+ inputs.zip(input_types.values_at(*inputs)).select{|i,t| t.to_sym == :select && input_options[i] && input_options[i][:select_options] }.each{|i,t| selects << [i, input_options[i][:select_options]] }
12
+ puts SOPT.input_doc(inputs, input_types, input_descriptions, input_defaults, true)
13
+ puts
14
+ end
15
+
16
+ if deps and deps.any?
17
+ puts Log.color(:magenta, "Inputs from dependencies:")
18
+ puts
19
+ seen = inputs
20
+ tasks.each do |name,task|
21
+ task.inputs - seen
22
+ end
23
+
24
+ #task_inputs = dep_inputs deps, workflow
25
+ #task_inputs.each do |task,new_inputs|
26
+ # new_inputs.zip(task.input_types.values_at(*new_inputs)).select do |i,t|
27
+ # t.to_sym == :select and task.input_options[i][:select_options]
28
+ # end.each do |i,t|
29
+ # selects << [i, task.input_options[i][:select_options]]
30
+ # end
31
+
32
+ # next if new_inputs.empty?
33
+
34
+ # if task.workflow and task.workflow != workflow
35
+ # puts " #{Log.color :yellow, ["[#{task.workflow.to_s}]", task.name.to_s] *" "}:"
36
+ # else
37
+ # puts " #{Log.color :yellow, task.name.to_s}:"
38
+ # end
39
+ # puts unless Log.compact
40
+ # puts SOPT.input_doc(new_inputs, task.input_types, task.input_descriptions, task.input_defaults, true)
41
+ # puts unless Log.compact
42
+ #end
43
+ #puts
44
+ end
45
+
46
+ case
47
+ when (input_types.values & [:array]).any?
48
+ puts Log.color(:green, Misc.format_paragraph("Lists are specified as arguments using ',' or '|'. When specified as files the '\\n'
49
+ also works in addition to the others. You may use the '--array_separator' option
50
+ the change this default. Whenever a file is specified it may also accept STDIN using
51
+ the '-' character."))
52
+ puts
53
+
54
+ when (input_types.values & [:text, :tsv]).any?
55
+ puts Log.color(:green, Misc.format_paragraph("Whenever a file is specified it may also accept STDIN using the '-' character."))
56
+ puts
57
+ end
58
+
59
+ puts Log.color(:magenta, "Returns: ") << Log.color(:blue, result_type.to_s) << "\n"
60
+ puts
61
+
62
+ if selects.any?
63
+ puts Log.color(:magenta, "Input select options")
64
+ puts
65
+ selects.collect{|p| p}.uniq.each do |input,options|
66
+ puts Log.color(:blue, input.to_s + ": ") << Misc.format_paragraph(options.collect{|o| Array === o ? o.first.to_s : o.to_s} * ", ") << "\n"
67
+ puts unless Log.compact
68
+ end
69
+ puts
70
+ end
71
+ end
72
+ end
73
+
74
+ module Workflow
75
+
76
+ def dep_tree(task_name, seen = nil)
77
+ @dep_tree ||= {}
78
+ key = [self, task_name]
79
+
80
+ return @dep_tree[key] if @dep_tree.include?(key)
81
+ save = seen.nil?
82
+ seen = Set.new if seen.nil?
83
+
84
+ dep_tree = {}
85
+ task = self.tasks[task_name]
86
+ task.deps.each do |dep|
87
+ next if seen.include? dep
88
+ seen << dep
89
+ workflow, task, *rest = dep
90
+
91
+ key = [workflow, task]
92
+
93
+ dep_tree[key] = workflow.dep_tree(task, seen)
94
+ end if task.deps
95
+
96
+ @dep_tree[key] = dep_tree if save
97
+
98
+ dep_tree
99
+ end
100
+
101
+ def recursive_deps(task_name)
102
+ dependencies = []
103
+ dep_tree(task_name, dependencies)
104
+ dependencies
105
+ end
106
+
107
+ def _prov_tasks(tree)
108
+ tasks = []
109
+ heap = [tree]
110
+ while heap.any?
111
+ t = heap.pop
112
+ t.each do |k,v|
113
+ tasks << k
114
+ heap << v
115
+ end
116
+ end
117
+ tasks
118
+ end
119
+
120
+ def prov_string(tree)
121
+ description = ""
122
+
123
+ last = nil
124
+ seen = Set.new
125
+
126
+ tasks = _prov_tasks(tree)
127
+ tasks.each do |workflow,task_name|
128
+
129
+ next if seen.include?([workflow,task_name])
130
+
131
+ child = last && last.include?([workflow, task_name])
132
+ first = last.nil?
133
+ last = _prov_tasks(workflow.dep_tree(task_name))
134
+
135
+ break if child
136
+
137
+ if child
138
+ description << "->" << task_name.to_s
139
+ elsif first
140
+ description << "" << task_name.to_s
141
+ else
142
+ description << ";" << task_name.to_s
143
+ end
144
+
145
+ seen << [workflow, task_name]
146
+ end
147
+ description
148
+ end
149
+
150
+ def prov_tree(tree, offset = 0, seen = [])
151
+
152
+ return "" if tree.empty?
153
+
154
+ lines = []
155
+
156
+ offset_str = " " * offset
157
+
158
+ lines << offset_str
159
+
160
+ tree.each do |p,dtree|
161
+ next if seen.include?(p)
162
+ seen.push(p)
163
+ workflow, task = p
164
+ lines << offset_str + [workflow.to_s, task.to_s] * "#" + "\n" + workflow.prov_tree(dtree, offset + 1, seen)
165
+ end
166
+
167
+ lines * "\n"
168
+ end
169
+
170
+ def doc(task = nil, abridge = false)
171
+
172
+ if task.nil?
173
+ puts Log.color :magenta, self.to_s
174
+ puts Log.color :magenta, "=" * self.to_s.length
175
+
176
+ if self.documentation[:title] and not self.documentation[:title].empty?
177
+ puts
178
+ puts Misc.format_paragraph self.documentation[:title]
179
+ end
180
+
181
+ if self.documentation[:description] and not self.documentation[:description].empty?
182
+ puts
183
+ puts Misc.format_paragraph self.documentation[:description]
184
+ end
185
+ puts
186
+
187
+ puts Log.color :magenta, "## TASKS"
188
+ if self.documentation[:task_description] and not self.documentation[:task_description].empty?
189
+ puts
190
+ puts Misc.format_paragraph self.documentation[:task_description]
191
+ end
192
+ puts
193
+
194
+ final = Set.new
195
+ not_final = Set.new
196
+ tasks.each do |name,task|
197
+ tree = dep_tree(name)
198
+ not_final += tree.keys
199
+ final << name unless not_final.include?(name)
200
+ end
201
+
202
+ not_final.each do |p|
203
+ final -= [p.last]
204
+ end
205
+
206
+ tasks.each do |name,task|
207
+ description = task.description || ""
208
+ description = description.split("\n\n").first
209
+
210
+ next if abridge && ! final.include?(name)
211
+ puts Misc.format_definition_list_item(name.to_s, description, Log.tty_size || 80, 30, :yellow)
212
+
213
+ prov_string = prov_string(dep_tree(name))
214
+ puts Misc.format_paragraph Log.color(:blue, "->" + prov_string) if prov_string && ! prov_string.empty?
215
+ end
216
+
217
+ else
218
+
219
+ if Task === task
220
+ task_name = task.name
221
+ else
222
+ task_name = task
223
+ task = self.tasks[task_name]
224
+ end
225
+
226
+ #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]}
227
+ task.doc(self, self.recursive_deps(task_name))
228
+
229
+ dep_tree = {[self, task_name] => dep_tree(task_name)}
230
+ prov_tree = prov_tree(dep_tree)
231
+ if prov_tree && ! prov_tree.empty? && prov_tree.split("\n").length > 2
232
+
233
+ puts Log.color :magenta, "## DEPENDENCY GRAPH (abridged)"
234
+ puts
235
+ prov_tree.split("\n").each do |line|
236
+ next if line.strip.empty?
237
+ if m = line.match(/^( *)(\w+?)#(\w*)/i)
238
+ offset, workflow, task_name = m.values_at 1, 2, 3
239
+ puts [offset, Log.color(:magenta, workflow), "#", Log.color(:yellow, task_name)] * ""
240
+ else
241
+ puts Log.color :blue, line
242
+ end
243
+ end
244
+ puts
245
+ end
246
+
247
+ if self.examples.include? task_name
248
+ self.examples[task_name].each do |example|
249
+
250
+ puts Log.color(:magenta, "Example ") << Log.color(:green, example) + " -- " + Log.color(:blue, example_dir[task_name][example])
251
+
252
+ inputs = self.example(task_name, example)
253
+
254
+ inputs.each do |input, type, file|
255
+ case type
256
+ when :tsv, :array, :text, :file
257
+ lines = file.read.split("\n")
258
+ head = lines[0..5].compact * "\n\n"
259
+ head = head[0..500]
260
+ puts Misc.format_definition_list_item(input, head, 1000, -1, :blue).gsub(/\n\s*\n/,"\n")
261
+ puts '...' if lines.length > 6
262
+ else
263
+ puts Misc.format_definition_list_item(input, file.read, Log.tty_size, 20, :blue)
264
+ end
265
+ end
266
+ puts
267
+ end
268
+ end
269
+ end
270
+ end
271
+
272
+ def SOPT_str(task)
273
+ sopt_options = []
274
+ self.rec_inputs(task.name).each do |name|
275
+ short = name.to_s.chars.first
276
+ boolean = self.rec_input_types(task.name)[name].to_sym == :boolean
277
+
278
+ sopt_options << "-#{short}--#{name}#{boolean ? "" : "*"}"
279
+ end
280
+
281
+ sopt_options * ":"
282
+ end
283
+
284
+ def get_SOPT(task)
285
+ sopt_option_string = self.SOPT_str(task)
286
+ SOPT.get sopt_option_string
287
+ end
288
+
289
+ def self.get_SOPT(workflow, task)
290
+ workflow = Workflow.require_workflow workflow if String === workflow
291
+ task = workflow.tasks[task.to_sym] if String === task || Symbol === task
292
+ workflow.get_SOPT(task)
293
+ end
294
+ 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,39 @@
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
+ if Open.exists?(workflow)
29
+ workflow = workflow.find if Path === workflow
30
+ load workflow
31
+ end
32
+ workflows.last
33
+ end
34
+
35
+ def job(name, *args)
36
+ task = tasks[name]
37
+ task.job(*args)
38
+ end
39
+ end
data/lib/scout-gear.rb CHANGED
@@ -1,4 +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'
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 1.2.0 ruby lib
5
+ # stub: scout-gear 5.1.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "scout-gear".freeze
9
- s.version = "1.2.0"
9
+ s.version = "5.1.1"
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-24"
14
+ s.date = "2023-04-27"
15
15
  s.description = "Temporary files, logs, etc.".freeze
16
16
  s.email = "mikisvaz@gmail.com".freeze
17
17
  s.executables = ["scout".freeze]
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  ]
22
22
  s.files = [
23
23
  ".document",
24
+ ".gitmodules",
24
25
  ".vimproject",
25
26
  "LICENSE.txt",
26
27
  "README.rdoc",
@@ -28,6 +29,9 @@ Gem::Specification.new do |s|
28
29
  "VERSION",
29
30
  "bin/scout",
30
31
  "lib/scout-gear.rb",
32
+ "lib/scout.rb",
33
+ "lib/scout/cmd.rb",
34
+ "lib/scout/concurrent_stream.rb",
31
35
  "lib/scout/exceptions.rb",
32
36
  "lib/scout/indiferent_hash.rb",
33
37
  "lib/scout/indiferent_hash/case_insensitive.rb",
@@ -41,26 +45,95 @@ Gem::Specification.new do |s|
41
45
  "lib/scout/log/progress/util.rb",
42
46
  "lib/scout/meta_extension.rb",
43
47
  "lib/scout/misc.rb",
48
+ "lib/scout/misc/digest.rb",
49
+ "lib/scout/misc/filesystem.rb",
50
+ "lib/scout/misc/format.rb",
51
+ "lib/scout/misc/insist.rb",
52
+ "lib/scout/open.rb",
53
+ "lib/scout/open/lock.rb",
54
+ "lib/scout/open/remote.rb",
55
+ "lib/scout/open/stream.rb",
56
+ "lib/scout/open/util.rb",
44
57
  "lib/scout/path.rb",
45
58
  "lib/scout/path/find.rb",
59
+ "lib/scout/path/tmpfile.rb",
46
60
  "lib/scout/path/util.rb",
61
+ "lib/scout/persist.rb",
62
+ "lib/scout/persist/open.rb",
63
+ "lib/scout/persist/path.rb",
64
+ "lib/scout/persist/serialize.rb",
65
+ "lib/scout/resource.rb",
66
+ "lib/scout/resource/path.rb",
67
+ "lib/scout/resource/produce.rb",
68
+ "lib/scout/resource/produce/rake.rb",
69
+ "lib/scout/resource/scout.rb",
70
+ "lib/scout/simple_opt.rb",
71
+ "lib/scout/simple_opt/accessor.rb",
72
+ "lib/scout/simple_opt/doc.rb",
73
+ "lib/scout/simple_opt/get.rb",
74
+ "lib/scout/simple_opt/parse.rb",
75
+ "lib/scout/simple_opt/setup.rb",
47
76
  "lib/scout/tmpfile.rb",
77
+ "lib/scout/workflow.rb",
78
+ "lib/scout/workflow/definition.rb",
79
+ "lib/scout/workflow/documentation.rb",
80
+ "lib/scout/workflow/step.rb",
81
+ "lib/scout/workflow/step/info.rb",
82
+ "lib/scout/workflow/task.rb",
83
+ "lib/scout/workflow/task/inputs.rb",
84
+ "lib/scout/workflow/usage.rb",
85
+ "lib/scout/workflow/util.rb",
86
+ "lib/workflow-scout.rb",
48
87
  "scout-gear.gemspec",
88
+ "scout_commands/alias",
89
+ "scout_commands/find",
90
+ "scout_commands/glob",
91
+ "scout_commands/rbbt",
92
+ "scout_commands/workflow/task",
93
+ "test/scout/indiferent_hash/test_case_insensitive.rb",
49
94
  "test/scout/indiferent_hash/test_options.rb",
50
95
  "test/scout/log/test_progress.rb",
96
+ "test/scout/misc/test_digest.rb",
97
+ "test/scout/misc/test_filesystem.rb",
98
+ "test/scout/misc/test_insist.rb",
99
+ "test/scout/open/test_lock.rb",
100
+ "test/scout/open/test_remote.rb",
101
+ "test/scout/open/test_stream.rb",
102
+ "test/scout/open/test_util.rb",
51
103
  "test/scout/path/test_find.rb",
52
104
  "test/scout/path/test_util.rb",
105
+ "test/scout/persist/test_open.rb",
106
+ "test/scout/persist/test_path.rb",
107
+ "test/scout/persist/test_serialize.rb",
108
+ "test/scout/resource/test_path.rb",
109
+ "test/scout/resource/test_produce.rb",
110
+ "test/scout/simple_opt/test_get.rb",
111
+ "test/scout/simple_opt/test_parse.rb",
112
+ "test/scout/simple_opt/test_setup.rb",
113
+ "test/scout/test_cmd.rb",
114
+ "test/scout/test_concurrent_stream.rb",
53
115
  "test/scout/test_indiferent_hash.rb",
54
116
  "test/scout/test_log.rb",
55
117
  "test/scout/test_meta_extension.rb",
56
118
  "test/scout/test_misc.rb",
119
+ "test/scout/test_open.rb",
57
120
  "test/scout/test_path.rb",
121
+ "test/scout/test_persist.rb",
122
+ "test/scout/test_resource.rb",
58
123
  "test/scout/test_tmpfile.rb",
59
- "test/test_helper.rb"
124
+ "test/scout/test_workflow.rb",
125
+ "test/scout/workflow/step/test_info.rb",
126
+ "test/scout/workflow/task/test_inputs.rb",
127
+ "test/scout/workflow/test_step.rb",
128
+ "test/scout/workflow/test_task.rb",
129
+ "test/scout/workflow/test_usage.rb",
130
+ "test/scout/workflow/test_util.rb",
131
+ "test/test_helper.rb",
132
+ "test/test_scout-gear.rb"
60
133
  ]
61
134
  s.homepage = "http://github.com/mikisvaz/scout-gear".freeze
62
135
  s.licenses = ["MIT".freeze]
63
- s.rubygems_version = "3.4.6".freeze
136
+ s.rubygems_version = "3.4.11".freeze
64
137
  s.summary = "basic gear for scouts".freeze
65
138
 
66
139
  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