squared 0.4.14 → 0.5.1

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 = Struct::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 = Array(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)
@@ -360,7 +355,7 @@ module Squared
360
355
  end
361
356
  .each do |dir, basename, opts|
362
357
  args = kwargs.dup
363
- args.merge!(opts) if opts
358
+ args.update(opts) if opts
364
359
  add(dir, basename, group: val, **args, &blk)
365
360
  end
366
361
  self
@@ -399,7 +394,7 @@ module Squared
399
394
  }
400
395
  data.each do |key, val|
401
396
  key = key.to_s
402
- if key.match?(/\A(\\A|\^)/) || key.match?(/(\\z|\$)\z/)
397
+ if key.start_with?(/(\\A|\^)/) || key.match?(/(\\z|\$)\z/)
403
398
  @describe[:replace] << [Regexp.new(key), val]
404
399
  else
405
400
  @describe[val.is_a?(Regexp) ? :pattern : :alias][key.to_s] = val
@@ -417,7 +412,7 @@ module Squared
417
412
  if ret.empty?
418
413
  ret = @project.select { |_, item| item.ref?(ref) }.map(&:last) if ref
419
414
  if ret.empty? && (path || name)
420
- path &&= rootpath(path)
415
+ path &&= rootpath path
421
416
  name &&= name.to_s
422
417
  proj = @project.find { |_, item| (path && item.path == path) || (name && item.name == name) }&.last
423
418
  ret << proj if proj
@@ -517,7 +512,7 @@ module Squared
517
512
  obj.allref.each do |ref|
518
513
  next unless obj.has?(key, ref) && (alt = data[ref])
519
514
 
520
- ret = task_resolve(obj, alt)
515
+ ret = task_resolve obj, alt
521
516
  break unless ret.empty?
522
517
  end
523
518
  else
@@ -537,7 +532,7 @@ module Squared
537
532
  end
538
533
 
539
534
  def format_desc(val, opts = nil, arg: 'opts*', before: nil, after: nil, out: false)
540
- return unless TASK_METADATA || out
535
+ return unless TASK_METADATA
541
536
 
542
537
  val = val.split(':') if val.is_a?(String)
543
538
  if before || after || opts
@@ -711,7 +706,7 @@ module Squared
711
706
  else
712
707
  step = 0
713
708
  catch :found do
714
- has = ->(c, d) { c.any? { |e| e.is_a?(Regexp) ? d.match?(e) : d == e } }
709
+ has = ->(c, d) { c.any? { |e| e.is_a?(Regexp) ? d.start_with?(e) : d == e } }
715
710
  w = data.with
716
711
  a = data.after
717
712
  b = data.before
@@ -770,7 +765,7 @@ module Squared
770
765
  end
771
766
  end
772
767
  if step == -1
773
- level.unshift(data.action)
768
+ level.prepend(data.action)
774
769
  step = 0
775
770
  elsif step > 0
776
771
  (level[step -= 1] ||= []).concat(data.action)
@@ -860,7 +855,7 @@ module Squared
860
855
  def root?(path, pass: [])
861
856
  return false unless path.directory?
862
857
 
863
- path.children.each do |c|
858
+ path.each_child do |c|
864
859
  name = c.basename.to_s
865
860
  next if c.to_s == __FILE__ || (@main == name && c.directory? && c.empty?) || pass.any? { |val| val == name }
866
861
 
@@ -870,14 +865,14 @@ module Squared
870
865
  end
871
866
 
872
867
  def script?(state, target: nil, pat: nil, group: nil, ref: baseref, global: false)
873
- data = script_find(ref, group)
868
+ data = script_find ref, group
874
869
  if global
875
870
  target = data[:script] || data[:run] if target.nil?
876
871
  pat = data[state] if pat.nil?
877
872
  end
878
873
  return false if state == :prod && data[:dev] == true && data[:global]
879
874
 
880
- target && pat.is_a?(Regexp) ? Array(target).any? { |val| val.match?(pat) } : pat == true
875
+ target && pat.is_a?(Regexp) ? Array(target).any?(pat) : pat == true
881
876
  end
882
877
 
883
878
  def scriptobj