squared 0.4.31 → 0.4.33

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: e24f3f18639483d5b698d06a1fd471251623658359121940dd4d6597d3e5f453
4
- data.tar.gz: 90eb6cd2b8b5e28497d666d655758422d124b4eb47701164ce3712a11ecc2936
3
+ metadata.gz: cc4c3610fd67d9cf3afa29add2ea865f0fbe13e075c384cb746f5074c473f7ef
4
+ data.tar.gz: 6328ffe0d303b321d8663a53c6d0c59b3b758bfb881d693c2d7ac5b322961db4
5
5
  SHA512:
6
- metadata.gz: 4a7a4c5283e6bd65ed22fe9053d3f14552f2de61200e48c8c0c8e8013d0915db2c72a76ad2f7de784d0127ac47a8dd87c48ceea7a6c8c93468119487820886d7
7
- data.tar.gz: 8aee7c98eb186fec5968373ab0f3acffefcbe45d6c85adce46c581536ca51d77c71af89f1c0b95cf4be10e850a24df6b783c35eb9fc32da0fa3918d360f8d779
6
+ metadata.gz: 5e7c0fdee86fd208433ed3736383a1cd0bac10792fdbdb1e8e3c4829b9d77e78e02d603a79efe81b1b4c5944159bfd464aad9ccc834aeeea1431508554c0fc14
7
+ data.tar.gz: cfb6cc7335731677c8643ef3667dcb03707c6d3f9c7c1285f1ecf89c7f75ec827083c687a57449bd94d75d5881bf542031d430325035f594ba3300caa21faf64
data/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.33] - 2025-12-07
4
+
5
+ ### Added
6
+
7
+ - Ruby attribute setter gemdir for copy method was created.
8
+ - Project inline run executables binary path are replaced with global alias.
9
+
10
+ ### Fixed
11
+
12
+ - Workspace class Series created non-existent keys when queried.
13
+ - Application class did not support changing base Project class.
14
+ - Git command rev action build did not check build? method.
15
+ - Python command build action python did not use outdir option.
16
+
17
+ ## [0.4.32] - 2025-11-25
18
+
19
+ ### Fixed
20
+
21
+ - Git method commit did not include --dry-run with add command.
22
+ - JoinSet method include? did not always search to start of delimiter.
23
+ - Config viewer did not check for a readable package registry document.
24
+ - Powershell executable did not check for alternate path location.
25
+
3
26
  ## [0.4.31] - 2025-11-22
4
27
 
5
28
  ### Changed
@@ -1121,6 +1144,8 @@
1121
1144
 
1122
1145
  - Changelog was created.
1123
1146
 
1147
+ [0.4.33]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.33
1148
+ [0.4.32]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.32
1124
1149
  [0.4.31]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.31
1125
1150
  [0.4.30]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.30
1126
1151
  [0.4.29]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.29
@@ -138,6 +138,13 @@ module Squared
138
138
  super + extras.size
139
139
  end
140
140
 
141
+ def include?(obj)
142
+ return true if super
143
+ return extras.include?(obj) unless (n = extras.index(@partition))
144
+
145
+ extras[0..n].include?(obj)
146
+ end
147
+
141
148
  def to_a
142
149
  pass
143
150
  end
@@ -160,6 +167,7 @@ module Squared
160
167
 
161
168
  alias add :<<
162
169
  alias add? :<<
170
+ alias member? include?
163
171
 
164
172
  private
165
173
 
@@ -110,7 +110,8 @@ module Squared
110
110
  end
111
111
 
112
112
  def shell_bin(name, env: true)
113
- key = name.upcase
113
+ key = name.to_s.upcase
114
+ key = File.basename(key, '.*') if Rake::Win32.windows?
114
115
  shell_quote((env && ENV["PATH_#{key}"]) || PATH[key] || PATH[key.to_sym] || name,
115
116
  option: false, force: false, double: true)
116
117
  end
@@ -22,8 +22,8 @@ module Squared
22
22
  nil
23
23
  end
24
24
 
25
- def link(project, main = project.dependfile.basename, name = nil, **kwargs, &blk)
26
- return unless project.enabled?
25
+ def link(project, main = project.dependfile&.basename, name = nil, **kwargs, &blk)
26
+ return unless project.enabled? && main
27
27
 
28
28
  ret = Viewer.new(main, name, project: project, **kwargs)
29
29
  ret.instance_eval(&blk) if block_given?
@@ -159,7 +159,7 @@ module Squared
159
159
  end
160
160
 
161
161
  def also(path, type = nil, name: nil, **kwargs)
162
- return self if @mime.frozen? || !(file = basepath(path)).exist?
162
+ return self unless (file = basepath(path)).exist? && !@mime.frozen?
163
163
 
164
164
  ext = mimetype file
165
165
  type ||= ext
@@ -321,7 +321,9 @@ module Squared
321
321
  end
322
322
 
323
323
  def warning?
324
- project ? project.workspace.warning : true
324
+ return true unless project
325
+
326
+ project.workspace.warning
325
327
  end
326
328
 
327
329
  def stdin?
@@ -346,7 +348,9 @@ module Squared
346
348
  end
347
349
 
348
350
  def basepath(*args)
349
- project ? project.basepath(*args) : Pathname.pwd.join(*args)
351
+ return Pathname.pwd.join(*args) unless project
352
+
353
+ project.basepath(*args)
350
354
  end
351
355
  end
352
356
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.4.31'
4
+ VERSION = '0.4.33'
5
5
  end
@@ -83,7 +83,7 @@ module Squared
83
83
  basename = @home.basename.to_s
84
84
  if main
85
85
  @main = main.to_s.freeze
86
- @home += @main unless @main == basename || (windows? && @main.downcase == basename.downcase)
86
+ @home += @main unless @main == basename || (windows? && @main.casecmp?(basename))
87
87
  else
88
88
  @main = basename.freeze
89
89
  end
@@ -178,7 +178,9 @@ module Squared
178
178
  self
179
179
  end
180
180
 
181
- def with(*val, group: nil, **kwargs, &blk)
181
+ def with(*val, pass: false, group: nil, **kwargs, &blk)
182
+ return self if pass == true || (pass && Array(pass).map(&:to_s).any? { |s| respond_to?(s) && __send__(s) })
183
+
182
184
  @group = nil
183
185
  @ref = nil
184
186
  @withargs = kwargs.empty? ? nil : kwargs
@@ -334,9 +336,9 @@ module Squared
334
336
  end
335
337
  proj = ((if !ref.is_a?(Class)
336
338
  Application.find(ref, path: path)
337
- elsif ref < Project::Base
339
+ elsif ref < Application.impl_project
338
340
  ref
339
- end) || @kind[name]&.last || Project::Base).new(self, path, name, **kwargs)
341
+ end) || @kind[name]&.last || Application.impl_project).new(self, path, name, **kwargs)
340
342
  proj.__send__(:index_set, @project.size)
341
343
  @project[name] = proj
342
344
  __get__(:project)[name] = proj unless kwargs[:private]
@@ -332,7 +332,7 @@ module Squared
332
332
 
333
333
  format_desc action, flag, '(-)project*'
334
334
  task flag do |_, args|
335
- args = args.to_a.reject { |val| name == val.to_s }
335
+ args = args.to_a.reject { |val| name == val }
336
336
  if flag == :run
337
337
  graph args
338
338
  else
@@ -447,9 +447,9 @@ module Squared
447
447
  if args.empty?
448
448
  return unless from == :run
449
449
 
450
- run_b(@run, sync: sync, from: from) if series?(@run)
451
- args = @output
452
450
  banner = verbosetype > 1 if from_base?('build')
451
+ run_b(@run, sync: sync, from: from, banner: banner) if series?(@run)
452
+ args = @output
453
453
  end
454
454
  if args.first.is_a?(Struct)
455
455
  f, blk = args.first.to_a
@@ -471,7 +471,7 @@ module Squared
471
471
  end
472
472
  d = append_hash(d, target: []).join(' ') if d.is_a?(Hash)
473
473
  if a
474
- cmd << [a, d, b].compact.join(' ')
474
+ cmd << [replace_bin(a), d, b].compact.join(' ')
475
475
  else
476
476
  next unless respond_to?(:compose)
477
477
 
@@ -485,7 +485,7 @@ module Squared
485
485
  if cmd
486
486
  return run_b(cmd, sync: sync, from: from) if cmd.is_a?(Proc) || cmd.is_a?(Method)
487
487
 
488
- cmd = as_get(cmd, from)
488
+ cmd = replace_bin as_get(cmd, from)
489
489
  opts = compose(opts, script: false) if opts && respond_to?(:compose)
490
490
  flags = append_hash(flags, target: []).join(' ') if flags.is_a?(Hash)
491
491
  case opts
@@ -812,7 +812,7 @@ module Squared
812
812
  def run(cmd = @session, var = nil, exception: self.exception, sync: true, from: nil, banner: true, chdir: path,
813
813
  interactive: nil, hint: nil, **)
814
814
  unless cmd
815
- print_error('no command given', subject: project, hint: from || 'unknown', pass: true)
815
+ print_error('no command session started', subject: project, hint: from || 'unknown', pass: true)
816
816
  return
817
817
  end
818
818
  cmd = cmd.target if cmd.is_a?(OptionPartition)
@@ -1061,8 +1061,8 @@ module Squared
1061
1061
  def run_b(obj, **kwargs)
1062
1062
  case obj
1063
1063
  when Struct
1064
- if (any = instance_eval(&obj.block) || obj.run)
1065
- run_b(any, **kwargs)
1064
+ if (val = instance_eval(&obj.block) || obj.run)
1065
+ run_b(val, **kwargs)
1066
1066
  end
1067
1067
  when Proc
1068
1068
  instance_eval(&obj)
@@ -1595,6 +1595,13 @@ module Squared
1595
1595
  ret
1596
1596
  end
1597
1597
 
1598
+ def replace_bin(val)
1599
+ a, b = val.split(' ', 2)
1600
+ return val if val.start_with?(/["']/) || a.include?(File::Separator)
1601
+
1602
+ [shell_bin(a), b].compact.join(' ')
1603
+ end
1604
+
1598
1605
  def parse_json(val, kind: Hash, hint: nil)
1599
1606
  ret = JSON.parse(val)
1600
1607
  raise_error("invalid JSON #{kind.name}", val, hint: hint) if kind && !ret.is_a?(kind)
@@ -1678,7 +1685,7 @@ module Squared
1678
1685
  end
1679
1686
  if values
1680
1687
  ret = Array(ret)
1681
- values.each do |val|
1688
+ Array(values).each do |val|
1682
1689
  if val.is_a?(Array)
1683
1690
  val, force = val
1684
1691
  else
@@ -1713,7 +1720,7 @@ module Squared
1713
1720
  def command(*args)
1714
1721
  return args.join(' && ') unless workspace.powershell?
1715
1722
 
1716
- "powershell.exe -Command #{shell_quote("& {#{args.join(' ; ')}}", option: false, double: true)}"
1723
+ "#{shell_bin('powershell.exe')} -Command \"& {#{args.join(' ; ')}}\""
1717
1724
  end
1718
1725
 
1719
1726
  def relativepath(*list, all: false)
@@ -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,
@@ -863,6 +863,8 @@ module Squared
863
863
  rev_parse(flag, ref: ref, size: size)
864
864
  end
865
865
  when :build
866
+ next unless build?
867
+
866
868
  format_desc action, flag, 'opts*'
867
869
  task flag do |_, args|
868
870
  revbuild flag, args.to_a
@@ -1114,7 +1116,7 @@ module Squared
1114
1116
  end
1115
1117
  end
1116
1118
  out = choice_index('Choose a stash', git_spawn('stash list', stdout: false),
1117
- values: values, column: /^[^@]+@\{(\d+)\}/, force: true)
1119
+ values: values, column: /^[^@]+@\{(\d+)\}/)
1118
1120
  if values
1119
1121
  op.merge(out.reverse)
1120
1122
  else
@@ -1460,7 +1462,7 @@ module Squared
1460
1462
  co = git_session('commit', options: false)
1461
1463
  pu = git_output 'push', upstream && '--set-upstream'
1462
1464
  if dryrun
1463
- op.delete('--dry-run')
1465
+ op.adjoin('--dry-run')
1464
1466
  co << '--dry-run'
1465
1467
  pu << '--dry-run'
1466
1468
  end
@@ -1472,7 +1474,6 @@ module Squared
1472
1474
  end
1473
1475
  pu << '--force-with-lease' if amend
1474
1476
  pu.merge(repotrack(origin, branch))
1475
- puts if pass
1476
1477
  source op
1477
1478
  source co
1478
1479
  source pu
@@ -1767,7 +1768,7 @@ module Squared
1767
1768
  files << "#{sub_style(b, styles: color(:red))} #{a}"
1768
1769
  end
1769
1770
  unless files.empty?
1770
- files = choice_index('Select files', files, multiple: true, force: true, trim: /^\S+\s/,
1771
+ files = choice_index('Select files', files, multiple: true, trim: /^\S+\s/,
1771
1772
  accept: [['Add?', false, true]])
1772
1773
  end
1773
1774
  op.swap(list + files)
@@ -624,6 +624,7 @@ module Squared
624
624
  else
625
625
  footer.call(0, found.size)
626
626
  end
627
+ printsucc
627
628
  commit(:add, ['package.json'], pass: true)
628
629
  end
629
630
  elsif !avail.empty?
@@ -8,7 +8,7 @@ module Squared
8
8
  DIR_PYTHON = (DEP_PYTHON + %w[README.rst]).freeze
9
9
  OPT_PYTHON = {
10
10
  common: %w[b B d E h i I O P q s S u v x c=q m=b W=b X=q check-hash-based-pycs=b].freeze,
11
- build: %w[n|no-isolation s|sdist x|skip-dependency-check v|verbose w|wheel C|config-setting=q installer=b
11
+ build: %w[C=bm n|no-isolation s|sdist x|skip-dependency-check v|verbose w|wheel config-setting=q installer=b
12
12
  o|outdir=p].freeze,
13
13
  venv: %w[clear copies symlinks system-site-packages upgrade upgrade-deps without-scm-ignore-files without-pip
14
14
  prompt=q].freeze
@@ -78,7 +78,7 @@ module Squared
78
78
 
79
79
  attr_reader :venv, :editable
80
80
 
81
- def initialize(*, editable: '.', verbose: nil, **kwargs)
81
+ def initialize(*, editable: '.', **kwargs)
82
82
  super
83
83
  if @pass.include?(Python.ref)
84
84
  initialize_ref Python.ref
@@ -307,10 +307,10 @@ module Squared
307
307
  next unless build_backend == 'hatchling.build'
308
308
  end
309
309
  format_desc(action, flag, 'opts*', after: case flag
310
- when :python then 'srcdir?'
311
310
  when :poetry then 'output?'
312
311
  when :pdm then 'dest?'
313
312
  when :hatch then 'location?'
313
+ else 'outdir?'
314
314
  end)
315
315
  task flag do |_, args|
316
316
  build! flag, args.to_a
@@ -478,9 +478,6 @@ module Squared
478
478
 
479
479
  def build!(flag, opts = [])
480
480
  case flag
481
- when :python
482
- cmd, opts = python_session('-m build', opts: opts)
483
- list = OPT_PYTHON[:build]
484
481
  when :poetry
485
482
  cmd = poetry_session 'build'
486
483
  list = OPT_POETRY[:build] + OPT_POETRY[:common]
@@ -490,37 +487,32 @@ module Squared
490
487
  when :hatch
491
488
  cmd, opts = hatch_session('build', opts: opts)
492
489
  list = OPT_HATCH[:build]
490
+ else
491
+ cmd, opts = python_session('-m build', opts: opts)
492
+ list = OPT_PYTHON[:build]
493
493
  end
494
- srcdir = nil
495
494
  op = OptionPartition.new(opts, list, cmd, project: self, single: singleopt(flag))
496
- op.each do |opt|
497
- if !srcdir && basepath(opt.chomp('*')).exist? && projectpath?(opt.chomp('*'))
498
- srcdir = opt
499
- else
500
- op.found << opt
501
- end
502
- end
503
- op.swap
504
495
  case flag
505
- when :poetry, :pdm
506
- if srcdir
507
- args = flag == :pdm ? ['d', 'dest'] : ['o', 'output']
508
- if op.arg?(*args)
509
- op.push(srcdir)
510
- else
511
- op << quote_option(args.last, basepath(srcdir))
512
- end
513
- srcdir = nil
514
- end
515
496
  when :hatch
516
- if ENV['HATCH_BUILD_LOCATION']
517
- srcdir = nil
518
- else
519
- srcdir ||= path
497
+ if !ENV['HATCH_BUILD_LOCATION'] && (outdir ||= op.shift)
498
+ op.add_path(outdir)
520
499
  end
521
500
  op << basic_option('p', project) unless ENV['HATCH_PROJECT'] || op.arg?('p', 'project')
501
+ else
502
+ unless op.empty?
503
+ args = case flag
504
+ when :poetry
505
+ %w[o output]
506
+ when :pdm
507
+ %w[d dest]
508
+ else
509
+ srcdir = true
510
+ %w[o outdir]
511
+ end
512
+ op << quote_option(args.last, basepath(op.shift)) unless op.arg?(*args)
513
+ end
522
514
  end
523
- op.add_path(srcdir) if srcdir
515
+ op.exist?(add: true, first: true) if srcdir
524
516
  op.clear
525
517
  run(from: :"#{flag}:build")
526
518
  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, **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 || path.join('*.rb')),
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
@@ -287,7 +297,7 @@ module Squared
287
297
  end
288
298
  end
289
299
 
290
- def copy(from: gemlib, into: @gemdir, override: false, **kwargs)
300
+ def copy(from: gemlib, into: gemdir, override: false, **kwargs)
291
301
  return if @copy == false
292
302
 
293
303
  glob = kwargs[:include]
@@ -716,7 +726,7 @@ module Squared
716
726
  "#{spec.name}-#{spec.version}.gem"
717
727
  else
718
728
  gems = Dir.glob(basepath('*.gem')).map { |val| File.basename(val) }
719
- choice_index('Select a file', gems, force: true)
729
+ choice_index 'Select a file', gems
720
730
  end)
721
731
  else
722
732
  file = op.shift
@@ -844,27 +854,25 @@ module Squared
844
854
 
845
855
  def copy?
846
856
  return true if @copy.is_a?(Hash) ? copy[:into] : super
847
- return gemdir? if @gemdir
857
+ return gemdir? if gemdir
848
858
 
849
859
  if version
850
860
  begin
851
861
  case @autodetect
852
862
  when 'rvm'
853
- @gemdir = pwd_set { `rvm info homes` }[/^\s+gem:\s+"(.+)"$/, 1]
863
+ self.gemdir = pwd_set { `rvm info homes` }[/^\s+gem:\s+"(.+)"$/, 1]
854
864
  when 'rbenv'
855
865
  if pwd_set { `rbenv which ruby` } =~ %r{^(.+[\\/]versions[\\/](\d\.\d)\.[^\\/]+)[\\/]bin[\\/]ruby$}
856
- @gemdir = File.join($1, 'lib/ruby/gems', "#{$2}.0")
866
+ self.gemdir = File.join($1, 'lib/ruby/gems', "#{$2}.0")
857
867
  end
858
868
  when 'asdf'
859
- @gemdir = pwd_set { `asdf where ruby` }
860
- @gemdir = @gemdir =~ /(\d\.\d)\.[^.]+$/ && File.join(@gemdir, 'lib/ruby/gems', "#{$1}.0")
869
+ val = pwd_set { `asdf where ruby` }
870
+ self.gemdir = File.join(val, 'lib/ruby/gems', "#{$1}.0") if val =~ /(\d\.\d)\.[^.]+$/
861
871
  when /bundler?/
862
- @gemdir = pwd_set { `bundle env` }[/^\s+Gem Home\s+(.+)$/, 1]
872
+ self.gemdir = pwd_set { `bundle env` }[/^\s+Gem Home\s+(.+)$/, 1]
863
873
  end
864
874
  rescue StandardError => e
865
875
  log.debug e
866
- else
867
- @gemdir = Pathname.new(@gemdir) if @gemdir
868
876
  end
869
877
  return true if gemdir?
870
878
  end
@@ -875,7 +883,7 @@ module Squared
875
883
  log.warn "using version #{val} (given #{ver})"
876
884
  end
877
885
  self.version = val
878
- @gemdir = Pathname.new(path.strip) + gempath
886
+ self.gemdir = Pathname.new(path.strip) + gempath
879
887
  end
880
888
  if version
881
889
  opt = gempwd
@@ -889,17 +897,17 @@ module Squared
889
897
  next unless out =~ /\(#{Regexp.escape(val)}(?:,[^)]+|\b)\):([^\n]+)/
890
898
 
891
899
  set.call(val, $1)
892
- return gemdir? if @gemdir
900
+ return gemdir? if gemdir
893
901
  end
894
902
  end
895
903
  end
896
- @gemdir = Pathname.new(Gem.dir) + gempath
904
+ self.gemdir = Pathname.new(Gem.dir) + gempath
897
905
  else
898
906
  parse = lambda do |path|
899
907
  next unless path
900
908
 
901
909
  lib = Regexp.new(['', 'gems', "#{gemname}-([^#{File::SEPARATOR}]+)", ''].join(File::SEPARATOR))
902
- if (ver = path[lib, 1]) && (val = path[/\A(.+)#{gempath(ver[1])}/, 1])
910
+ if (ver = path[lib, 1]) && (val = path[/\A(.+)#{Regexp.escape(gempath(ver))}/, 1])
903
911
  set.call(ver, val)
904
912
  end
905
913
  end
@@ -907,7 +915,7 @@ module Squared
907
915
  target = RUBY_VERSION.start_with?('2.6') ? RubyVM : $LOAD_PATH
908
916
  parse.call(target.resolve_feature_path(gemname)&.last)
909
917
  end
910
- if !@gemdir && !pwd_set { parse.call(`#{bundle_output('show', gemname)}`) }
918
+ if !gemdir && !pwd_set { parse.call(`#{bundle_output('show', gemname)}`) }
911
919
  raise_error 'gems directory not found'
912
920
  end
913
921
  end
@@ -1047,9 +1055,9 @@ module Squared
1047
1055
  end
1048
1056
 
1049
1057
  def gemdir?
1050
- return false unless @gemdir
1058
+ return false unless gemdir
1051
1059
 
1052
- @gemdir.exist? && !@gemdir.empty?
1060
+ gemdir.exist? && !gemdir.empty?
1053
1061
  end
1054
1062
 
1055
1063
  alias read_rakefile raketasks
@@ -88,7 +88,7 @@ module Squared
88
88
 
89
89
  def arg?(target, *args, value: false, **)
90
90
  r, s = args.partition { |val| val.is_a?(Regexp) }
91
- r << matchopts(s, value: value) unless s.empty?
91
+ r << matchopts(s, value) unless s.empty?
92
92
  a = target.to_a.compact
93
93
  if (n = a.index('--'))
94
94
  a = a[0..n]
@@ -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)})/
@@ -300,13 +300,16 @@ module Squared
300
300
  self
301
301
  end
302
302
 
303
- def append_any(*args, **kwargs)
303
+ def append_any(*args, quote: true, **kwargs)
304
304
  (args.empty? ? extras : args.flatten).each do |val|
305
305
  if exist?(val)
306
306
  add_path(val, **kwargs)
307
- else
307
+ elsif quote
308
308
  add_quote(val, **kwargs)
309
+ else
310
+ add val
309
311
  end
312
+ found << val if args.empty?
310
313
  end
311
314
  self
312
315
  end
@@ -387,7 +390,7 @@ module Squared
387
390
  end
388
391
 
389
392
  def add_path(*args, **kwargs)
390
- add shell_quote(path ? path.join(*args) : File.join(*args), **kwargs)
393
+ add shell_quote(path ? path.join(*args) : File.join(*args), option: false, **kwargs)
391
394
  self
392
395
  end
393
396
 
@@ -397,27 +400,32 @@ module Squared
397
400
  self
398
401
  end
399
402
 
403
+ def delim
404
+ add '--'
405
+ self
406
+ end
407
+
400
408
  def splice(*exclude, quote: true, delim: true, path: false, pattern: false, &blk)
401
- found, other = if block_given?
402
- partition(&blk)
403
- elsif exclude.first.is_a?(Symbol)
404
- partition(&exclude.first)
405
- else
406
- partition do |val|
407
- next false if pattern && OptionPartition.pattern?(val)
408
-
409
- exclude.none? { |pat| val.match?(Regexp.new(pat)) }
410
- end
411
- end
412
- unless found.empty?
409
+ temp, other = if block_given?
410
+ partition(&blk)
411
+ elsif exclude.first.is_a?(Symbol)
412
+ partition(&exclude.first)
413
+ else
414
+ partition do |val|
415
+ next false if pattern && OptionPartition.pattern?(val)
416
+
417
+ exclude.none? { |pat| val.match?(Regexp.new(pat)) }
418
+ end
419
+ end
420
+ unless temp.empty?
413
421
  add '--' if delim
414
422
  extras.clear
415
423
  concat other
416
424
  if path
417
- found.each { |val| add_path(val) }
425
+ temp.each { |val| add_path(val) }
418
426
  else
419
- found.map! { |val| shell_quote(val) } if quote
420
- merge found
427
+ temp.map! { |val| shell_quote(val) } if quote
428
+ merge temp
421
429
  end
422
430
  end
423
431
  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
@@ -20,7 +20,7 @@ module Squared
20
20
 
21
21
  def expect(name)
22
22
  ret = project name
23
- return ret if ret&.path&.directory?
23
+ return ret if ret&.path&.directory? && !ret.path.empty?
24
24
 
25
25
  raise NoMethodError, "project is not initialized (#{name})"
26
26
  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.4.31
4
+ version: 0.4.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham