squared 0.4.12 → 0.4.13
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 +30 -0
- data/README.ruby.md +5 -1
- data/lib/squared/common/shell.rb +14 -14
- data/lib/squared/common/system.rb +2 -2
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +1 -0
- data/lib/squared/workspace/project/base.rb +273 -101
- data/lib/squared/workspace/project/docker.rb +83 -43
- data/lib/squared/workspace/project/git.rb +15 -10
- data/lib/squared/workspace/project/node.rb +35 -4
- data/lib/squared/workspace/project/python.rb +127 -96
- data/lib/squared/workspace/project/ruby.rb +29 -19
- data/lib/squared/workspace/project/support/class.rb +2 -2
- metadata +1 -1
@@ -9,6 +9,7 @@ module Squared
|
|
9
9
|
module Workspace
|
10
10
|
module Project
|
11
11
|
class Base
|
12
|
+
include Comparable
|
12
13
|
include Common::Format
|
13
14
|
include System
|
14
15
|
include Shell
|
@@ -17,7 +18,8 @@ module Squared
|
|
17
18
|
include Support
|
18
19
|
include Rake::DSL
|
19
20
|
|
20
|
-
VAR_SET = %i[parent global envname dependfile dependindex theme
|
21
|
+
VAR_SET = %i[parent global script index envname desc dependfile dependindex theme archive env dev prod graph
|
22
|
+
pass exclude].freeze
|
21
23
|
BLK_SET = %i[run depend doc lint test copy clean].freeze
|
22
24
|
SEM_VER = /\b(\d+)(?:(\.)(\d+))?(?:(\.)(\d+)(\S+)?)?\b/.freeze
|
23
25
|
URI_SCHEME = %r{^([a-z][a-z\d+-.]*)://[^@:\[\]\\^<>|\s]}i.freeze
|
@@ -31,7 +33,7 @@ module Squared
|
|
31
33
|
def bannerargs(*); end
|
32
34
|
|
33
35
|
def tasks
|
34
|
-
(%i[build archive graph] + BLK_SET).freeze
|
36
|
+
(%i[build archive graph prereqs] + BLK_SET).freeze
|
35
37
|
end
|
36
38
|
|
37
39
|
def as_path(val)
|
@@ -63,6 +65,7 @@ module Squared
|
|
63
65
|
end
|
64
66
|
|
65
67
|
@@tasks = {}
|
68
|
+
@@graph = { _: [] }
|
66
69
|
@@print_order = 0
|
67
70
|
|
68
71
|
subtasks({
|
@@ -73,8 +76,8 @@ module Squared
|
|
73
76
|
attr_reader :name, :project, :workspace, :path, :theme, :exception, :pipe, :verbose,
|
74
77
|
:group, :parent, :dependfile
|
75
78
|
|
76
|
-
def initialize(workspace, path, name, *, group: nil,
|
77
|
-
|
79
|
+
def initialize(workspace, path, name, *, group: nil, archive: nil, first: {}, last: {}, error: {},
|
80
|
+
common: ARG[:COMMON], **kwargs)
|
78
81
|
@path = path
|
79
82
|
@workspace = workspace
|
80
83
|
@name = name.to_s.freeze
|
@@ -93,33 +96,11 @@ module Squared
|
|
93
96
|
when Hash
|
94
97
|
archive
|
95
98
|
end
|
96
|
-
@release = release
|
99
|
+
@release = kwargs[:release]
|
97
100
|
@envname = @name.gsub(/[^\w]+/, '_').upcase.freeze
|
98
|
-
@exception = env_bool(kwargs[:exception], workspace.exception, strict: true)
|
99
|
-
@pipe = env_pipe(kwargs[:pipe], workspace.pipe, strict: true)
|
100
|
-
@verbose = case verbose
|
101
|
-
when NilClass
|
102
|
-
workspace.verbose
|
103
|
-
when String
|
104
|
-
env_bool(verbose, workspace.verbose, strict: true, index: true)
|
105
|
-
else
|
106
|
-
verbose
|
107
|
-
end
|
108
|
-
@theme = if !@verbose
|
109
|
-
{}
|
110
|
-
elsif common
|
111
|
-
workspace.theme
|
112
|
-
else
|
113
|
-
__get__(:theme)[:project][to_sym] ||= {}
|
114
|
-
end
|
115
101
|
@output = []
|
116
102
|
@ref = []
|
117
103
|
@children = []
|
118
|
-
@graph = if graph
|
119
|
-
as_a(graph, workspace.prefix ? ->(val) { workspace.task_name(val).to_sym } : :to_sym).freeze
|
120
|
-
end
|
121
|
-
@pass = (pass ? as_a(pass) : []).freeze
|
122
|
-
@exclude = (exclude ? as_a(exclude, :to_sym) : []).freeze
|
123
104
|
@events = {
|
124
105
|
first: first,
|
125
106
|
last: last,
|
@@ -128,7 +109,15 @@ module Squared
|
|
128
109
|
@desc = (@name.include?(':') ? @name.split(':').join(ARG[:SPACE]) : @name).freeze
|
129
110
|
@parent = nil
|
130
111
|
@global = false
|
112
|
+
@index = -1
|
131
113
|
run_set(kwargs[:run], kwargs[:env], opts: kwargs.fetch(:opts, true))
|
114
|
+
exception_set kwargs[:exception]
|
115
|
+
pipe_set kwargs[:pipe]
|
116
|
+
verbose_set kwargs[:verbose]
|
117
|
+
theme_set common
|
118
|
+
graph_set kwargs[:graph]
|
119
|
+
pass_set kwargs[:pass]
|
120
|
+
exclude_set kwargs[:exclude]
|
132
121
|
initialize_ref Base.ref
|
133
122
|
end
|
134
123
|
|
@@ -254,6 +243,44 @@ module Squared
|
|
254
243
|
end
|
255
244
|
end
|
256
245
|
|
246
|
+
def <=>(other)
|
247
|
+
return 0 unless workspace == other.workspace
|
248
|
+
|
249
|
+
a, b = graph_deps
|
250
|
+
return 1 if a.include?(other)
|
251
|
+
|
252
|
+
c, d = graph_deps other
|
253
|
+
e = b.reject { |val| d.include?(val) }
|
254
|
+
f = d.reject { |val| b.include?(val) }
|
255
|
+
if parent == other.parent
|
256
|
+
g = []
|
257
|
+
h = []
|
258
|
+
else
|
259
|
+
g = a.reject { |val| c.include?(val) }
|
260
|
+
h = c.reject { |val| a.include?(val) }
|
261
|
+
end
|
262
|
+
g << self
|
263
|
+
h << other
|
264
|
+
e.concat(g)
|
265
|
+
f.concat(h)
|
266
|
+
if g.any? { |val| f.include?(val) }
|
267
|
+
-1
|
268
|
+
elsif h.any? { |val| e.include?(val) }
|
269
|
+
1
|
270
|
+
elsif e.any? { |val| f.include?(val) }
|
271
|
+
-1
|
272
|
+
elsif f.any? { |val| e.include?(val) }
|
273
|
+
1
|
274
|
+
elsif @index != -1 && (i = other.instance_variable_get(:@index)) != -1
|
275
|
+
@index < i ? -1 : 1
|
276
|
+
else
|
277
|
+
0
|
278
|
+
end
|
279
|
+
rescue StandardError => e
|
280
|
+
log&.debug e
|
281
|
+
0
|
282
|
+
end
|
283
|
+
|
257
284
|
def ref
|
258
285
|
Base.ref
|
259
286
|
end
|
@@ -342,24 +369,16 @@ module Squared
|
|
342
369
|
end
|
343
370
|
|
344
371
|
def add(path, name = nil, **kwargs, &blk)
|
345
|
-
checkdir = lambda do |val|
|
346
|
-
if val.directory? && !val.empty?
|
347
|
-
true
|
348
|
-
else
|
349
|
-
log&.warn "workspace \"#{val}\" (#{val.empty? ? 'empty' : 'not found'})"
|
350
|
-
false
|
351
|
-
end
|
352
|
-
end
|
353
372
|
if path.is_a?(String) && (seg = path[%r{\A(.+)[\\/]\*+\z}, 1])
|
354
|
-
return self unless checkdir
|
373
|
+
return self unless checkdir?(path = basepath(seg))
|
355
374
|
|
356
|
-
path = path.children.select { |val| checkdir
|
375
|
+
path = path.children.select { |val| checkdir?(val) }
|
357
376
|
end
|
358
377
|
if path.is_a?(Array)
|
359
378
|
name = @name if name == true
|
360
379
|
path.each { |val| add(val, name && task_join(name, File.basename(val)), **kwargs, &blk) }
|
361
380
|
return self
|
362
|
-
elsif !projectpath?(path = basepath(path)) || !checkdir
|
381
|
+
elsif !projectpath?(path = basepath(path)) || !checkdir?(path)
|
363
382
|
return self
|
364
383
|
else
|
365
384
|
name = case name
|
@@ -376,8 +395,14 @@ module Squared
|
|
376
395
|
kwargs[:ref] = ref unless kwargs.key?(:ref)
|
377
396
|
parent = self
|
378
397
|
proj = nil
|
379
|
-
|
380
|
-
|
398
|
+
name = case name
|
399
|
+
when String, Symbol
|
400
|
+
name.to_s
|
401
|
+
else
|
402
|
+
path.basename
|
403
|
+
end
|
404
|
+
workspace.add(path, name, **kwargs) do
|
405
|
+
__send__ :parent_set, parent
|
381
406
|
proj = self
|
382
407
|
end
|
383
408
|
@children << proj
|
@@ -409,7 +434,7 @@ module Squared
|
|
409
434
|
|
410
435
|
run_b(@run, sync: sync, from: from) if series?(@run)
|
411
436
|
args = @output
|
412
|
-
banner = verbosetype > 1 if
|
437
|
+
banner = verbosetype > 1 if from_base?('build')
|
413
438
|
end
|
414
439
|
if args.first.is_a?(Struct)
|
415
440
|
f, blk = args.first.to_a
|
@@ -464,13 +489,42 @@ module Squared
|
|
464
489
|
cmd = compose(as_get(opts), flags, script: true, args: extra, from: from)
|
465
490
|
from = :script if from == :run && script?
|
466
491
|
end
|
467
|
-
run(cmd, var, from: from, banner: banner
|
492
|
+
run(cmd, var, sync: sync, from: from, banner: banner)
|
468
493
|
end
|
469
494
|
|
470
495
|
def depend(*, sync: invoked_sync?('depend'), **)
|
471
496
|
run_b(@depend, sync: sync, from: :depend)
|
472
497
|
end
|
473
498
|
|
499
|
+
def prereqs(*, sync: invoked_sync?('prereqs'), **)
|
500
|
+
on :first, :prereqs
|
501
|
+
graph_deps.flatten(1).sort.each do |proj|
|
502
|
+
next if @@graph[:_].include?(proj)
|
503
|
+
|
504
|
+
if (val = ENV["PREREQS_#{proj.instance_variable_get(:@envname)}"] || ENV["PREREQS_#{proj.ref.upcase}"])
|
505
|
+
val.split(/\s*,\s*/).each do |meth|
|
506
|
+
if proj.respond_to?(meth.to_sym)
|
507
|
+
begin
|
508
|
+
proj.__send__(meth, sync: sync)
|
509
|
+
rescue StandardError => e
|
510
|
+
ret = on(:error, :prereqs, e)
|
511
|
+
raise unless ret == true
|
512
|
+
else
|
513
|
+
next
|
514
|
+
end
|
515
|
+
end
|
516
|
+
if warning?
|
517
|
+
warn log_message(Logger::WARN, name, 'method not found', subject: 'prereqs', hint: meth, pass: true)
|
518
|
+
end
|
519
|
+
end
|
520
|
+
elsif proj.build?
|
521
|
+
proj.build(sync: sync)
|
522
|
+
end
|
523
|
+
@@graph[:_] << proj
|
524
|
+
end
|
525
|
+
on :last, :prereqs
|
526
|
+
end
|
527
|
+
|
474
528
|
def archive(*, sync: invoked_sync?('archive'), **)
|
475
529
|
return unless @archive.is_a?(Hash)
|
476
530
|
|
@@ -478,7 +532,7 @@ module Squared
|
|
478
532
|
end
|
479
533
|
|
480
534
|
def doc(*, sync: invoked_sync?('doc'), **)
|
481
|
-
run_b(@doc, sync: sync, from: :doc)
|
535
|
+
run_b(@doc, sync: sync, from: :doc, banner: from_base?('doc') ? verbosetype > 1 : verbose)
|
482
536
|
end
|
483
537
|
|
484
538
|
def lint(*, sync: invoked_sync?('lint'), **)
|
@@ -542,7 +596,7 @@ module Squared
|
|
542
596
|
on :last, :clean unless pass
|
543
597
|
end
|
544
598
|
|
545
|
-
def graph(start = [], tasks = nil, sync: invoked_sync?('graph'), pass: [], out: nil)
|
599
|
+
def graph(start = [], tasks = nil, *, sync: invoked_sync?('graph'), pass: [], out: nil, **)
|
546
600
|
if (val = env('GRAPH', strict: true))
|
547
601
|
tasks ||= []
|
548
602
|
split_escape(val).each do |task|
|
@@ -560,14 +614,13 @@ module Squared
|
|
560
614
|
data[name] << self
|
561
615
|
on :first, :graph
|
562
616
|
end
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
end
|
617
|
+
ret = graph_branch(self, data, tasks, out, sync: sync, pass: pass)
|
618
|
+
rescue StandardError => e
|
619
|
+
ret = on(:error, :graph, e)
|
620
|
+
raise unless ret == true
|
621
|
+
else
|
569
622
|
if out
|
570
|
-
[out,
|
623
|
+
[out, ret]
|
571
624
|
else
|
572
625
|
on :last, :graph
|
573
626
|
end
|
@@ -736,32 +789,44 @@ module Squared
|
|
736
789
|
self
|
737
790
|
end
|
738
791
|
|
739
|
-
def variable_set(key, *
|
740
|
-
if variables.include?(key)
|
792
|
+
def variable_set(key, *args, **kwargs, &blk)
|
793
|
+
if variables.include?(key) || blocks.include?(key)
|
794
|
+
val = case args.size
|
795
|
+
when 0
|
796
|
+
nil
|
797
|
+
when 1
|
798
|
+
args.first
|
799
|
+
else
|
800
|
+
args
|
801
|
+
end
|
741
802
|
case key
|
742
|
-
when :
|
743
|
-
|
803
|
+
when :index
|
804
|
+
index_set val
|
805
|
+
when :graph
|
806
|
+
graph_set val
|
807
|
+
when :pass
|
808
|
+
pass_set val
|
809
|
+
when :exclude
|
810
|
+
exclude_set val
|
811
|
+
when :parent
|
812
|
+
parent_set val
|
813
|
+
when :run
|
814
|
+
run_set(*args, **kwargs)
|
744
815
|
when :script
|
745
|
-
script_set(*
|
816
|
+
script_set(*args, **kwargs)
|
746
817
|
when :env
|
747
|
-
run_set(output[0], *
|
748
|
-
when :parent
|
749
|
-
@parent = val if (val = val.first).is_a?(Project::Base)
|
750
|
-
when :graph
|
751
|
-
@graph = case val.first
|
752
|
-
when NilClass, FalseClass
|
753
|
-
nil
|
754
|
-
else
|
755
|
-
val.flatten.map!(&:to_s).freeze
|
756
|
-
end
|
818
|
+
run_set(output[0], *args, **kwargs)
|
757
819
|
when :dependfile
|
758
|
-
@dependfile = basepath(*
|
820
|
+
@dependfile = basepath(*args)
|
759
821
|
else
|
760
|
-
if
|
761
|
-
|
762
|
-
|
763
|
-
|
822
|
+
if block_given?
|
823
|
+
if blocks.include?(key)
|
824
|
+
series key, &blk
|
825
|
+
return self
|
826
|
+
end
|
827
|
+
val = block_args val, &blk
|
764
828
|
end
|
829
|
+
instance_variable_set(:"@#{key}", val.first)
|
765
830
|
end
|
766
831
|
else
|
767
832
|
log&.warn "variable_set: @#{key} (private)"
|
@@ -805,6 +870,15 @@ module Squared
|
|
805
870
|
@graph.is_a?(Array) && !@graph.empty?
|
806
871
|
end
|
807
872
|
|
873
|
+
def prereqs?
|
874
|
+
target = self
|
875
|
+
loop do
|
876
|
+
return true if target.graph?
|
877
|
+
break unless (target = target.parent)
|
878
|
+
end
|
879
|
+
false
|
880
|
+
end
|
881
|
+
|
808
882
|
def copy?
|
809
883
|
runnable?(@copy) || workspace.task_defined?(name, 'copy')
|
810
884
|
end
|
@@ -897,7 +971,7 @@ module Squared
|
|
897
971
|
puts_oe(*args, pipe: pipe)
|
898
972
|
end
|
899
973
|
|
900
|
-
def run(cmd = @session, var = nil, exception: @exception, sync: true, banner: true, chdir: path,
|
974
|
+
def run(cmd = @session, var = nil, exception: @exception, sync: true, from: nil, banner: true, chdir: path, **)
|
901
975
|
unless cmd
|
902
976
|
if warning?
|
903
977
|
from &&= from.to_s
|
@@ -940,7 +1014,7 @@ module Squared
|
|
940
1014
|
end
|
941
1015
|
end
|
942
1016
|
|
943
|
-
def run_s(*cmd, env: nil, sync: true, banner: verbose != false,
|
1017
|
+
def run_s(*cmd, env: nil, sync: true, from: nil, banner: verbose != false, **kwargs)
|
944
1018
|
on :first, from
|
945
1019
|
begin
|
946
1020
|
cmd.flatten.each { |val| run(val, env, sync: sync, banner: banner, **kwargs) }
|
@@ -951,11 +1025,11 @@ module Squared
|
|
951
1025
|
on :last, from
|
952
1026
|
end
|
953
1027
|
|
954
|
-
def run_b(obj,
|
1028
|
+
def run_b(obj, **kwargs)
|
955
1029
|
case obj
|
956
1030
|
when Struct
|
957
1031
|
if (any = instance_eval(&obj.block) || obj.run)
|
958
|
-
run_b(any,
|
1032
|
+
run_b(any, **kwargs)
|
959
1033
|
end
|
960
1034
|
when Proc
|
961
1035
|
instance_eval(&obj)
|
@@ -965,9 +1039,9 @@ module Squared
|
|
965
1039
|
if series?(obj)
|
966
1040
|
obj.each(&:call)
|
967
1041
|
elsif obj.is_a?(Array) && obj.any? { |val| !val.is_a?(String) }
|
968
|
-
build(*obj,
|
1042
|
+
build(*obj, **kwargs)
|
969
1043
|
elsif obj
|
970
|
-
run_s(obj.is_a?(Enumerable) ? obj.to_a : obj,
|
1044
|
+
run_s(obj.is_a?(Enumerable) ? obj.to_a : obj, **kwargs)
|
971
1045
|
end
|
972
1046
|
end
|
973
1047
|
end
|
@@ -1052,7 +1126,7 @@ module Squared
|
|
1052
1126
|
k = 0
|
1053
1127
|
final = data.keys.last
|
1054
1128
|
while k < depth
|
1055
|
-
indent = k > 0
|
1129
|
+
indent = k > 0 ? ((last && !j) || (j && k == depth - 1) || single) : j && last && depth == 1
|
1056
1130
|
s += "#{indent || (last && data[final].last == context) ? ' ' : a} "
|
1057
1131
|
k += 1
|
1058
1132
|
end
|
@@ -1087,10 +1161,28 @@ module Squared
|
|
1087
1161
|
deps.concat(objs)
|
1088
1162
|
end
|
1089
1163
|
end
|
1090
|
-
|
1164
|
+
deps.uniq!
|
1165
|
+
deps.delete(target)
|
1166
|
+
data[target.name] = deps
|
1091
1167
|
data
|
1092
1168
|
end
|
1093
1169
|
|
1170
|
+
def graph_deps(target = self)
|
1171
|
+
key = target.name
|
1172
|
+
return @@graph[key] if @@graph.key?(key)
|
1173
|
+
|
1174
|
+
base = []
|
1175
|
+
deps = []
|
1176
|
+
loop do
|
1177
|
+
deps.concat(graph_branch(target, graph_collect(target), []))
|
1178
|
+
break unless (target = target.parent)
|
1179
|
+
|
1180
|
+
base << target
|
1181
|
+
end
|
1182
|
+
deps.uniq!
|
1183
|
+
@@graph[key] = [base, deps]
|
1184
|
+
end
|
1185
|
+
|
1094
1186
|
def env(key, default = nil, suffix: nil, equals: nil, ignore: nil, strict: false)
|
1095
1187
|
a = "#{key}_#{@envname}"
|
1096
1188
|
ret = if suffix
|
@@ -1142,6 +1234,12 @@ module Squared
|
|
1142
1234
|
cmd.done
|
1143
1235
|
end
|
1144
1236
|
|
1237
|
+
def session_arg?(*args, target: @session, **kwargs)
|
1238
|
+
return false unless target
|
1239
|
+
|
1240
|
+
OptionPartition.arg?(target, *args, **kwargs)
|
1241
|
+
end
|
1242
|
+
|
1145
1243
|
def option(*args, target: @session, prefix: target&.first, **kwargs)
|
1146
1244
|
if prefix
|
1147
1245
|
args.each do |val|
|
@@ -1168,7 +1266,7 @@ module Squared
|
|
1168
1266
|
end
|
1169
1267
|
|
1170
1268
|
def print_item(*val)
|
1171
|
-
puts
|
1269
|
+
puts unless printfirst?
|
1172
1270
|
printsucc
|
1173
1271
|
puts val unless val.empty? || (val.size == 1 && val.first.nil?)
|
1174
1272
|
end
|
@@ -1230,7 +1328,7 @@ module Squared
|
|
1230
1328
|
if verbose
|
1231
1329
|
out = []
|
1232
1330
|
if data[:command]
|
1233
|
-
if cmd =~ /\A(?:"((?:[^"]|(?<=\\)")+)"|'((?:[^']|(?<=\\)')+)'|(\S+)) /
|
1331
|
+
if cmd =~ /\A(?:"((?:[^"]|(?<=\\)")+)"|'((?:[^']|(?<=\\)')+)'|(\S+))( |\z)/
|
1234
1332
|
path = $3 || $2 || $1
|
1235
1333
|
cmd = cmd.sub(path, stripext(path).upcase)
|
1236
1334
|
end
|
@@ -1547,6 +1645,20 @@ module Squared
|
|
1547
1645
|
ret
|
1548
1646
|
end
|
1549
1647
|
|
1648
|
+
def command_args(args, force: false, **kwargs)
|
1649
|
+
return unless args.size == 1 && !option('i', 'interactive', **kwargs, equals: '0')
|
1650
|
+
|
1651
|
+
readline('Enter arguments', force: force)
|
1652
|
+
end
|
1653
|
+
|
1654
|
+
def block_args(val = nil, &blk)
|
1655
|
+
if (ret = instance_eval(&blk)).nil?
|
1656
|
+
val
|
1657
|
+
else
|
1658
|
+
ret.is_a?(Array) ? ret : [ret]
|
1659
|
+
end
|
1660
|
+
end
|
1661
|
+
|
1550
1662
|
def runenv
|
1551
1663
|
nil
|
1552
1664
|
end
|
@@ -1749,6 +1861,63 @@ module Squared
|
|
1749
1861
|
@output[4] = args unless @output[4] == false || args.nil?
|
1750
1862
|
end
|
1751
1863
|
|
1864
|
+
def index_set(val)
|
1865
|
+
@index = val if val.is_a?(Numeric)
|
1866
|
+
end
|
1867
|
+
|
1868
|
+
def parent_set(val)
|
1869
|
+
@parent = val if val.is_a?(Project::Base)
|
1870
|
+
end
|
1871
|
+
|
1872
|
+
def exception_set(val)
|
1873
|
+
@exception = env_bool(val, workspace.exception, strict: true)
|
1874
|
+
end
|
1875
|
+
|
1876
|
+
def pipe_set(val)
|
1877
|
+
@pipe = env_pipe(val, workspace.pipe, strict: true)
|
1878
|
+
end
|
1879
|
+
|
1880
|
+
def verbose_set(val)
|
1881
|
+
@verbose = case val
|
1882
|
+
when NilClass
|
1883
|
+
workspace.verbose
|
1884
|
+
when String
|
1885
|
+
env_bool(val, workspace.verbose, strict: true, index: true)
|
1886
|
+
else
|
1887
|
+
val
|
1888
|
+
end
|
1889
|
+
end
|
1890
|
+
|
1891
|
+
def theme_set(common)
|
1892
|
+
@theme = if !verbose
|
1893
|
+
{}
|
1894
|
+
elsif common
|
1895
|
+
workspace.theme
|
1896
|
+
else
|
1897
|
+
__get__(:theme)[:project][to_sym] ||= {}
|
1898
|
+
end
|
1899
|
+
end
|
1900
|
+
|
1901
|
+
def graph_set(val)
|
1902
|
+
@graph = if val
|
1903
|
+
as_a(val).map { |s| workspace.prefix ? workspace.task_name(s).to_sym : s.to_sym }.freeze
|
1904
|
+
end
|
1905
|
+
end
|
1906
|
+
|
1907
|
+
def pass_set(val)
|
1908
|
+
@pass = (val ? as_a(val, :to_s) : []).freeze
|
1909
|
+
end
|
1910
|
+
|
1911
|
+
def exclude_set(val)
|
1912
|
+
@exclude = (val ? as_a(val, :to_sym) : []).freeze
|
1913
|
+
end
|
1914
|
+
|
1915
|
+
def dependfile_set(list)
|
1916
|
+
@dependindex = list.index { |file| basepath(file).exist? }.tap do |index|
|
1917
|
+
@dependfile = @path + list[index || 0]
|
1918
|
+
end
|
1919
|
+
end
|
1920
|
+
|
1752
1921
|
def as_get(val)
|
1753
1922
|
return unless val
|
1754
1923
|
|
@@ -1781,6 +1950,15 @@ module Squared
|
|
1781
1950
|
val.absolute? ? val.to_s.start_with?(File.join(path, '')) : !val.to_s.start_with?(File.join('..', ''))
|
1782
1951
|
end
|
1783
1952
|
|
1953
|
+
def checkdir?(val)
|
1954
|
+
if val.directory? && !val.empty?
|
1955
|
+
true
|
1956
|
+
else
|
1957
|
+
log&.warn "directory \"#{val}\" (#{val.empty? ? 'empty' : 'not found'})"
|
1958
|
+
false
|
1959
|
+
end
|
1960
|
+
end
|
1961
|
+
|
1784
1962
|
def semmajor?(cur, want)
|
1785
1963
|
(cur[0] == '0' && want[0] == '0' ? cur[2] != want[2] : cur[0] != want[0]) && !want[5]
|
1786
1964
|
end
|
@@ -1802,8 +1980,8 @@ module Squared
|
|
1802
1980
|
val.is_a?(Array) && val.all? { |p| p.is_a?(Proc) || p.is_a?(Method) }
|
1803
1981
|
end
|
1804
1982
|
|
1805
|
-
def
|
1806
|
-
|
1983
|
+
def from_base?(val)
|
1984
|
+
task_invoked?(val, "#{val}:sync", 'default')
|
1807
1985
|
end
|
1808
1986
|
|
1809
1987
|
def from_sync?(*val)
|
@@ -1819,13 +1997,10 @@ module Squared
|
|
1819
1997
|
return val if group && !(val = from_sync?(ac, group)).nil?
|
1820
1998
|
return val if (base = workspace.find_base(self)) && !(val = from_sync?(ac, base.ref)).nil?
|
1821
1999
|
return false if workspace.series.chain?(val = task_join(name, action))
|
2000
|
+
return true if task_invoked?(val) && (!task_invoked?(ac) || !workspace.task_defined?(ac, 'sync'))
|
1822
2001
|
|
1823
|
-
|
1824
|
-
|
1825
|
-
else
|
1826
|
-
val = workspace.series.name_get(action)
|
1827
|
-
val != action && invoked_sync?(val)
|
1828
|
-
end
|
2002
|
+
val = workspace.series.name_get(action)
|
2003
|
+
val != action && invoked_sync?(val)
|
1829
2004
|
end
|
1830
2005
|
|
1831
2006
|
def success?(ret)
|
@@ -1848,22 +2023,19 @@ module Squared
|
|
1848
2023
|
workspace.warning
|
1849
2024
|
end
|
1850
2025
|
|
1851
|
-
def has_value?(data,
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
when Enumerable
|
1860
|
-
data.to_a.include?(obj)
|
1861
|
-
end
|
2026
|
+
def has_value?(data, other)
|
2027
|
+
case data
|
2028
|
+
when Hash
|
2029
|
+
other.is_a?(Enumerable) ? other.any? { |obj| data.value?(obj) } : data.value?(other)
|
2030
|
+
when Enumerable
|
2031
|
+
other.is_a?(Enumerable) ? other.any? { |obj| data.include?(obj) } : data.include?(other)
|
2032
|
+
else
|
2033
|
+
false
|
1862
2034
|
end
|
1863
2035
|
end
|
1864
2036
|
|
1865
2037
|
def variables
|
1866
|
-
|
2038
|
+
VAR_SET
|
1867
2039
|
end
|
1868
2040
|
|
1869
2041
|
def blocks
|