squared 0.5.18 → 0.5.19

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: 7c64d1ba5b8781c76d0dbbccf6cbedf66e217043fbfd2bc33220a8c2d60baa82
4
- data.tar.gz: 0566e40b09f80693e1abbbf7e97de7bb92e952d5d2890be37340da34e0f24be3
3
+ metadata.gz: 90e816457aa629a2416781e2480aa4025f0b5395eb41dc45157ecbb0d9a57262
4
+ data.tar.gz: a03eca5dba74e2b6c3c6d6946291f788e5f3a75c84afa89a8e5139c325d3397a
5
5
  SHA512:
6
- metadata.gz: 4ff0e0a44837f6fec6016680564f784968e0627367e727dfd30d1533f951f437b57ca746cc5876aa97ae05c11bc89ca79b149783e9082e15adc7d437e95c87e1
7
- data.tar.gz: ac233a17a56d35be1008b1e598d875fe173e85d412eafd13477536a469da1de9e06f16c245c02c5e568b8250a4a8bbf2693b9859fc3e3231ac43ff0a661371e6
6
+ metadata.gz: 3ec9a3d2105f6355485a71820b4631554dfe9a47a6b4fbfb36d690b09693cd54abad75877aa7b17fe235dadcf2f03c0508b5ea33dd0e3a67c69faa73ad6c19b4
7
+ data.tar.gz: 8ed22f2ba7bb7195082d616ab085ead6e1795fa23a06f9bc48035206e1dedec4f146b2934711c2d88ac52e77b8c000838a517bdc8ddb616a3b0d5c1a9c608bd8
data/CHANGELOG.md CHANGED
@@ -1,10 +1,30 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.19] - 2025-12-07
4
+
5
+ ### Fixed
6
+
7
+ - See `0.4.33`.
8
+
9
+ ## [0.4.33] - 2025-12-07
10
+
11
+ ### Added
12
+
13
+ - Ruby attribute setter gemdir for copy method was created.
14
+ - Project inline run executables binary path are replaced with global alias.
15
+
16
+ ### Fixed
17
+
18
+ - Workspace class Series created non-existent keys when queried.
19
+ - Application class did not support changing base Project class.
20
+ - Git command rev action build did not check build? method.
21
+ - Python command build action python did not use outdir option.
22
+
3
23
  ## [0.5.18] - 2025-11-25
4
24
 
5
25
  ### Fixed
6
26
 
7
- - See `0.5.18`.
27
+ - See `0.4.32`.
8
28
 
9
29
  ## [0.4.32] - 2025-11-25
10
30
 
@@ -1286,6 +1306,8 @@
1286
1306
 
1287
1307
  - Changelog was created.
1288
1308
 
1309
+ [0.5.19]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.19
1310
+ [0.5.18]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.18
1289
1311
  [0.5.17]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.17
1290
1312
  [0.5.16]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.16
1291
1313
  [0.5.15]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.15
@@ -1304,6 +1326,8 @@
1304
1326
  [0.5.2]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.2-ruby
1305
1327
  [0.5.1]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.1-ruby
1306
1328
  [0.5.0]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.0-ruby
1329
+ [0.4.33]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.33
1330
+ [0.4.32]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.32
1307
1331
  [0.4.31]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.31
1308
1332
  [0.4.30]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.30
1309
1333
  [0.4.29]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.29
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.5.18'
4
+ VERSION = '0.5.19'
5
5
  end
@@ -335,9 +335,9 @@ module Squared
335
335
  end
336
336
  proj = ((if !ref.is_a?(Class)
337
337
  Application.find(ref, path: path)
338
- elsif ref < Project::Base
338
+ elsif ref < Application.impl_project
339
339
  ref
340
- end) || @kind[name]&.last || Project::Base).new(self, path, name, **kwargs)
340
+ end) || @kind[name]&.last || Application.impl_project).new(self, path, name, **kwargs)
341
341
  proj.__send__(:index_set, @project.size)
342
342
  @project[name] = proj
343
343
  __get__(:project)[name] = proj unless kwargs[:private]
@@ -403,7 +403,7 @@ module Squared
403
403
  .map(&:basename)
404
404
  .sort { |a, b| b <=> a }
405
405
  .push('latest', 'system'),
406
- force: true, accept: [['Confirm?', false, true]],
406
+ accept: [['Confirm?', false, true]],
407
407
  values: ['Options'])
408
408
  OptionPartition.strip(opts)
409
409
  end
@@ -514,7 +514,7 @@ module Squared
514
514
  end
515
515
  d = append_hash(d, target: []).join(' ') if d.is_a?(Hash)
516
516
  if a
517
- cmd << [a, d, b].compact.join(' ')
517
+ cmd << [replace_bin(a), d, b].compact.join(' ')
518
518
  else
519
519
  next unless respond_to?(:compose)
520
520
 
@@ -528,7 +528,7 @@ module Squared
528
528
  if cmd
529
529
  return run_b(cmd, sync: sync, from: from) if cmd.is_a?(Proc) || cmd.is_a?(Method)
530
530
 
531
- cmd = as_get(cmd, from)
531
+ cmd = replace_bin as_get(cmd, from)
532
532
  opts = compose(opts, script: false) if opts && respond_to?(:compose)
533
533
  flags = append_hash(flags, target: []).join(' ') if flags.is_a?(Hash)
534
534
  case opts
@@ -1662,6 +1662,13 @@ module Squared
1662
1662
  ret
1663
1663
  end
1664
1664
 
1665
+ def replace_bin(val)
1666
+ a, b = val.split(' ', 2)
1667
+ return val if val.start_with?(/["']/) || a.include?(File::Separator)
1668
+
1669
+ [shell_bin(a), b].compact.join(' ')
1670
+ end
1671
+
1665
1672
  def parse_json(val, kind: Hash, hint: nil)
1666
1673
  ret = JSON.parse(val)
1667
1674
  raise_error("invalid JSON #{kind.name}", val, hint: hint) if kind && !ret.is_a?(kind)
@@ -13,7 +13,7 @@ module Squared
13
13
  buildx: {
14
14
  common: %w[builder=b D|debug],
15
15
  build: %w[add-host=q annotation=q attest=q build-arg=qq build-context=qq cache-from=q cache-to=q
16
- cgroup-parent=b iidfile=p label=q a-file=p network=b no-cache-filter=b o|output=q platform=b
16
+ cgroup-parent=b iidfile=p label=q network=b no-cache-filter=b o|output=q platform=q
17
17
  q|quiet secret=qq shm-size=b ssh=qq t|tag=b target=b ulimit=q].freeze,
18
18
  bake: %w[print list=q set=q].freeze,
19
19
  shared: %w[check load no-cache pull push allow=q call=b? f|file=p metadata-file=p progress=b provenance=q
@@ -41,14 +41,14 @@ module Squared
41
41
  device-read-bps=q device-read-iops=q device-write-bps=q device-write-iops=q
42
42
  disable-content-trust=b? dns=q dns-option=q dns-search=q domainname=b entrypoint=q e|env=qq
43
43
  env-file=p expose=q gpus=q group-add=b health-cmd=q health-interval=b health-retries=i
44
- health-start-interval=q health-start-period=q health-timeout=q io-maxbandwidth=b io-maxiops=b
45
- ip=b ip6=q ipc=b isolation=b kernel-memory=b l|label=q label-file=q link=b link-local-ip=q
46
- log-driver=b log-opt=q mac-address=q m|memory=b memory-reservation=b memory-swap=n
47
- memory-swappiness=n mount=qq name=b network=b network-alias=b oom-score-adj=b pid=b pids-limit=n
48
- platform=b p|publish=q pull=b restart=b runtime=b security-opt=q shm-size=b stop-signal=b
49
- stop-timeout=i storage-opt=q sysctl=q tmpfs=q ulimit=q u|user=b userns=b uts=b v|volume=q
50
- volume-driver=b volumes-from=b w|workdir=q].freeze,
51
- run: %w[d|detach detach-keys=q hostname=q sig-proxy=b?].freeze,
44
+ health-start-interval=q health-start-period=q health-timeout=q hostname=q io-maxbandwidth=b
45
+ io-maxiops=b ip=b ip6=q ipc=b isolation=b kernel-memory=b l|label=q label-file=q link=b
46
+ link-local-ip=q log-driver=b log-opt=q mac-address=q m|memory=b memory-reservation=b
47
+ memory-swap=n memory-swappiness=n mount=qq name=b network=b network-alias=b oom-score-adj=b
48
+ pid=b pids-limit=n platform=q p|publish=q pull=b restart=b runtime=b security-opt=q shm-size=b
49
+ stop-signal=b stop-timeout=i storage-opt=q sysctl=q tmpfs=q ulimit=q u|user=b userns=b uts=b
50
+ v|volume=q volume-driver=b volumes-from=b w|workdir=q].freeze,
51
+ run: %w[d|detach detach-keys=q sig-proxy=b?].freeze,
52
52
  update: %w[blkio-weight=i cpu-period=i cpu-quota=i cpu-rt-period=i cpu-rt-runtime=i c|cpu-shares=i cpus=f
53
53
  cpuset-cpus=b cpuset-mems=b m|memory=b memory-reservation=b memory-swap=b pids-limit=n
54
54
  restart=q].freeze,
@@ -64,9 +64,9 @@ module Squared
64
64
  }.freeze,
65
65
  image: {
66
66
  list: %w[a|all q|quiet digests no-trunc tree f|filter=q format=q].freeze,
67
- push: %w[a|all-tags disable-content-trust=b? platform=b q|quiet].freeze,
68
- rm: %w[f|force no-prune platform=b].freeze,
69
- save: %w[o|output=p platform=b].freeze
67
+ push: %w[a|all-tags disable-content-trust=b? platform=q q|quiet].freeze,
68
+ rm: %w[f|force no-prune platform=q].freeze,
69
+ save: %w[o|output=p platform=q].freeze
70
70
  }.freeze,
71
71
  network: {
72
72
  connect: %w[alias=b driver-opt=q gw-priority=n ip=b ip6=q link=b link-local-ip=q].freeze,
@@ -864,6 +864,8 @@ module Squared
864
864
  rev_parse(flag, ref: ref, size: size)
865
865
  end
866
866
  when :build
867
+ next unless build?
868
+
867
869
  format_desc action, flag, 'opts*'
868
870
  task flag do |_, args|
869
871
  revbuild flag, args.to_a
@@ -1122,7 +1124,7 @@ module Squared
1122
1124
  end
1123
1125
  end
1124
1126
  out = choice_index('Choose a stash', git_spawn('stash list', stdout: false),
1125
- values: values, column: /^[^@]+@\{(\d+)\}/, force: true)
1127
+ values: values, column: /^[^@]+@\{(\d+)\}/)
1126
1128
  if values
1127
1129
  op.merge(out.reverse)
1128
1130
  else
@@ -1771,7 +1773,7 @@ module Squared
1771
1773
  files << "#{sub_style(b, styles: color(:red))} #{a}"
1772
1774
  end
1773
1775
  unless files.empty?
1774
- files = choice_index('Select files', files, multiple: true, force: true, trim: /^\S+\s/,
1776
+ files = choice_index('Select files', files, multiple: true, trim: /^\S+\s/,
1775
1777
  accept: [['Add?', false, true]])
1776
1778
  end
1777
1779
  op.swap(list + files)
@@ -78,7 +78,7 @@ module Squared
78
78
 
79
79
  attr_reader :venv, :editable
80
80
 
81
- def initialize(*, editable: '.', verbose: nil, asdf: 'python', **kwargs)
81
+ def initialize(*, editable: '.', asdf: 'python', **kwargs)
82
82
  super
83
83
  if @pass.include?(Python.ref)
84
84
  initialize_ref Python.ref
@@ -310,10 +310,10 @@ module Squared
310
310
  next unless build_backend == 'hatchling.build'
311
311
  end
312
312
  format_desc(action, flag, 'opts*', after: case flag
313
- when :python then 'srcdir?'
314
313
  when :poetry then 'output?'
315
314
  when :pdm then 'dest?'
316
315
  when :hatch then 'location?'
316
+ else 'outdir?'
317
317
  end)
318
318
  task flag do |_, args|
319
319
  build! flag, args.to_a
@@ -487,9 +487,6 @@ module Squared
487
487
 
488
488
  def build!(flag, opts = [])
489
489
  case flag
490
- when :python
491
- cmd, opts = python_session('-m build', opts: opts)
492
- list = OPT_PYTHON[:build]
493
490
  when :poetry
494
491
  cmd = poetry_session 'build'
495
492
  list = OPT_POETRY[:build] + OPT_POETRY[:common]
@@ -499,37 +496,32 @@ module Squared
499
496
  when :hatch
500
497
  cmd, opts = hatch_session('build', opts: opts)
501
498
  list = OPT_HATCH[:build]
499
+ else
500
+ cmd, opts = python_session('-m build', opts: opts)
501
+ list = OPT_PYTHON[:build]
502
502
  end
503
- srcdir = nil
504
503
  op = OptionPartition.new(opts, list, cmd, project: self, single: singleopt(flag))
505
- op.each do |opt|
506
- if !srcdir && basepath(opt.chomp('*')).exist? && projectpath?(opt.chomp('*'))
507
- srcdir = opt
508
- else
509
- op.found << opt
510
- end
511
- end
512
- op.swap
513
504
  case flag
514
- when :poetry, :pdm
515
- if srcdir
516
- args = flag == :pdm ? ['d', 'dest'] : ['o', 'output']
517
- if op.arg?(*args)
518
- op.push(srcdir)
519
- else
520
- op << quote_option(args.last, basepath(srcdir))
521
- end
522
- srcdir = nil
523
- end
524
505
  when :hatch
525
- if ENV['HATCH_BUILD_LOCATION']
526
- srcdir = nil
527
- else
528
- srcdir ||= path
506
+ if !ENV['HATCH_BUILD_LOCATION'] && (outdir ||= op.shift)
507
+ op.add_path(outdir)
529
508
  end
530
509
  op << basic_option('p', project) unless ENV['HATCH_PROJECT'] || op.arg?('p', 'project')
510
+ else
511
+ unless op.empty?
512
+ args = case flag
513
+ when :poetry
514
+ %w[o output]
515
+ when :pdm
516
+ %w[d dest]
517
+ else
518
+ srcdir = true
519
+ %w[o outdir]
520
+ end
521
+ op << quote_option(args.last, basepath(op.shift)) unless op.arg?(*args)
522
+ end
531
523
  end
532
- op.add_path(srcdir) if srcdir
524
+ op.exist?(add: true, first: true) if srcdir
533
525
  op.clear
534
526
  run(from: :"#{flag}:build")
535
527
  end
@@ -24,10 +24,10 @@ module Squared
24
24
  common: %w[no-color V|verbose r|retry=i].freeze,
25
25
  install: %w[frozen no-cache no-prune system binstubs=p? path=p standalone=q? target-rbconfig=p trust-policy=b
26
26
  with=q without=q].freeze,
27
- install_base: %w[force full-index quiet redownload gemfile=p j|jobs=i].freeze,
27
+ install_base: %w[force full-index local quiet redownload gemfile=p j|jobs=i].freeze,
28
28
  update: %w[all conservative local major minor patch pre ruby strict bundler=b? g|group=q source=b].freeze,
29
- outdated: %w[filter-major filter-minor filter-patch groups local parseable pre only-explicit strict
30
- update-strict group=q source=b].freeze,
29
+ outdated: %w[filter-major filter-minor filter-patch filter-strict groups local parseable porcelain pre
30
+ only-explicit strict update-strict group=q source=b].freeze,
31
31
  exec: %w[gemfile=p].freeze,
32
32
  cache: %w[all all-platforms frozen no-all no-install no-prune quiet cache-path=p gemfile=p path=p].freeze,
33
33
  check: %w[dry-run gemfile=p path=p].freeze
@@ -38,7 +38,7 @@ module Squared
38
38
  install_base: %w[E f w b|both clear-sources conservative default development development-all explain
39
39
  ignore-dependencies l|local N|no-document r|remote vendor n|bindir=p build-root=p
40
40
  B|bulk-threshold=i document=b? g|file=p? p|http-proxy=q? i|install-dir=p platform=q
41
- s|source=q target-rbconfig=p? P|trust-policy=b without=b].freeze,
41
+ s|source=q target-rbconfig=p? P|trust-policy=b without=q].freeze,
42
42
  update: %w[system=b?].freeze,
43
43
  uninstall: %w[a D I x vendor n|bindir=p i|install-dir=p platform=b v|version=q].freeze,
44
44
  outdated: %w[b|both clear-sources l|local r|remote B|bulk-threshold=i p|http-proxy=q? platform=q
@@ -69,7 +69,7 @@ module Squared
69
69
  end
70
70
 
71
71
  def bannerargs
72
- %i[dependfile gemname].freeze
72
+ %i[dependfile gemname gemdir].freeze
73
73
  end
74
74
 
75
75
  def config?(val)
@@ -93,6 +93,8 @@ module Squared
93
93
  'irb' => nil
94
94
  })
95
95
 
96
+ attr_reader :gemdir
97
+
96
98
  def initialize(*, autodetect: false, gemspec: nil, asdf: 'ruby', **kwargs)
97
99
  super
98
100
  if @pass.include?(Ruby.ref)
@@ -126,6 +128,14 @@ module Squared
126
128
  end
127
129
  end
128
130
 
131
+ def gemdir=(val)
132
+ @gemdir = if val.is_a?(Pathname)
133
+ val
134
+ else
135
+ Pathname.new(val).realdirpath rescue nil
136
+ end
137
+ end
138
+
129
139
  def ref
130
140
  Ruby.ref
131
141
  end
@@ -241,7 +251,7 @@ module Squared
241
251
  else
242
252
  a, b, c = choice_index('Select a file', Dir.glob(file || '*.rb', base: path),
243
253
  values: (file ? [] : ['Options']).push('Arguments'),
244
- force: true, series: true)
254
+ series: true)
245
255
  if file
246
256
  file = a
247
257
  b
@@ -293,7 +303,7 @@ module Squared
293
303
  end
294
304
  end
295
305
 
296
- def copy(from: gemlib, into: @gemdir, override: false, **kwargs)
306
+ def copy(from: gemlib, into: gemdir, override: false, **kwargs)
297
307
  return if @copy == false
298
308
 
299
309
  glob = kwargs[:include]
@@ -754,7 +764,7 @@ module Squared
754
764
  file = basepath(if !n && (spec = gemspec)
755
765
  "#{spec.name}-#{spec.version}.gem"
756
766
  else
757
- choice_index('Select a file', Dir.glob('*.gem', base: path), force: true)
767
+ choice_index 'Select a file', Dir.glob('*.gem', base: path)
758
768
  end)
759
769
  else
760
770
  file = op.shift.yield_self { |val| val.include?('.') ? val : "#{val}.gem" }
@@ -882,27 +892,25 @@ module Squared
882
892
 
883
893
  def copy?
884
894
  return true if @copy.is_a?(Hash) ? copy[:into] : super
885
- return gemdir? if @gemdir
895
+ return gemdir? if gemdir
886
896
 
887
897
  if version
888
898
  begin
889
899
  case @autodetect
890
900
  when 'rvm'
891
- @gemdir = pwd_set { `rvm info homes` }[/^\s+gem:\s+"(.+)"$/, 1]
901
+ self.gemdir = pwd_set { `rvm info homes` }[/^\s+gem:\s+"(.+)"$/, 1]
892
902
  when 'rbenv'
893
903
  if pwd_set { `rbenv which ruby` } =~ %r{^(.+[\\/]versions[\\/](\d\.\d)\.[^\\/]+)[\\/]bin[\\/]ruby$}
894
- @gemdir = File.join($1, 'lib/ruby/gems', "#{$2}.0")
904
+ self.gemdir = File.join($1, 'lib/ruby/gems', "#{$2}.0")
895
905
  end
896
906
  when 'asdf'
897
- @gemdir = pwd_set { `asdf where ruby` }
898
- @gemdir = @gemdir =~ /(\d\.\d)\.[^.]+$/ && File.join(@gemdir, 'lib/ruby/gems', "#{$1}.0")
907
+ val = pwd_set { `asdf where ruby` }
908
+ self.gemdir = File.join(val, 'lib/ruby/gems', "#{$1}.0") if val =~ /(\d\.\d)\.[^.]+$/
899
909
  when /bundler?/
900
- @gemdir = pwd_set { `bundle env` }[/^\s+Gem Home\s+(.+)$/, 1]
910
+ self.gemdir = pwd_set { `bundle env` }[/^\s+Gem Home\s+(.+)$/, 1]
901
911
  end
902
912
  rescue StandardError => e
903
913
  log.debug e
904
- else
905
- @gemdir = Pathname.new(@gemdir) if @gemdir
906
914
  end
907
915
  return true if gemdir?
908
916
  end
@@ -913,7 +921,7 @@ module Squared
913
921
  log.warn "using version #{val} (given #{ver})"
914
922
  end
915
923
  self.version = val
916
- @gemdir = Pathname.new(path.strip) + gempath
924
+ self.gemdir = Pathname.new(path.strip) + gempath
917
925
  end
918
926
  if version
919
927
  opt = gempwd
@@ -927,17 +935,17 @@ module Squared
927
935
  next unless out =~ /\(#{Regexp.escape(val)}(?:,[^)]+|\b)\):([^\n]+)/
928
936
 
929
937
  set.call(val, $1)
930
- return gemdir? if @gemdir
938
+ return gemdir? if gemdir
931
939
  end
932
940
  end
933
941
  end
934
- @gemdir = Pathname.new(Gem.dir) + gempath
942
+ self.gemdir = Pathname.new(Gem.dir) + gempath
935
943
  else
936
944
  parse = lambda do |path|
937
945
  next unless path
938
946
 
939
947
  lib = Regexp.new(['', 'gems', "#{gemname}-([^#{File::SEPARATOR}]+)", ''].join(File::SEPARATOR))
940
- if (ver = path[lib, 1]) && (val = path[/\A(.+)#{gempath(ver[1])}/, 1])
948
+ if (ver = path[lib, 1]) && (val = path[/\A(.+)#{Regexp.escape(gempath(ver))}/, 1])
941
949
  set.call(ver, val)
942
950
  end
943
951
  end
@@ -945,7 +953,7 @@ module Squared
945
953
  target = RUBY_VERSION.start_with?('2.6') ? RubyVM : $LOAD_PATH
946
954
  parse.call(target.resolve_feature_path(gemname)&.last)
947
955
  end
948
- if !@gemdir && !pwd_set { parse.call(`#{bundle_output('show', gemname)}`) }
956
+ if !gemdir && !pwd_set { parse.call(`#{bundle_output('show', gemname)}`) }
949
957
  raise_error 'gems directory not found'
950
958
  end
951
959
  end
@@ -1106,9 +1114,9 @@ module Squared
1106
1114
  end
1107
1115
 
1108
1116
  def gemdir?
1109
- return false unless @gemdir
1117
+ return false unless gemdir
1110
1118
 
1111
- @gemdir.exist? && !@gemdir.empty?
1119
+ gemdir.exist? && !gemdir.empty?
1112
1120
  end
1113
1121
  end
1114
1122
 
@@ -114,7 +114,7 @@ module Squared
114
114
 
115
115
  def matchopts(list, value = false)
116
116
  a, b = Array(list).partition { |val| val.size == 1 || val.match?(OPT_SINGLE) }
117
- return /\A#{shortopt(*a)}}/ if b.empty?
117
+ return /\A#{shortopt(*a)}/ if b.empty?
118
118
  return /\A#{longopt(*b, value)}/ if a.empty?
119
119
 
120
120
  /\A(?:#{shortopt(*a)}|#{longopt(*b, value)})/
@@ -309,6 +309,7 @@ module Squared
309
309
  else
310
310
  add val
311
311
  end
312
+ found << val if args.empty?
312
313
  end
313
314
  self
314
315
  end
@@ -437,26 +438,26 @@ module Squared
437
438
  end
438
439
 
439
440
  def splice(*exclude, quote: true, delim: true, path: false, pattern: false, &blk)
440
- found, other = if block_given?
441
- partition(&blk)
442
- elsif exclude.first.is_a?(Symbol)
443
- partition(&exclude.first)
444
- else
445
- partition do |val|
446
- next false if pattern && OptionPartition.pattern?(val)
447
-
448
- exclude.none? { |pat| val.match?(Regexp.new(pat)) }
449
- end
450
- end
451
- unless found.empty?
441
+ temp, other = if block_given?
442
+ partition(&blk)
443
+ elsif exclude.first.is_a?(Symbol)
444
+ partition(&exclude.first)
445
+ else
446
+ partition do |val|
447
+ next false if pattern && OptionPartition.pattern?(val)
448
+
449
+ exclude.none? { |pat| val.match?(Regexp.new(pat)) }
450
+ end
451
+ end
452
+ unless temp.empty?
452
453
  add '--' if delim
453
454
  extras.clear
454
455
  concat other
455
456
  if path
456
- found.each { |val| add_path(val) }
457
+ temp.each { |val| add_path(val) }
457
458
  else
458
- found.map! { |val| shell_quote(val) } if quote
459
- merge found
459
+ temp.map! { |val| shell_quote(val) } if quote
460
+ merge temp
460
461
  end
461
462
  end
462
463
  self
@@ -38,8 +38,8 @@ module Squared
38
38
  def alias(ref, obj)
39
39
  if obj.is_a?(Hash)
40
40
  obj.each { |key, val| TASK_ALIAS[key][ref] = val }
41
- else
42
- TASK_ALIAS[obj]&.delete(ref)
41
+ elsif TASK_ALIAS.key?(obj)
42
+ TASK_ALIAS[obj].delete(ref)
43
43
  end
44
44
  end
45
45
 
@@ -165,6 +165,8 @@ module Squared
165
165
  end
166
166
 
167
167
  def alias_get(key)
168
+ return unless TASK_ALIAS.key?(key)
169
+
168
170
  TASK_ALIAS[key]
169
171
  end
170
172
 
@@ -182,11 +184,13 @@ module Squared
182
184
  end
183
185
 
184
186
  def extend?(obj, key)
185
- return false unless (items = TASK_EXTEND[key]) && !(items = items.select { |kind| obj.is_a?(kind) }).empty?
187
+ return false unless TASK_EXTEND.key?(key)
186
188
 
187
189
  meth = :"#{key}?"
188
190
  ret = false
189
- items.each do |kind|
191
+ TASK_EXTEND[key].each do |kind|
192
+ next unless obj.is_a?(kind)
193
+
190
194
  if kind.instance_methods.include?(meth)
191
195
  out = obj.__send__(meth)
192
196
  return true if out == 1
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.18
4
+ version: 0.5.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham