squared 0.5.12 → 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.
@@ -21,7 +21,7 @@ module Squared
21
21
  include Prompt
22
22
 
23
23
  def append(target, *args, delim: false, escape: false, quote: true, strip: nil, force: true, double: false,
24
- **)
24
+ filter: nil, **)
25
25
  return if (ret = args.flatten).empty?
26
26
 
27
27
  target << '--' if delim && !target.include?('--')
@@ -29,6 +29,22 @@ module Squared
29
29
  pat, s = Array(strip)
30
30
  ret.map! { |val| val.gsub(pat, s || '') }
31
31
  end
32
+ ret, err = ret.partition { |val| filter.match?(val) } if filter
33
+ if block_given?
34
+ out = []
35
+ err ||= []
36
+ ret.each do |val|
37
+ case (s = yield val)
38
+ when String
39
+ out << s
40
+ when NilClass, FalseClass
41
+ err << val
42
+ else
43
+ out << val
44
+ end
45
+ end
46
+ ret = out
47
+ end
32
48
  if escape || quote
33
49
  ret.map! do |val|
34
50
  if escape
@@ -43,13 +59,13 @@ module Squared
43
59
  else
44
60
  target.concat(ret)
45
61
  end
46
- ret
62
+ err || ret
47
63
  end
48
64
 
49
65
  def clear(target, opts, pass: true, styles: nil, **kwargs)
50
66
  return if opts.empty?
51
67
 
52
- kwargs[:subject] ||= stripext target.first
68
+ kwargs[:subject] ||= target.first.stripext
53
69
  kwargs[:hint] ||= 'unrecognized'
54
70
  append(target, opts, delim: true) if kwargs.delete(:append)
55
71
  warn log_message(Logger::WARN, opts.join(', '), pass: true, **kwargs)
@@ -84,6 +100,20 @@ module Squared
84
100
  ret.select { |val| single ? val.size == 1 : val.size > 1 }
85
101
  end
86
102
 
103
+ def uniq!(list, pass = [])
104
+ keys = {}
105
+ list.each_with_index do |val, i|
106
+ j = val =~ OPT_VALUE ? $1 : val
107
+ (keys[j] ||= []) << i unless pass.include?(j)
108
+ end
109
+ data = keys.map { |item| item[1].size > 1 ? item[1][0..-2] : [] }.reject(&:empty?)
110
+ return if data.empty?
111
+
112
+ data.each { |key| key.each { |i| list[i] = nil } }
113
+ list.compact!
114
+ list
115
+ end
116
+
87
117
  def arg?(target, *args, value: false, **)
88
118
  r, s = args.partition { |val| val.is_a?(Regexp) }
89
119
  r << matchopts(s, value) unless s.empty?
@@ -120,13 +150,12 @@ module Squared
120
150
  end
121
151
  end
122
152
 
123
- attr_reader :target, :extras, :found, :errors, :values, :project, :path
153
+ attr_reader :target, :extras, :found, :errors, :values, :project, :path, :sep
124
154
 
125
155
  def_delegators :@target, :+, :-, :<<, :any?, :none?, :include?, :add, :add?, :find, :find_all, :find_index,
126
156
  :merge, :delete, :delete?, :delete_if, :grep, :grep_v, :inspect, :to_a, :to_s
127
- def_delegators :@extras, :empty?, :each, :each_with_index, :partition, :dup, :first, :last, :shift, :unshift,
128
- :pop, :push, :concat, :index, :join, :map, :map!, :detect, :select, :select!, :reject, :size,
129
- :delete_at
157
+ def_delegators :@extras, :empty?, :each, :each_with_index, :partition, :dup, :first, :shift, :unshift,
158
+ :pop, :push, :concat, :index, :join, :map, :map!, :detect, :select, :select!, :reject, :size
130
159
 
131
160
  def_delegator :@extras, :delete, :remove
132
161
  def_delegator :@extras, :delete_at, :remove_at
@@ -134,10 +163,11 @@ module Squared
134
163
  def_delegator :@extras, :find_all, :detect_all
135
164
  def_delegator :@extras, :find_index, :detect_index
136
165
 
137
- def initialize(opts, list, target = Set.new, project: nil, path: nil, **kwargs, &blk)
166
+ def initialize(opts, list, target = Set.new, project: nil, path: nil, sep: '=', **kwargs, &blk)
138
167
  @target = target.is_a?(Set) ? target : target.to_set
139
168
  @project = project
140
169
  @path = path || project&.path
170
+ @sep = sep
141
171
  @errors = []
142
172
  @found = []
143
173
  parse(list, opts, **kwargs, &blk)
@@ -171,7 +201,7 @@ module Squared
171
201
  .each do |val|
172
202
  if (n = val.index('='))
173
203
  flag = val[0, n]
174
- case val[n + 1]
204
+ case val[n.succ]
175
205
  when 'e'
176
206
  e << flag
177
207
  when 'b'
@@ -196,7 +226,7 @@ module Squared
196
226
  else
197
227
  next
198
228
  end
199
- m << flag if flag.size == 1 && val[n + 2] == 'm'
229
+ m << flag if val[n + 2] == 'm'
200
230
  bare << flag if val.end_with?('?')
201
231
  else
202
232
  bare << val
@@ -205,7 +235,7 @@ module Squared
205
235
  no = (no || []).map { |val| (n = val.index('=')) ? val[0, n] : val }
206
236
  bare.concat(no)
207
237
  if underscore
208
- tr = ->(list) { list.map { |val| val.tr('-', '_') } }
238
+ tr = ->(a) { a.map { |val| val.tr('-', '_') } }
209
239
  @values.concat(tr.call(@values))
210
240
  bare.concat(tr.call(bare))
211
241
  e.concat(tr.call(e))
@@ -225,7 +255,7 @@ module Squared
225
255
  [f, /\A\d*(?:\.\d+)?\z/],
226
256
  [si, /\A-?\d+\z/]
227
257
  ].freeze
228
- numcheck = ->(k, v) { numtype.any? { |flag, pat| flag.include?(k) && pat.match?(v) } }
258
+ numcheck = ->(k, v) { numtype.any? { |flag, pat| flag.include?(k) && v.match?(pat) } }
229
259
  skip = false
230
260
  opts.each do |opt|
231
261
  next skip = true if opt == '--'
@@ -243,21 +273,21 @@ module Squared
243
273
  val = $2
244
274
  merge = m.include?(key)
245
275
  if e.include?(key)
246
- add shell_option(key, val, merge: merge)
276
+ add shell_option(key, val, merge: merge, sep: sep)
247
277
  elsif q.include?(key)
248
- add quote_option(key, val, double: qq.include?(key), merge: merge)
278
+ add quote_option(key, val, double: qq.include?(key), merge: merge, sep: sep)
249
279
  elsif p.include?(key)
250
280
  if val.match?(/\A(["']).+\1\z/)
251
- add shell_option(key, val, escape: false, merge: merge)
281
+ add shell_option(key, val, escape: false, merge: merge, sep: sep)
252
282
  elsif path
253
- add quote_option(key, path + val, merge: merge)
283
+ add quote_option(key, path + val, merge: merge, sep: sep)
254
284
  else
255
285
  push opt
256
286
  end
257
287
  elsif b.include?(key) || (bl.include?(key) && %w[true false].include?(val)) || numcheck.call(key, val)
258
- add basic_option(key, val, merge: merge)
288
+ add basic_option(key, val, merge: merge, sep: sep)
259
289
  elsif merge
260
- add basic_option(key, val, merge: true)
290
+ add basic_option(key, val, merge: true, sep: sep)
261
291
  else
262
292
  push opt
263
293
  end
@@ -269,28 +299,33 @@ module Squared
269
299
  skip = true if first&.any? { |s| s.is_a?(Regexp) ? opt.match?(s) : !opt.include?(s) }
270
300
  end
271
301
  end
272
- @values = @values.empty? ? /\A\s+\z/ : /\A(#{@values.join('|')})=(.+)\z/m
302
+ @values = @values.empty? ? /\A\s+\z/ : /\A(#{@values.join('|')})#{sep}(.+)\z/m
273
303
  @extras.each_with_index(&blk) if block_given?
274
304
  self
275
305
  end
276
306
 
277
- def swap(opts = nil)
307
+ def swap(opts = nil, &blk)
278
308
  unless opts
279
309
  opts = found
280
310
  @found = []
281
311
  end
312
+ opts.sort!(&blk) if block_given?
282
313
  @extras = opts
283
314
  self
284
315
  end
285
316
 
286
- def append(*args, **kwargs)
317
+ def append(*args, **kwargs, &blk)
287
318
  args = extras if args.empty?
288
- OptionPartition.append(target, *args, **kwargs)
319
+ out = OptionPartition.append(target, *args, **kwargs, &blk)
320
+ errors.concat(out) if out && (block_given? || kwargs[:filter])
289
321
  self
290
322
  end
291
323
 
292
324
  def append_any(*args, quote: true, **kwargs)
293
325
  (args.empty? ? extras : args.flatten).each do |val|
326
+ val = yield val if block_given?
327
+ next unless val.is_a?(String)
328
+
294
329
  if exist?(val)
295
330
  add_path(val, **kwargs)
296
331
  elsif quote
@@ -308,7 +343,7 @@ module Squared
308
343
  end
309
344
 
310
345
  def values_of(*args, strict: true, first: false, last: false)
311
- eq, s = strict ? ['=', '[^ ]+'] : ['(?:=| +)', '[^-][^ ]*']
346
+ eq, s = strict ? [sep, '[^ ]+'] : ['(?:=| +)', '[^-][^ ]*']
312
347
  g = ["\"((?:[^\"]|(?<=\\\\)\"(?!$#{windows? ? '| ' : ''}))*)\""]
313
348
  g << "'((?:[^']|'\\\\'')*)'" unless windows?
314
349
  g << "(#{s})"
@@ -347,22 +382,18 @@ module Squared
347
382
  def clear(opts = nil, errors: false, **kwargs)
348
383
  styles = project.theme[:inline] if project
349
384
  if errors
350
- OptionPartition.clear(target, self.errors, styles: styles, **kwargs)
351
- self.errors.clear
385
+ OptionPartition.clear(target, @errors, styles: styles, **kwargs)
386
+ @errors.clear
352
387
  return self unless opts
353
388
  end
354
389
  opts ||= extras
355
- OptionPartition.clear(target, if found.empty?
356
- opts
357
- else
358
- opts.reject { |val| found.include?(val) }
359
- end, styles: styles, **kwargs)
390
+ OptionPartition.clear(target, opts - found, styles: styles, **kwargs)
360
391
  opts.clear
361
392
  self
362
393
  end
363
394
 
364
395
  def adjoin(*args, with: nil, start: false)
365
- i = -1
396
+ index = -1
366
397
  temp = to_a
367
398
  if with
368
399
  pat = case with
@@ -373,44 +404,50 @@ module Squared
373
404
  else
374
405
  with
375
406
  end
376
- temp.each_with_index do |val, index|
407
+ temp.each_with_index do |val, i|
377
408
  if val.to_s.match?(pat)
378
- i = index + (start.is_a?(Numeric) ? start : 1)
409
+ index = i + (start.is_a?(Numeric) ? start : 1)
379
410
  break
380
411
  end
381
412
  end
382
413
  else
383
- temp.each_with_index do |val, index|
384
- if i == 0
414
+ temp.each_with_index do |val, i|
415
+ if index == 0
385
416
  next unless val.start_with?('-')
386
417
 
387
- i = index
418
+ index = i
388
419
  break
389
- elsif index > 0 && !val.start_with?('-')
420
+ elsif i > 0 && !val.start_with?('-')
390
421
  if start
391
- i = index + (start.is_a?(Numeric) ? start : 1)
422
+ index = i + (start.is_a?(Numeric) ? start : 1)
392
423
  break
393
424
  end
394
- i = 0
425
+ index = 0
395
426
  end
396
427
  end
397
428
  end
398
- if i > 0
429
+ if index > 0
399
430
  if args.empty?
400
431
  args = dup
401
432
  reset
402
433
  else
403
434
  args.each { |val| remove val }
404
435
  end
405
- args = temp[0...i] + args + temp[i..-1]
436
+ args = temp[0...index] + args + temp[index..-1]
406
437
  target.clear
407
438
  end
408
439
  merge args
409
440
  self
410
441
  end
411
442
 
412
- def add_path(*args, **kwargs)
413
- add shell_quote(path ? path.join(*args) : File.join(*args), option: false, **kwargs)
443
+ def add_path(*args, force: true, double: false, **kwargs)
444
+ if args.empty?
445
+ args = select { |s| s.is_a?(String) }
446
+ args.map! { |val| path + val } if path
447
+ append(args, force: force, **kwargs)
448
+ else
449
+ add shell_quote(path ? path.join(*args) : File.join(*args), option: false, force: force, double: double)
450
+ end
414
451
  self
415
452
  end
416
453
 
@@ -419,6 +456,62 @@ module Squared
419
456
  self
420
457
  end
421
458
 
459
+ def add_option(flag, val = nil, **kwargs)
460
+ add shell_option(flag, val, **kwargs)
461
+ self
462
+ end
463
+
464
+ def add_first(fallback = nil, prefix: nil, path: false, quote: false, reverse: false, expect: false, **kwargs)
465
+ val = (reverse ? pop : shift) || fallback
466
+ if val
467
+ val.delete_prefix!(prefix) if prefix
468
+ return self if block_given? && !(val = yield val).is_a?(String)
469
+
470
+ if path
471
+ add_path(val, **kwargs)
472
+ elsif quote
473
+ add_quote(val, **kwargs)
474
+ else
475
+ add val
476
+ end
477
+ elsif expect
478
+ raise(expect.is_a?(String) ? expect : 'no value provided')
479
+ end
480
+ self
481
+ end
482
+
483
+ def last(val = nil, &blk)
484
+ unless block_given?
485
+ case val
486
+ when NilClass
487
+ return extras.last
488
+ when Numeric
489
+ return extras.last(val)
490
+ when String, Array, Regexp
491
+ val = OptionPartition.send(:matchopts, val) unless val.is_a?(Regexp)
492
+ blk = proc { |s| s&.match?(val) }
493
+ else
494
+ raise TypeError, "unknown: #{val}"
495
+ end
496
+ end
497
+ ret = find_all(&blk)
498
+ unless ret.empty?
499
+ ret = case val
500
+ when NilClass
501
+ ret.first(1)
502
+ when Numeric
503
+ ret.first(val)
504
+ else
505
+ ret
506
+ end
507
+ ret.each do |opt|
508
+ delete opt
509
+ add opt
510
+ end
511
+ end
512
+ val.nil? ? ret.first : ret
513
+ end
514
+
422
515
  def splice(*exclude, quote: true, delim: true, path: false, pattern: false, &blk)
423
516
  found, other = if block_given?
424
517
  partition(&blk)
@@ -452,7 +545,7 @@ module Squared
452
545
  self
453
546
  end
454
547
 
455
- def append?(key, val = nil, type: nil, force: false, **kwargs)
548
+ def append?(key, val = nil, type: nil, force: false, sep: '=', **kwargs)
456
549
  return false unless force || !arg?(key)
457
550
 
458
551
  val = yield self if block_given?
@@ -461,11 +554,11 @@ module Squared
461
554
  type ||= :quote if kwargs.empty?
462
555
  add case type
463
556
  when :quote
464
- quote_option(key, val)
557
+ quote_option(key, val, sep: sep)
465
558
  when :basic
466
- basic_option(key, val)
559
+ basic_option(key, val, sep: sep)
467
560
  else
468
- shell_option(key, val, **kwargs)
561
+ shell_option(key, val, sep: sep, **kwargs)
469
562
  end
470
563
  true
471
564
  end
@@ -474,24 +567,23 @@ module Squared
474
567
  OptionPartition.arg?(target, *args, **kwargs)
475
568
  end
476
569
 
477
- def exist?(*args, add: false, first: false, last: false)
478
- return false unless path
479
- return path.join(*args).exist? unless args.empty?
570
+ def exist?(*args, add: false, first: false, last: false, glob: false)
571
+ return with_glob?(File.join(*args), glob) unless args.empty?
480
572
 
481
573
  if first || last
482
- return false unless (val = first ? self.first : self.last).is_a?(String)
574
+ return false unless (val = first ? self.first : self.last)
483
575
 
484
- path.join(val).exist?.tap do |ret|
576
+ with_glob?(val, glob).tap do |ret|
485
577
  next unless add && ret
486
578
 
487
- add_path(first ? shift : pop)
579
+ add_first(path: true, reverse: !first)
488
580
  end
489
581
  else
490
- each_with_index do |val, index|
491
- next unless val.is_a?(String) && path.join(val).exist?
582
+ each_with_index do |val, i|
583
+ next unless with_glob?(val, glob)
492
584
 
493
585
  if add
494
- remove_at index
586
+ remove_at i
495
587
  add_path val
496
588
  end
497
589
  return true
@@ -513,6 +605,12 @@ module Squared
513
605
  val[OPT_VALUE, 1] || val
514
606
  end
515
607
 
608
+ def with_glob?(val, glob = true)
609
+ return false unless path && val.is_a?(String) && !val.empty?
610
+
611
+ path.join(val).exist? || (glob && !path.glob(val).empty?)
612
+ end
613
+
516
614
  def windows?
517
615
  Rake::Win32.windows?
518
616
  end
@@ -531,31 +629,31 @@ module Squared
531
629
  end
532
630
 
533
631
  def last(val, pat)
534
- (@last ||= []).append([val, pat, $1]) if val =~ pat
632
+ (@last ||= []).push([val, pat, $1]) if val =~ pat
535
633
  self << val
536
634
  end
537
635
 
538
636
  def pass(&blk)
539
637
  ret = to_a.map!(&:to_s).reject(&:empty?)
540
638
  @last&.each do |val, pat, key|
541
- i = []
542
- j = nil
543
- ret.each_with_index do |opt, index|
639
+ items = []
640
+ index = nil
641
+ ret.each_with_index do |opt, i|
544
642
  if opt == val
545
- j = index
546
- elsif j && opt[pat, 1] == key
547
- i << index
643
+ index = i
644
+ elsif index && opt[pat, 1] == key
645
+ items << i
548
646
  end
549
647
  end
550
- next unless j && !i.empty?
648
+ next unless index && !items.empty?
551
649
 
552
- val = ret[j]
553
- cur = j
554
- i.each do |k|
650
+ val = ret[index]
651
+ cur = index
652
+ items.each do |k|
555
653
  ret[cur] = ret[k]
556
654
  cur = k
557
655
  end
558
- ret[i.last] = val
656
+ ret[items.last] = val
559
657
  end
560
658
  return ret unless block_given?
561
659
 
@@ -3,16 +3,6 @@
3
3
  module Squared
4
4
  module Workspace
5
5
  module Repo
6
- class << self
7
- def read_manifest(path)
8
- require 'rexml/document'
9
- return unless (file = path + '.repo/manifest.xml').exist?
10
-
11
- doc = REXML::Document.new(file.read)
12
- doc.elements['manifest/include'].attributes['name']&.sub('.xml', '')
13
- end
14
- end
15
-
16
6
  attr_reader :manifest_url, :manifest
17
7
 
18
8
  def repo(url, manifest = 'latest', run: nil, script: nil, args: nil, dev: nil, prod: nil,
@@ -25,18 +15,18 @@ module Squared
25
15
  @root = nil unless path.directory?
26
16
  elsif !@root.exist?
27
17
  @root.mkpath
28
- elsif !repo_install?
29
- @root = nil unless repo_confirm
18
+ elsif !repo_install? && !repo_confirm
19
+ @root = nil
30
20
  end
21
+ raise_error Errno::EEXIST, path.cleanpath, hint: 'REPO_HOME' unless @root
31
22
  end
32
- raise_error("path invalid: #{val}", hint: 'REPO_HOME') unless @root
33
23
  path.realdirpath
34
24
  elsif (val = env('REPO_ROOT'))
35
25
  @root = Pathname.new(val).realdirpath
36
26
  if !@root.exist?
37
27
  @root.mkpath
38
- elsif !repo_install?(parent: true)
39
- raise_error("path does not exist: #{val}", hint: 'REPO_ROOT') unless repo_confirm
28
+ elsif !repo_install?(parent: true) && !repo_confirm
29
+ raise_error Errno::EEXIST, @root, hint: 'REPO_ROOT'
40
30
  end
41
31
  @root.join(main).realdirpath
42
32
  elsif repo_install?(parent: true) && (!@home.exist? || @root + main == @home)
@@ -51,9 +41,13 @@ module Squared
51
41
  @manifest = manifest
52
42
  data = scriptobj
53
43
  if repo?
44
+ sc, ru = env('REPO_BUILD', '').split(',', 2).map!(&:strip)
54
45
  if script
55
- if (val = env('REPO_BUILD'))
56
- data[:script] = case val
46
+ data[:script] = if sc.to_s.empty?
47
+ script
48
+ else
49
+ data[:env][:script] = true
50
+ case sc
57
51
  when 'verbose'
58
52
  @verbose = 1
59
53
  if script.is_a?(Array)
@@ -67,20 +61,23 @@ module Squared
67
61
  @warning = false
68
62
  script
69
63
  else
70
- val
64
+ sc
71
65
  end
72
- data[:env] = true
73
- else
74
- data[:script] = script
75
- end
66
+ end
76
67
  data[:args] = (val = env('REPO_SCRIPT')) ? shell_split(val, join: true) : args
77
- elsif (val = env('REPO_BUILD'))
78
- data[:run] = val
79
- data[:env] = true
68
+ data[:global][:script] = true
80
69
  else
81
- data[:run] = run
70
+ ru ||= sc
71
+ end
72
+ if run
73
+ data[:run] = if ru.to_s.empty?
74
+ run
75
+ else
76
+ data[:env][:run] = true
77
+ ru
78
+ end
79
+ data[:global][:run] = true
82
80
  end
83
- data[:global] = true
84
81
  data[:dev] = env_match 'REPO_DEV', dev
85
82
  data[:prod] = env_match 'REPO_PROD', prod
86
83
  if (val = env('REPO_GROUP'))
@@ -98,9 +95,8 @@ module Squared
98
95
  if script
99
96
  data[:script] = script
100
97
  data[:args] = args
101
- else
102
- data[:run] = run
103
98
  end
99
+ data[:run] = run if run
104
100
  data[:dev] = dev
105
101
  data[:prod] = prod
106
102
  script_set(data, group: group, ref: ref)
@@ -115,7 +111,7 @@ module Squared
115
111
 
116
112
  namespace task_name('repo') do |ns|
117
113
  path = ns.scope.path
118
- branch = env('REPO_MANIFEST') || Repo.read_manifest(root)
114
+ branch = env('REPO_MANIFEST') || repo_manifest
119
115
  target = branch || manifest
120
116
  stage = nil
121
117
  opts = %w[force rebase detach submodules fail no-update gc]
@@ -160,7 +156,7 @@ module Squared
160
156
  args = args.to_a
161
157
  u = env('REPO_URL') || manifest_url
162
158
  m = args.first && !opts.include?(args.first) ? args.shift : target
163
- g = args.first && !opts.include?(args.first) ? args.shift : nil
159
+ g = (args.shift if args.first && !opts.include?(args.first))
164
160
  g = case (val = env('REPO_GROUPS'))
165
161
  when '', NilClass
166
162
  g
@@ -216,7 +212,7 @@ module Squared
216
212
  end
217
213
  end
218
214
 
219
- series.sync.append(
215
+ series.sync.push(
220
216
  task_join(path, 'all'),
221
217
  task_join(path, 'init'),
222
218
  task_join(path, 'sync')
@@ -224,11 +220,19 @@ module Squared
224
220
  end
225
221
  end
226
222
 
223
+ def repo_manifest(path = root)
224
+ return unless (file = path + '.repo/manifest.xml').exist?
225
+
226
+ require 'rexml/document'
227
+ doc = REXML::Document.new(file.read)
228
+ doc.elements['manifest/include'].attributes['name']&.sub('.xml', '')
229
+ end
230
+
227
231
  def repo_confirm
228
232
  return false unless root.directory?
229
233
 
230
234
  path = sub_style(root, styles: theme[:inline])
231
- @repo_override = Common::Prompt.confirm(
235
+ @repo_override = env('REPO_Y', equals: '1') || Common::Prompt.confirm(
232
236
  "#{log_title(:warn)} \"#{path}\" is not empty. Continue with installation?",
233
237
  'N',
234
238
  timeout: env('REPO_TIMEOUT', 15, ignore: '0')
@@ -247,7 +251,7 @@ module Squared
247
251
  def repo_opts(*args)
248
252
  return args unless (n = ARGV.index('--'))
249
253
 
250
- ARGV[(n + 1)..-1].concat(args)
254
+ ARGV[n.succ..-1].concat(args)
251
255
  end
252
256
 
253
257
  def repo?
@@ -199,9 +199,7 @@ module Squared
199
199
  end
200
200
 
201
201
  def batch?(obj, key)
202
- return false unless (data = batch_get(key))
203
-
204
- data.keys.any? { |ref| obj.ref?(ref) }
202
+ (data = batch_get(key)) ? data.keys.any? { |ref| obj.ref?(ref) } : false
205
203
  end
206
204
 
207
205
  def chain?(val)
@@ -240,9 +238,11 @@ module Squared
240
238
  end
241
239
 
242
240
  def already_invoked?(list, val)
243
- return Rake::Task.tasks.any? { |obj| obj.already_invoked && list.include?(obj.name) } unless val
244
-
245
- list.include?(val) && !invoked_get(val).nil?
241
+ if val
242
+ list.include?(val) && !invoked_get(val).nil?
243
+ else
244
+ Rake::Task.tasks.any? { |obj| obj.already_invoked && list.include?(obj.name) }
245
+ end
246
246
  end
247
247
  end
248
248
 
@@ -3,30 +3,9 @@
3
3
  module Squared
4
4
  module Workspace
5
5
  module Support
6
- class << self
7
- def hashobj
8
- Hash.new { |data, key| data[key] = {} }
9
- end
10
-
11
- def hashlist
12
- Hash.new { |data, key| data[key] = [] }
13
- end
14
-
15
- def hashdup(data, pass: {})
16
- ret = {}
17
- data.each do |key, val|
18
- ret[key] = case val
19
- when Hash
20
- pass[val] ||= hashdup(val, pass: pass)
21
- when Proc, Method
22
- val
23
- else
24
- val.dup
25
- end
26
- end
27
- ret
28
- end
29
- end
6
+ RunData = Struct.new('RunData', :run, :block)
7
+ ChainData = Struct.new('ChainData', :action, :step, :with, :before, :after, :sync)
8
+ BannerData = Struct.new('BannerData', :command, :order, :styles, :border)
30
9
  end
31
10
  end
32
11
  end