squared 0.5.22 → 0.6.0
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 +4 -4
- data/CHANGELOG.md +89 -203
- data/README.md +104 -72
- data/lib/squared/common/base.rb +1 -22
- data/lib/squared/common/format.rb +40 -38
- data/lib/squared/common/prompt.rb +58 -40
- data/lib/squared/common/shell.rb +71 -56
- data/lib/squared/common/system.rb +69 -36
- data/lib/squared/common/utils.rb +29 -6
- data/lib/squared/config.rb +27 -34
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +86 -104
- data/lib/squared/workspace/project/base.rb +544 -401
- data/lib/squared/workspace/project/docker.rb +396 -292
- data/lib/squared/workspace/project/git.rb +352 -341
- data/lib/squared/workspace/project/node.rb +500 -283
- data/lib/squared/workspace/project/python.rb +368 -247
- data/lib/squared/workspace/project/ruby.rb +695 -394
- data/lib/squared/workspace/project/support/class.rb +209 -212
- data/lib/squared/workspace/repo.rb +46 -43
- data/lib/squared/workspace/series.rb +13 -21
- data/lib/squared/workspace/support/base.rb +3 -24
- data/lib/squared/workspace/support/variables.rb +48 -0
- data/lib/squared/workspace/support.rb +1 -1
- data/lib/squared/workspace.rb +4 -6
- metadata +3 -3
- data/lib/squared/workspace/support/data.rb +0 -11
data/lib/squared/common/utils.rb
CHANGED
|
@@ -9,21 +9,44 @@ module Squared
|
|
|
9
9
|
module Utils
|
|
10
10
|
module_function
|
|
11
11
|
|
|
12
|
-
def
|
|
13
|
-
|
|
12
|
+
def as_a(obj, *meth, flat: nil, compact: false, &blk)
|
|
13
|
+
return [] if obj.nil?
|
|
14
|
+
|
|
15
|
+
unless obj.is_a?(::Array)
|
|
16
|
+
obj = if obj.respond_to?(:to_ary)
|
|
17
|
+
obj.to_ary
|
|
18
|
+
elsif obj.respond_to?(:to_a) && !obj.is_a?(::Hash) && (val = obj.to_a).is_a?(::Array)
|
|
19
|
+
val
|
|
20
|
+
else
|
|
21
|
+
[obj]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
obj = flat.is_a?(::Numeric) ? obj.flatten(flat) : obj.flatten if flat
|
|
25
|
+
obj = obj.compact if compact
|
|
26
|
+
obj = obj.map(&meth.shift) until meth.empty?
|
|
27
|
+
return obj unless block_given?
|
|
28
|
+
|
|
29
|
+
obj.select(&blk)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def split_escape(val, char: ',', &blk)
|
|
33
|
+
ret = val.split(/\s*(?<!\\)#{char}\s*/)
|
|
34
|
+
return ret unless block_given?
|
|
35
|
+
|
|
36
|
+
ret.each(&blk)
|
|
14
37
|
end
|
|
15
38
|
|
|
16
39
|
def split_option(val)
|
|
17
40
|
val = val.strip
|
|
18
41
|
return [val, '', ''] unless (i = val.index('='))
|
|
19
42
|
|
|
20
|
-
last = val[
|
|
43
|
+
last = val[i.succ..-1].strip
|
|
21
44
|
quote = ''
|
|
22
45
|
if last =~ /\A(["'])(.+)\1\z/
|
|
23
46
|
last = $2
|
|
24
47
|
quote = $1
|
|
25
48
|
end
|
|
26
|
-
[val[0..
|
|
49
|
+
[val[0..i.pred], last, quote]
|
|
27
50
|
end
|
|
28
51
|
|
|
29
52
|
def task_invoke(*cmd, args: [], exception: true, warning: true)
|
|
@@ -105,9 +128,9 @@ module Squared
|
|
|
105
128
|
end
|
|
106
129
|
end
|
|
107
130
|
|
|
108
|
-
def env(key, default = nil, suffix: nil, strict: false, equals: nil, ignore: nil)
|
|
131
|
+
def env(key, default = nil, suffix: nil, strict: false, equals: nil, ignore: nil, **)
|
|
109
132
|
ret = env_value(key, suffix: suffix, strict: strict)
|
|
110
|
-
return
|
|
133
|
+
return Array(equals).any? { |val| val.to_s == ret } unless equals.nil?
|
|
111
134
|
|
|
112
135
|
ret.empty? || (ignore && Array(ignore).any? { |val| val.to_s == ret }) ? default : ret
|
|
113
136
|
end
|
data/lib/squared/config.rb
CHANGED
|
@@ -12,18 +12,19 @@ module Squared
|
|
|
12
12
|
include Rake::DSL
|
|
13
13
|
|
|
14
14
|
class << self
|
|
15
|
-
def parse(gem, namespace, ext = [
|
|
15
|
+
def parse(gem, namespace, ext = [pkg])
|
|
16
16
|
require gem
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
end
|
|
17
|
+
obj = eval namespace
|
|
18
|
+
Array(ext).each { |val| @@mime_obj[val] = [obj, ext] }
|
|
20
19
|
rescue LoadError, NameError => e
|
|
21
20
|
warn e
|
|
22
21
|
nil
|
|
22
|
+
else
|
|
23
|
+
@@mime_obj[ext.first]
|
|
23
24
|
end
|
|
24
25
|
|
|
25
|
-
def link(project, main = project.dependfile
|
|
26
|
-
return unless project.enabled?
|
|
26
|
+
def link(project, main = project.dependfile.basename, name = nil, **kwargs, &blk)
|
|
27
|
+
return unless project.enabled?
|
|
27
28
|
|
|
28
29
|
ret = new(main, name, project: project, **kwargs)
|
|
29
30
|
ret.instance_eval(&blk) if block_given?
|
|
@@ -85,7 +86,7 @@ module Squared
|
|
|
85
86
|
['path not found', realpath]
|
|
86
87
|
else
|
|
87
88
|
@required = true
|
|
88
|
-
project ? [project, '
|
|
89
|
+
project ? [project, 'missing'] : %w[name missing]
|
|
89
90
|
end
|
|
90
91
|
warn log_message(Logger::WARN, msg, subject: self.class, hint: hint)
|
|
91
92
|
end
|
|
@@ -105,7 +106,7 @@ module Squared
|
|
|
105
106
|
next unless (data = Viewer.parse(type, type.upcase, ext))
|
|
106
107
|
end
|
|
107
108
|
obj, ext = data
|
|
108
|
-
target = file ||
|
|
109
|
+
target = file || (realpath if target?)
|
|
109
110
|
|
|
110
111
|
task_desc(command, *ext, target: target)
|
|
111
112
|
task type, [:keys] do |_, args|
|
|
@@ -159,7 +160,7 @@ module Squared
|
|
|
159
160
|
end
|
|
160
161
|
|
|
161
162
|
def also(path, type = nil, name: nil, **kwargs)
|
|
162
|
-
return self
|
|
163
|
+
return self if @mime.frozen? || !(file = basepath(path)).exist?
|
|
163
164
|
|
|
164
165
|
ext = mimetype file
|
|
165
166
|
type ||= ext
|
|
@@ -204,7 +205,7 @@ module Squared
|
|
|
204
205
|
|
|
205
206
|
def read_keys(reader, type, file, keys, ext: [type], opts: {})
|
|
206
207
|
if file && (mime = mimetype(file)) && basepath(file).exist?
|
|
207
|
-
raise_error
|
|
208
|
+
raise_error file, mime, hint: 'invalid' unless ext.include?(mime)
|
|
208
209
|
else
|
|
209
210
|
if ext.include?(mime)
|
|
210
211
|
alt = file
|
|
@@ -219,7 +220,7 @@ module Squared
|
|
|
219
220
|
args = { hint: 'no keys' }
|
|
220
221
|
end
|
|
221
222
|
unless file
|
|
222
|
-
args ||= {
|
|
223
|
+
args ||= { kind: Errno::ENOENT }
|
|
223
224
|
raise_error(reader.name, "#{File.basename(alt, '.*')}.#{ext.first}", **args)
|
|
224
225
|
end
|
|
225
226
|
end
|
|
@@ -236,22 +237,18 @@ module Squared
|
|
|
236
237
|
title = Pathname.new(file)
|
|
237
238
|
.realpath
|
|
238
239
|
.to_s
|
|
239
|
-
.sub(
|
|
240
|
+
.sub(/^#{Regexp.escape(File.join(Dir.pwd, ''))}/, '')
|
|
240
241
|
emphasize(lines, title: title, sub: unless stdin?
|
|
241
242
|
[
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
{ pat: /\A((?~: ): )(true|false)(\s*)\z/m, styles: theme[:boolean],
|
|
252
|
-
index: 2 },
|
|
253
|
-
{ pat: /\A((?~: ): (?!undefined))([^"\[{].*)\z/m, styles: theme[:value],
|
|
254
|
-
index: 2 }
|
|
243
|
+
opt_style(theme[:banner], /\A((?:[^:]|(?<! ):(?! ))+)\z/),
|
|
244
|
+
opt_style(theme[:undefined], /\A(.*?)(<[^>]+>)(.+)\z/m, 2),
|
|
245
|
+
opt_style(theme[:key], /\A((?~ : ))( : (?!undefined).+)\z/m),
|
|
246
|
+
opt_style(theme[:number], /\A((?~: ): )(-?[\d.]+)(\s*)\z/m, 2),
|
|
247
|
+
opt_style(theme[:string], /\A((?~: ): ")(.+)("\s*)\z/m, 2),
|
|
248
|
+
opt_style(theme[:hash], /\A((?~: ): \{)(.+)(\}\s*)\z/m, 2),
|
|
249
|
+
opt_style(theme[:array], /\A((?~: ): \[)(.+)(\]\s*)\z/m, 2),
|
|
250
|
+
opt_style(theme[:boolean], /\A((?~: ): )(true|false)(\s*)\z/m, 2),
|
|
251
|
+
opt_style(theme[:value], /\A((?~: ): (?!undefined))([^"\[{].*)\z/m, 2)
|
|
255
252
|
]
|
|
256
253
|
end, border: theme[:border])
|
|
257
254
|
end
|
|
@@ -262,7 +259,7 @@ module Squared
|
|
|
262
259
|
symbolize = opts[:symbolize_names]
|
|
263
260
|
keys.each do |key|
|
|
264
261
|
begin
|
|
265
|
-
items = key.split('.')
|
|
262
|
+
items = key.split('.')
|
|
266
263
|
items = items.map(&:to_sym) if symbolize
|
|
267
264
|
val = data.dig(*items)
|
|
268
265
|
if val.nil?
|
|
@@ -293,7 +290,7 @@ module Squared
|
|
|
293
290
|
if stdin?
|
|
294
291
|
puts out.map!(&:last).join("\n")
|
|
295
292
|
else
|
|
296
|
-
out.map! { |
|
|
293
|
+
out.map! { |item| '%-*s : %s' % [pad, item[0], item[1]] }
|
|
297
294
|
end
|
|
298
295
|
end
|
|
299
296
|
|
|
@@ -308,7 +305,7 @@ module Squared
|
|
|
308
305
|
def task_desc(command, *ext, target: nil)
|
|
309
306
|
return unless Rake::TaskManager.record_task_metadata
|
|
310
307
|
|
|
311
|
-
val = "#{ext.first}[#{
|
|
308
|
+
val = "#{ext.first}[#{"file?=#{File.basename(main)}.#{ext.last}," if target}keys+]"
|
|
312
309
|
args = *name.split(':').push(command, val)
|
|
313
310
|
if project
|
|
314
311
|
project.workspace.task_desc(*args)
|
|
@@ -322,9 +319,7 @@ module Squared
|
|
|
322
319
|
end
|
|
323
320
|
|
|
324
321
|
def warning?
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
project.workspace.warning
|
|
322
|
+
project ? project.workspace.warning : true
|
|
328
323
|
end
|
|
329
324
|
|
|
330
325
|
def stdin?
|
|
@@ -349,9 +344,7 @@ module Squared
|
|
|
349
344
|
end
|
|
350
345
|
|
|
351
346
|
def basepath(*args)
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
project.basepath(*args)
|
|
347
|
+
project ? project.basepath(*args) : Pathname.pwd.join(*args)
|
|
355
348
|
end
|
|
356
349
|
end
|
|
357
350
|
end
|
data/lib/squared/version.rb
CHANGED
|
@@ -5,18 +5,11 @@ module Squared
|
|
|
5
5
|
class Application
|
|
6
6
|
include Common::Format
|
|
7
7
|
include Utils
|
|
8
|
+
include Support::Variables
|
|
8
9
|
include Rake::DSL
|
|
9
10
|
|
|
10
|
-
SCRIPT_OBJ = {
|
|
11
|
-
run: nil,
|
|
12
|
-
script: nil,
|
|
13
|
-
dev: nil,
|
|
14
|
-
prod: nil,
|
|
15
|
-
global: false,
|
|
16
|
-
env: false
|
|
17
|
-
}.freeze
|
|
18
11
|
TASK_METADATA = Rake::TaskManager.record_task_metadata
|
|
19
|
-
private_constant :
|
|
12
|
+
private_constant :TASK_METADATA
|
|
20
13
|
|
|
21
14
|
class << self
|
|
22
15
|
def implement(*objs, base: false)
|
|
@@ -75,7 +68,8 @@ module Squared
|
|
|
75
68
|
@kind_project = []
|
|
76
69
|
@task_exclude = Set.new
|
|
77
70
|
|
|
78
|
-
attr_reader :root, :home, :main, :prefix, :
|
|
71
|
+
attr_reader :root, :home, :main, :prefix, :theme, :series, :closed
|
|
72
|
+
attr_accessor :exception, :pipe, :verbose, :warning
|
|
79
73
|
|
|
80
74
|
def initialize(home = (ARG[:HOME] && ENV[ARG[:HOME]]) || Dir.pwd, *, main: nil, prefix: nil,
|
|
81
75
|
verbose: ARG[:VERBOSE], common: ARG[:COMMON], pipe: ARG[:PIPE], exception: ARG[:FAIL], **)
|
|
@@ -92,40 +86,40 @@ module Squared
|
|
|
92
86
|
@prefix = prefix
|
|
93
87
|
@series = Application.series_wrap(self)
|
|
94
88
|
@project = {}
|
|
95
|
-
@kind =
|
|
89
|
+
@kind = hashlist
|
|
96
90
|
@extensions = []
|
|
97
91
|
@envname = env_key(@main).freeze
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
92
|
+
self.exception = env_bool exception
|
|
93
|
+
self.pipe = $DEBUG ? 2 : env_pipe(pipe, (ARG[:OUT] && env(ARG[:OUT])) || 1, root: @home)
|
|
94
|
+
self.verbose = if $VERBOSE.nil?
|
|
95
|
+
false
|
|
96
|
+
elsif verbose.nil?
|
|
97
|
+
@pipe != 0
|
|
98
|
+
else
|
|
99
|
+
env_bool(verbose, verbose.is_a?(String) ? @pipe != 0 : verbose, index: true)
|
|
100
|
+
end
|
|
101
|
+
self.warning = @verbose != false
|
|
108
102
|
@closed = false
|
|
109
|
-
if common
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
@chain =
|
|
103
|
+
@theme = if common
|
|
104
|
+
ARG[:COLOR] = false if @pipe == 0 || @pipe.is_a?(Pathname)
|
|
105
|
+
__get__(:theme)[:workspace]
|
|
106
|
+
else
|
|
107
|
+
{}
|
|
108
|
+
end
|
|
109
|
+
@chain = hashlist
|
|
116
110
|
@script = {
|
|
117
|
-
group:
|
|
118
|
-
ref:
|
|
111
|
+
group: hashobj,
|
|
112
|
+
ref: hashobj,
|
|
119
113
|
group!: {},
|
|
120
114
|
ref!: {}
|
|
121
115
|
}.freeze
|
|
122
116
|
@events = {
|
|
123
|
-
group:
|
|
124
|
-
ref:
|
|
117
|
+
group: hashobj,
|
|
118
|
+
ref: hashobj
|
|
125
119
|
}.freeze
|
|
126
120
|
@pass = {
|
|
127
|
-
group:
|
|
128
|
-
ref:
|
|
121
|
+
group: hashobj,
|
|
122
|
+
ref: hashobj,
|
|
129
123
|
global: {},
|
|
130
124
|
pattern: []
|
|
131
125
|
}.freeze
|
|
@@ -178,29 +172,15 @@ module Squared
|
|
|
178
172
|
self
|
|
179
173
|
end
|
|
180
174
|
|
|
181
|
-
def with(*val,
|
|
182
|
-
if
|
|
183
|
-
pass = kwargs[:pass]
|
|
184
|
-
case pass
|
|
185
|
-
when true, false
|
|
186
|
-
hide = pass
|
|
187
|
-
kwargs.delete(:pass)
|
|
188
|
-
else
|
|
189
|
-
hide, pass = Array(pass).partition { |s| respond_to?(s) || s.to_s.end_with?('?') }
|
|
190
|
-
if pass.empty?
|
|
191
|
-
kwargs.delete(:pass)
|
|
192
|
-
elsif hide.empty?
|
|
193
|
-
hide = nil
|
|
194
|
-
else
|
|
195
|
-
kwargs[:pass] = pass
|
|
196
|
-
end
|
|
197
|
-
end
|
|
198
|
-
end
|
|
199
|
-
return self if hide == true || (hide && Array(hide).any? { |s| respond_to?(s) && __send__(s) rescue nil })
|
|
175
|
+
def with(*val, pass: false, group: nil, **kwargs, &blk)
|
|
176
|
+
return self if pass == true || (pass && as_a(pass, :to_s).any? { |s| respond_to?(s) && __send__(s) })
|
|
200
177
|
|
|
201
178
|
@group = nil
|
|
202
179
|
@ref = nil
|
|
203
|
-
@withargs = kwargs.empty?
|
|
180
|
+
@withargs = unless kwargs.empty?
|
|
181
|
+
kwargs.delete(:parent)
|
|
182
|
+
kwargs
|
|
183
|
+
end
|
|
204
184
|
val = as_a(group || kwargs[:ref], flat: true, compact: true) if val.empty?
|
|
205
185
|
kind = val.first
|
|
206
186
|
val = kind if val.size == 1
|
|
@@ -210,7 +190,7 @@ module Squared
|
|
|
210
190
|
when Symbol
|
|
211
191
|
@ref = val
|
|
212
192
|
else
|
|
213
|
-
raise_error 'missing group or ref' if block_given?
|
|
193
|
+
raise_error ArgumentError, 'missing group or ref' if block_given?
|
|
214
194
|
end
|
|
215
195
|
if block_given?
|
|
216
196
|
instance_eval(&blk)
|
|
@@ -235,7 +215,7 @@ module Squared
|
|
|
235
215
|
nil
|
|
236
216
|
else
|
|
237
217
|
action.map! { |val| task_name(val) }
|
|
238
|
-
|
|
218
|
+
@project.keys unless prefix
|
|
239
219
|
end
|
|
240
220
|
ns = lambda do |val|
|
|
241
221
|
next if (ret = as_a(val, :to_s, flat: true)).empty?
|
|
@@ -291,9 +271,9 @@ module Squared
|
|
|
291
271
|
|
|
292
272
|
def pass(name, group: @group, ref: @ref, &blk)
|
|
293
273
|
data = if group
|
|
294
|
-
@pass[:group][group
|
|
274
|
+
@pass[:group][group]
|
|
295
275
|
elsif ref
|
|
296
|
-
@pass[:ref][ref
|
|
276
|
+
@pass[:ref][ref]
|
|
297
277
|
else
|
|
298
278
|
@pass[:global]
|
|
299
279
|
end
|
|
@@ -327,22 +307,21 @@ module Squared
|
|
|
327
307
|
end
|
|
328
308
|
data.order << meth
|
|
329
309
|
end
|
|
330
|
-
if group
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
items.each { |val| @banner[label][val.to_sym] = data }
|
|
310
|
+
Array(if group
|
|
311
|
+
label = :group
|
|
312
|
+
group
|
|
313
|
+
else
|
|
314
|
+
label = :ref
|
|
315
|
+
ref || :_
|
|
316
|
+
end).each { |val| @banner[label][val.to_sym] = data }
|
|
338
317
|
self
|
|
339
318
|
end
|
|
340
319
|
|
|
341
320
|
def add(path, project = nil, **kwargs, &blk)
|
|
342
|
-
kwargs =
|
|
321
|
+
kwargs = hashdup(@withargs).update(kwargs) if @withargs
|
|
343
322
|
ref = kwargs.key?(:ref) ? kwargs.delete(:ref) : @ref
|
|
344
323
|
kwargs[:group] = @group if @group && !kwargs.key?(:group)
|
|
345
|
-
path =
|
|
324
|
+
path = rootpath path
|
|
346
325
|
project = (project || path.basename).to_s
|
|
347
326
|
name = task_name project
|
|
348
327
|
index = 0
|
|
@@ -352,9 +331,9 @@ module Squared
|
|
|
352
331
|
end
|
|
353
332
|
proj = ((if !ref.is_a?(Class)
|
|
354
333
|
Application.find(ref, path: path)
|
|
355
|
-
elsif ref <
|
|
334
|
+
elsif ref < Project::Base
|
|
356
335
|
ref
|
|
357
|
-
end) || @kind[name]&.last ||
|
|
336
|
+
end) || @kind[name]&.last || Project::Base).new(self, path, name, **kwargs)
|
|
358
337
|
proj.__send__(:index_set, @project.size)
|
|
359
338
|
@project[name] = proj
|
|
360
339
|
__get__(:project)[name] = proj unless kwargs[:private]
|
|
@@ -399,11 +378,10 @@ module Squared
|
|
|
399
378
|
end
|
|
400
379
|
end
|
|
401
380
|
if obj.is_a?(String)
|
|
402
|
-
begin
|
|
403
|
-
|
|
381
|
+
obj = begin
|
|
382
|
+
JSON.parse(homepath(obj).read, { symbolize_names: true })
|
|
404
383
|
rescue StandardError => e
|
|
405
384
|
warn log_message(Logger::ERROR, e)
|
|
406
|
-
obj = nil
|
|
407
385
|
end
|
|
408
386
|
end
|
|
409
387
|
apply_style(data || theme, obj, args, empty: empty) if obj && (!target || data)
|
|
@@ -465,7 +443,7 @@ module Squared
|
|
|
465
443
|
end
|
|
466
444
|
|
|
467
445
|
def task_localname(val)
|
|
468
|
-
prefix && val.is_a?(String) ? val.sub(
|
|
446
|
+
prefix && val.is_a?(String) ? val.sub(/^#{Regexp.escape(prefix)}:/, '') : val.to_s
|
|
469
447
|
end
|
|
470
448
|
|
|
471
449
|
def task_desc(*args, **kwargs)
|
|
@@ -514,7 +492,7 @@ module Squared
|
|
|
514
492
|
if (base = task_base?(key))
|
|
515
493
|
tasks << key if obj.has?(key, baseref)
|
|
516
494
|
elsif (batch = series.batch_get(key))
|
|
517
|
-
obj.allref do |ref|
|
|
495
|
+
obj.allref.each do |ref|
|
|
518
496
|
next unless obj.has?(key, ref) && (data = batch[ref])
|
|
519
497
|
|
|
520
498
|
data.each do |val|
|
|
@@ -533,7 +511,7 @@ module Squared
|
|
|
533
511
|
if tasks.empty?
|
|
534
512
|
return [] if (base && !obj.ref?(baseref)) || !(data = series.alias_get(key))
|
|
535
513
|
|
|
536
|
-
obj.allref do |ref|
|
|
514
|
+
obj.allref.each do |ref|
|
|
537
515
|
next unless obj.has?(key, ref) && (alt = data[ref])
|
|
538
516
|
|
|
539
517
|
ret = task_resolve obj, alt
|
|
@@ -581,7 +559,7 @@ module Squared
|
|
|
581
559
|
|
|
582
560
|
return ret
|
|
583
561
|
end
|
|
584
|
-
@script[:ref!][:'']
|
|
562
|
+
@script[:ref!][:''] ||= scriptobj
|
|
585
563
|
end
|
|
586
564
|
|
|
587
565
|
def script_get(*args, group: nil, ref: nil)
|
|
@@ -597,7 +575,7 @@ module Squared
|
|
|
597
575
|
return ret if group && (ret = @banner[:group][group.to_sym])
|
|
598
576
|
|
|
599
577
|
ref.reverse_each { |val| return ret if (ret = @banner[:ref][val]) }
|
|
600
|
-
@banner[:ref][:
|
|
578
|
+
@banner[:ref][:'']
|
|
601
579
|
end
|
|
602
580
|
|
|
603
581
|
def enabled?
|
|
@@ -757,23 +735,23 @@ module Squared
|
|
|
757
735
|
index = k if w && has.call(w, v1)
|
|
758
736
|
if a && has.call(a, v1)
|
|
759
737
|
if index
|
|
760
|
-
with.call(l
|
|
738
|
+
with.call(l.succ)
|
|
761
739
|
throw :found
|
|
762
740
|
else
|
|
763
|
-
index = k
|
|
741
|
+
index = k.succ
|
|
764
742
|
end
|
|
765
743
|
elsif b && has.call(b, v1)
|
|
766
744
|
if index
|
|
767
745
|
with.call(l)
|
|
768
746
|
throw :found
|
|
769
747
|
else
|
|
770
|
-
index = k
|
|
748
|
+
index = k.pred
|
|
771
749
|
end
|
|
772
750
|
elsif index
|
|
773
751
|
if a || b
|
|
774
752
|
tasks.each_with_index do |v2, m|
|
|
775
753
|
if a && has.call(a, v2)
|
|
776
|
-
with.call(m
|
|
754
|
+
with.call(m.succ)
|
|
777
755
|
throw :found
|
|
778
756
|
elsif b && has.call(b, v2)
|
|
779
757
|
with.call(m)
|
|
@@ -783,7 +761,7 @@ module Squared
|
|
|
783
761
|
if !pass
|
|
784
762
|
pass = [i, data]
|
|
785
763
|
elsif pass.include?(data)
|
|
786
|
-
if i == pass.first
|
|
764
|
+
if i == pass.first.succ
|
|
787
765
|
pass.delete(data)
|
|
788
766
|
pass = nil if pass.size == 1
|
|
789
767
|
end
|
|
@@ -795,7 +773,7 @@ module Squared
|
|
|
795
773
|
else
|
|
796
774
|
next
|
|
797
775
|
end
|
|
798
|
-
step = index == -1 ? -1 : index
|
|
776
|
+
step = index == -1 ? -1 : index.succ
|
|
799
777
|
throw :found
|
|
800
778
|
end
|
|
801
779
|
end
|
|
@@ -823,18 +801,15 @@ module Squared
|
|
|
823
801
|
format_desc key
|
|
824
802
|
task key do
|
|
825
803
|
unless failed.empty? && group.empty?
|
|
826
|
-
|
|
827
|
-
|
|
804
|
+
group.each { |val| failed += val.action }
|
|
805
|
+
puts log_message(Logger::ERROR, *failed, subject: 'failed placement', hint: false), pipe: 2
|
|
828
806
|
end
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
title = "Step #{n.succ}#{if !sync.include?(grp) || (grp.size == 1 && series.parallel.include?(grp.first))
|
|
832
|
-
''
|
|
833
|
-
else
|
|
807
|
+
level.each_with_index do |grp, i|
|
|
808
|
+
title = "Step #{i.succ}#{if sync.include?(grp) && !(grp.size == 1 && series.parallel.include?(grp.first))
|
|
834
809
|
' (sync)'
|
|
835
810
|
end}"
|
|
836
|
-
emphasize(grp, title: title, cols:
|
|
837
|
-
sub: [
|
|
811
|
+
emphasize(grp, title: title, cols: level.flatten(1).push(title), border: theme[:border],
|
|
812
|
+
sub: opt_style(theme[:header], /\A(Step \d+)(.*)\z/))
|
|
838
813
|
end
|
|
839
814
|
end
|
|
840
815
|
end
|
|
@@ -852,12 +827,11 @@ module Squared
|
|
|
852
827
|
end
|
|
853
828
|
if group
|
|
854
829
|
label = :group
|
|
855
|
-
|
|
830
|
+
as_a group, :to_sym
|
|
856
831
|
else
|
|
857
832
|
label = :ref
|
|
858
|
-
|
|
859
|
-
end
|
|
860
|
-
items.each do |name|
|
|
833
|
+
as_a ref, :to_sym
|
|
834
|
+
end.each do |name|
|
|
861
835
|
@script[label][name][task] = val
|
|
862
836
|
@events[label][name][task] = on if on.is_a?(Hash)
|
|
863
837
|
end
|
|
@@ -896,26 +870,34 @@ module Squared
|
|
|
896
870
|
|
|
897
871
|
path.each_child do |c|
|
|
898
872
|
name = c.basename.to_s
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
873
|
+
unless c.to_s == __FILE__ || (@main == name && c.directory? && c.empty?) || pass.any? { |val| val == name }
|
|
874
|
+
return false
|
|
875
|
+
end
|
|
902
876
|
end
|
|
903
877
|
true
|
|
904
878
|
end
|
|
905
879
|
|
|
906
|
-
def script?(state, target: nil, pat: nil, group: nil, ref: baseref, global: false)
|
|
880
|
+
def script?(state, target: nil, pat: nil, group: nil, ref: baseref, global: false, script: true)
|
|
907
881
|
data = script_find ref, group
|
|
882
|
+
type = script ? :script : :run
|
|
908
883
|
if global
|
|
909
|
-
target = data[
|
|
884
|
+
target = data[type] if target.nil?
|
|
910
885
|
pat = data[state] if pat.nil?
|
|
911
886
|
end
|
|
912
|
-
return false if state == :prod && data[:dev] == true && data[:global]
|
|
887
|
+
return false if state == :prod && data[:dev] == true && data[:global][type]
|
|
913
888
|
|
|
914
889
|
target && pat.is_a?(Regexp) ? Array(target).any?(pat) : pat == true
|
|
915
890
|
end
|
|
916
891
|
|
|
917
892
|
def scriptobj
|
|
918
|
-
|
|
893
|
+
{
|
|
894
|
+
run: nil,
|
|
895
|
+
script: nil,
|
|
896
|
+
dev: nil,
|
|
897
|
+
prod: nil,
|
|
898
|
+
global: {},
|
|
899
|
+
env: {}
|
|
900
|
+
}
|
|
919
901
|
end
|
|
920
902
|
end
|
|
921
903
|
end
|