squared 0.5.13 → 0.5.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3ed5681f473df27b02a4787101d56a1081c2c1bd6db77b2e9f39368b8b131dc
4
- data.tar.gz: c968c299822d98c675f032f024d904305c5aaa045dccced2f8d02228b714bdc9
3
+ metadata.gz: 128dc5736d403e4d43f62cc3a02d1267c7e3f0d96f40f1bc109195ad2b98c723
4
+ data.tar.gz: 7136af7bd97d0fc6613d1923c9b9c15e1788dcffe56811bc052acbe53eccf0f7
5
5
  SHA512:
6
- metadata.gz: 670b650344b8a956b15d90d3d24c0a60ee03a13c36875dddb2db51bc8a93919ff7f10c2270b01062418b3e36f285aa824d7ac87465a2499f1830b257d757fb08
7
- data.tar.gz: dd50aee39f1bdd0def09334ea6383e835c56ca103cee67c0937c1bd0a963356d909196fc284f1ce2247078c4a230690b620b313b0a0bbf8a4613367f477f0fb7
6
+ metadata.gz: 88e6c7b1dd96ce81de2432cc17336bca03c3619e9bb8121983daed0134a5fff63292075a22327eafd824c17962a8ef603feaf66c1dc250657c7740de8d0110cb
7
+ data.tar.gz: 11a2cccda6d069e4b1d7b961fa7c43a7ddbff7562a9754efd26389e26f2f89ee0d232df769e118fd463edb56525d646729eda9c740ec0b774ba577faf3770d89
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.14] - 2025-11-08
4
+
5
+ ### Fixed
6
+
7
+ - See `0.4.28`.
8
+
9
+ ## [0.4.28] - 2025-11-08
10
+
11
+ ### Fixed
12
+
13
+ - Project base method build as arrays parsed unrelated arguments.
14
+ - OptionPartition method arg? does not check after "--" delimiter.
15
+ - OptionPartition did not support duplicate values after "--" delimiter.
16
+ - OptionPartition method opt? did not type check for String.
17
+
3
18
  ## [0.5.13] - 2025-11-05
4
19
 
5
20
  ### Fixed
@@ -1202,6 +1217,7 @@
1202
1217
 
1203
1218
  - Changelog was created.
1204
1219
 
1220
+ [0.5.14]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.14
1205
1221
  [0.5.13]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.13
1206
1222
  [0.5.12]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.12
1207
1223
  [0.5.11]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.11
@@ -1216,6 +1232,7 @@
1216
1232
  [0.5.2]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.2-ruby
1217
1233
  [0.5.1]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.1-ruby
1218
1234
  [0.5.0]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.0-ruby
1235
+ [0.4.28]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.28
1219
1236
  [0.4.27]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.27
1220
1237
  [0.4.26]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.26
1221
1238
  [0.4.25]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.25
@@ -255,8 +255,8 @@ module Squared
255
255
  sub.each { |h| s = sub_style(s, **h) }
256
256
  s = "#{b0} #{s} #{b0}"
257
257
  if border
258
- s = sub_style(s, pat: /\A(#{Regexp.escape(b0)})(.+)\z/m, styles: border)
259
- s = sub_style(s, pat: /\A(.+)(#{Regexp.escape(b0)})\z/m, styles: border, index: 2)
258
+ s = sub_style(s, pat: /\A(#{Regexp.escape(b0)})(.+)\z/om, styles: border)
259
+ s = sub_style(s, pat: /\A(.+)(#{Regexp.escape(b0)})\z/om, styles: border, index: 2)
260
260
  end
261
261
  s
262
262
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.5.13'
4
+ VERSION = '0.5.14'
5
5
  end
@@ -525,31 +525,31 @@ module Squared
525
525
  cmd = cmd.join(' && ')
526
526
  else
527
527
  cmd, opts, var, flags, extra = args
528
- end
529
- if cmd
530
- return run_b(cmd, sync: sync, from: from) if cmd.is_a?(Proc) || cmd.is_a?(Method)
528
+ if cmd
529
+ return run_b(cmd, sync: sync, from: from) if cmd.is_a?(Proc) || cmd.is_a?(Method)
531
530
 
532
- cmd = as_get(cmd, from)
533
- opts = compose(opts, script: false) if opts && respond_to?(:compose)
534
- flags = append_hash(flags, target: []).join(' ') if flags.is_a?(Hash)
535
- case opts
536
- when Hash
537
- cmd = Array(cmd).append(flags)
538
- .concat(append_hash(opts, target: [], build: true))
539
- .compact
540
- .join(' ')
541
- when Enumerable
542
- cmd = Array(cmd).concat(opts.to_a)
543
- cmd.map! { |val| "#{val} #{flags}" } if flags
544
- cmd = cmd.join(' && ')
531
+ cmd = as_get(cmd, from)
532
+ opts = compose(opts, script: false) if opts && respond_to?(:compose)
533
+ flags = append_hash(flags, target: []).join(' ') if flags.is_a?(Hash)
534
+ case opts
535
+ when Hash
536
+ cmd = Array(cmd).append(flags)
537
+ .concat(append_hash(opts, target: [], build: true))
538
+ .compact
539
+ .join(' ')
540
+ when Enumerable
541
+ cmd = Array(cmd).concat(opts.to_a)
542
+ cmd.map! { |val| "#{val} #{flags}" } if flags
543
+ cmd = cmd.join(' && ')
544
+ else
545
+ cmd = [cmd, flags, opts].compact.join(' ') if opts || flags
546
+ end
545
547
  else
546
- cmd = [cmd, flags, opts].compact.join(' ') if opts || flags
547
- end
548
- else
549
- return unless (opts || extra) && respond_to?(:compose)
548
+ return unless (opts || extra) && respond_to?(:compose)
550
549
 
551
- cmd = compose(as_get(opts, from), flags, script: true, args: extra, from: from)
552
- from = :script if from == :run && script?
550
+ cmd = compose(as_get(opts, from), flags, script: true, args: extra, from: from)
551
+ from = :script if from == :run && script?
552
+ end
553
553
  end
554
554
  run(cmd, var, sync: sync, from: from, banner: banner)
555
555
  end
@@ -568,12 +568,12 @@ module Squared
568
568
  if proj.respond_to?(meth.to_sym)
569
569
  begin
570
570
  proj.__send__(meth, sync: sync)
571
- next
572
571
  rescue StandardError => e
573
572
  on_error(e, :prereqs, exception: true)
574
573
  end
574
+ else
575
+ print_error(name, "method: #{meth}", subject: 'prereqs', hint: 'undefined')
575
576
  end
576
- print_error(name, 'method not found', subject: 'prereqs', hint: meth)
577
577
  end
578
578
  elsif proj.build?
579
579
  proj.build(sync: sync)
@@ -1307,7 +1307,7 @@ module Squared
1307
1307
  end
1308
1308
  ret = JoinSet.new(cmd.flatten(1))
1309
1309
  if options && (val = env("#{prefix.upcase}_OPTIONS"))
1310
- split_escape(val).each { |opt| ret.last(fill_option(opt), /\A(--?[^ =]+)[ =].+\z/m) }
1310
+ split_escape(val).each { |opt| ret.last(fill_option(opt), /\A(--?[^\[\]=\s-][^\[\]=\s]*)[=\s].+\z/m) }
1311
1311
  end
1312
1312
  main ? @session = ret : ret
1313
1313
  end
@@ -1593,11 +1593,12 @@ module Squared
1593
1593
  **kwargs)
1594
1594
  return if list.empty?
1595
1595
 
1596
+ kwargs[:ignore] = false if no && !kwargs.key?(:ignore)
1596
1597
  [].tap do |ret|
1597
1598
  list.flatten.each do |flag|
1598
1599
  next unless (val = option(flag, target: target, **kwargs))
1599
1600
 
1600
- if val == '0' && no
1601
+ if no && val == '0'
1601
1602
  flag = "no-#{flag}"
1602
1603
  val = nil
1603
1604
  end
@@ -11,7 +11,7 @@ module Squared
11
11
  extend Forwardable
12
12
 
13
13
  OPT_NAME = /\A(?:(--)|-)((?(1)[^\[\]=\s-][^\[\]=\s]*|[^\[\]=\s-]))\z/
14
- OPT_VALUE = /\A-{0,2}([^\[\]=\s-][^\[\]=\s]*)(?:\s*=\s*|\s+)(.+)\z/
14
+ OPT_VALUE = /\A-{0,2}([^\[\]=\s-][^\[\]=\s]*)(?:=|\s+)(\S.*)\z/
15
15
  OPT_SINGLE = /\A-([^\[\]=\s-])(.+)\z/
16
16
  private_constant :OPT_NAME, :OPT_VALUE, :OPT_SINGLE
17
17
 
@@ -27,7 +27,7 @@ module Squared
27
27
  target << '--' if delim && !target.include?('--')
28
28
  if strip
29
29
  pat, s = Array(strip)
30
- ret.map! { |val| val.gsub(pat, s || '') }
30
+ ret.map! { |val| val.is_a?(String) ? val.gsub(pat, s || '') : val }
31
31
  end
32
32
  if escape || quote
33
33
  ret.map! do |val|
@@ -89,11 +89,16 @@ module Squared
89
89
  def arg?(target, *args, value: false, **)
90
90
  r, s = args.partition { |val| val.is_a?(Regexp) }
91
91
  r << matchopts(s, value) unless s.empty?
92
- s = target.to_a.compact
93
- r.any? { |pat| s.any?(pat) }
92
+ a = target.to_a
93
+ if (n = a.index('--'))
94
+ a = a[0..n]
95
+ end
96
+ r.any? { |pat| a.any?(pat) }
94
97
  end
95
98
 
96
99
  def opt?(val)
100
+ return false unless val.is_a?(String)
101
+
97
102
  val.start_with?('-') && (OPT_NAME.match?(val) || OPT_VALUE.match?(val) || OPT_SINGLE.match?(val))
98
103
  end
99
104
 
@@ -530,11 +535,16 @@ module Squared
530
535
  super[/[^:]+\z/, 0]
531
536
  end
532
537
 
533
- attr_reader :delim
538
+ alias to_ary to_a
534
539
 
535
- def initialize(data = [], delim: ' ')
536
- super(data.compact)
540
+ attr_reader :delim, :extras
541
+
542
+ def initialize(data = [], delim: ' ', partition: '--', uniq: /\A--?[^\[\]=\s-][^\[\]=\s]*(?:=|\s+)\S/)
537
543
  @delim = delim
544
+ @partition = partition
545
+ @uniq = uniq
546
+ @extras = []
547
+ super(data.compact)
538
548
  end
539
549
 
540
550
  def last(val, pat)
@@ -543,7 +553,7 @@ module Squared
543
553
  end
544
554
 
545
555
  def pass(&blk)
546
- ret = to_a.map!(&:to_s).reject(&:empty?)
556
+ ret = to_ary.map!(&:to_s).reject(&:empty?)
547
557
  @last&.each do |val, pat, key|
548
558
  i = []
549
559
  j = nil
@@ -564,6 +574,7 @@ module Squared
564
574
  end
565
575
  ret[i.last] = val
566
576
  end
577
+ ret.concat(extras.map(&:to_s).reject(&:empty?)) unless extras.empty?
567
578
  return ret unless block_given?
568
579
 
569
580
  ret.reject(&blk)
@@ -585,18 +596,73 @@ module Squared
585
596
 
586
597
  def temp(*args, &blk)
587
598
  args.compact!
588
- ret = pass(&blk)
589
- ret = Set.new(ret.concat(args)).to_a unless args.empty?
590
- ret.join(@delim)
599
+ pass(&blk)
600
+ .concat(args)
601
+ .join(@delim)
591
602
  end
592
603
 
593
604
  def done
594
605
  to_s.tap { clear }
595
606
  end
596
607
 
608
+ def merge(enum)
609
+ if !extras.empty?
610
+ extras.concat(enum.to_a)
611
+ self
612
+ elsif (n = enum.find_index { |val| extras?(val) })
613
+ data = enum.to_a
614
+ @extras = if n == 0
615
+ data
616
+ else
617
+ super(data[0...n])
618
+ data[n..-1]
619
+ end
620
+ self
621
+ else
622
+ super
623
+ end
624
+ end
625
+
626
+ def <<(obj)
627
+ extras!(obj) || super
628
+ end
629
+
630
+ def add?(obj)
631
+ extras!(obj) || super
632
+ end
633
+
634
+ def to_a
635
+ pass
636
+ end
637
+
597
638
  def to_s
598
639
  pass.join(@delim)
599
640
  end
641
+
642
+ def to_enum(*args)
643
+ pass.to_enum(*args)
644
+ end
645
+
646
+ def to_json(*args)
647
+ pass.to_json(*args)
648
+ end
649
+
650
+ def to_yaml(*args)
651
+ pass.to_yaml(*args)
652
+ end
653
+
654
+ private
655
+
656
+ def extras!(obj)
657
+ return if extras.empty? && !extras?(obj)
658
+
659
+ extras << obj unless !extras.include?(@partition) && include?(obj) && @uniq.match?(obj.to_s)
660
+ self
661
+ end
662
+
663
+ def extras?(obj)
664
+ obj == @partition || (include?(obj) && !@uniq.match?(obj.to_s))
665
+ end
600
666
  end
601
667
  end
602
668
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squared
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.13
4
+ version: 0.5.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  requirements: []
127
- rubygems_version: 3.7.2
127
+ rubygems_version: 3.6.9
128
128
  specification_version: 4
129
129
  summary: Rake task generator for managing multi-language workspaces.
130
130
  test_files: []