squared 0.4.12 → 0.5.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.
@@ -29,7 +29,7 @@ module Squared
29
29
  @impl_project = obj
30
30
  impl_series.base_set(obj)
31
31
  else
32
- kind_project.unshift(obj)
32
+ kind_project.prepend(obj)
33
33
  obj.tasks&.each { |task| impl_series.add(task, obj) }
34
34
  end
35
35
  if (args = obj.batchargs)
@@ -73,7 +73,7 @@ module Squared
73
73
  end
74
74
 
75
75
  @kind_project = []
76
- @task_exclude = SymSet.new
76
+ @task_exclude = Set.new
77
77
 
78
78
  attr_reader :root, :home, :main, :prefix, :exception, :warning, :pipe, :verbose, :theme, :series, :closed
79
79
 
@@ -220,7 +220,7 @@ module Squared
220
220
  if arg.include?(':') || (keys && !keys.include?(arg))
221
221
  task_name(arg)
222
222
  else
223
- /\A#{Regexp.escape(task_name(arg))}:/
223
+ /#{Regexp.escape(arg)}:/
224
224
  end
225
225
  end
226
226
  end
@@ -278,7 +278,7 @@ module Squared
278
278
  end
279
279
 
280
280
  def banner(*args, command: true, styles: nil, border: nil, group: @group, ref: @ref)
281
- data = { command: command, order: [], styles: check_style(styles, empty: false), border: check_style(border) }
281
+ data = Support::BannerData.new(command, [], check_style(styles, empty: false), check_style(border))
282
282
  args.each do |meth|
283
283
  if meth.is_a?(Array)
284
284
  found = false
@@ -301,9 +301,8 @@ module Squared
301
301
  elsif !Application.attr_banner.include?(meth = meth.to_sym)
302
302
  next
303
303
  end
304
- data[:order] << meth
304
+ data.order << meth
305
305
  end
306
- data = {} if !command && data[:order].empty?
307
306
  if group
308
307
  label = :group
309
308
  items = as_a group
@@ -316,11 +315,7 @@ module Squared
316
315
  end
317
316
 
318
317
  def add(path, project = nil, **kwargs, &blk)
319
- if @withargs
320
- data = @withargs.dup
321
- data.merge!(kwargs)
322
- kwargs = data
323
- end
318
+ kwargs = @withargs.yield_self { |data| data.dup.update(kwargs) } if @withargs
324
319
  ref = if kwargs.key?(:ref)
325
320
  kwargs = kwargs.dup unless @withargs
326
321
  kwargs.delete(:ref)
@@ -344,6 +339,7 @@ module Squared
344
339
  elsif ref < Project::Base
345
340
  ref
346
341
  end) || @kind[name]&.last || Project::Base).new(self, path, name, **kwargs)
342
+ proj.__send__(:index_set, @project.size)
347
343
  @project[name] = proj
348
344
  __get__(:project)[name] = proj unless kwargs[:private]
349
345
  proj.instance_eval(&blk) if block_given?
@@ -359,7 +355,7 @@ module Squared
359
355
  end
360
356
  .each do |dir, basename, opts|
361
357
  args = kwargs.dup
362
- args.merge!(opts) if opts
358
+ args.update(opts) if opts
363
359
  add(dir, basename, group: val, **args, &blk)
364
360
  end
365
361
  self
@@ -398,7 +394,7 @@ module Squared
398
394
  }
399
395
  data.each do |key, val|
400
396
  key = key.to_s
401
- if key.match?(/\A(\\A|\^)/) || key.match?(/(\\z|\$)\z/)
397
+ if key.start_with?(/(\\A|\^)/) || key.match?(/(\\z|\$)\z/)
402
398
  @describe[:replace] << [Regexp.new(key), val]
403
399
  else
404
400
  @describe[val.is_a?(Regexp) ? :pattern : :alias][key.to_s] = val
@@ -416,7 +412,7 @@ module Squared
416
412
  if ret.empty?
417
413
  ret = @project.select { |_, item| item.ref?(ref) }.map(&:last) if ref
418
414
  if ret.empty? && (path || name)
419
- path &&= rootpath(path)
415
+ path &&= rootpath path
420
416
  name &&= name.to_s
421
417
  proj = @project.find { |_, item| (path && item.path == path) || (name && item.name == name) }&.last
422
418
  ret << proj if proj
@@ -516,7 +512,7 @@ module Squared
516
512
  obj.allref.each do |ref|
517
513
  next unless obj.has?(key, ref) && (alt = data[ref])
518
514
 
519
- ret = task_resolve(obj, alt)
515
+ ret = task_resolve obj, alt
520
516
  break unless ret.empty?
521
517
  end
522
518
  else
@@ -536,7 +532,7 @@ module Squared
536
532
  end
537
533
 
538
534
  def format_desc(val, opts = nil, arg: 'opts*', before: nil, after: nil, out: false)
539
- return unless TASK_METADATA || out
535
+ return unless TASK_METADATA
540
536
 
541
537
  val = val.split(':') if val.is_a?(String)
542
538
  if before || after || opts
@@ -702,7 +698,7 @@ module Squared
702
698
  else
703
699
  step = 0
704
700
  catch :found do
705
- has = ->(c, d) { c.any? { |e| e.is_a?(Regexp) ? d.match?(e) : d == e } }
701
+ has = ->(c, d) { c.any? { |e| e.is_a?(Regexp) ? d.start_with?(e) : d == e } }
706
702
  w = data.with
707
703
  a = data.after
708
704
  b = data.before
@@ -761,7 +757,7 @@ module Squared
761
757
  end
762
758
  end
763
759
  if step == -1
764
- level.unshift(data.action)
760
+ level.prepend(data.action)
765
761
  step = 0
766
762
  elsif step > 0
767
763
  (level[step -= 1] ||= []).concat(data.action)
@@ -851,7 +847,7 @@ module Squared
851
847
  def root?(path, pass: [])
852
848
  return false unless path.directory?
853
849
 
854
- path.children.each do |c|
850
+ path.each_child do |c|
855
851
  name = c.basename.to_s
856
852
  next if c.to_s == __FILE__ || (@main == name && c.directory? && c.empty?) || pass.any? { |val| val == name }
857
853
 
@@ -861,14 +857,14 @@ module Squared
861
857
  end
862
858
 
863
859
  def script?(state, target: nil, pat: nil, group: nil, ref: baseref, global: false)
864
- data = script_find(ref, group)
860
+ data = script_find ref, group
865
861
  if global
866
862
  target = data[:script] || data[:run] if target.nil?
867
863
  pat = data[state] if pat.nil?
868
864
  end
869
865
  return false if state == :prod && data[:dev] == true && data[:global]
870
866
 
871
- target && pat.is_a?(Regexp) ? as_a(target).any? { |val| val.match?(pat) } : pat == true
867
+ target && pat.is_a?(Regexp) ? as_a(target).any?(pat) : pat == true
872
868
  end
873
869
 
874
870
  def scriptobj