squared 0.5.17 → 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: 91dfb7530ecdb1ab70461ab8bbbf894e706ea6f78b5e9ada99c930d0819e9ec9
4
- data.tar.gz: 82591aa893baf80057a3193e95763b8ce98c13593de54dffd00e31f0c27a3bf8
3
+ metadata.gz: 90e816457aa629a2416781e2480aa4025f0b5395eb41dc45157ecbb0d9a57262
4
+ data.tar.gz: a03eca5dba74e2b6c3c6d6946291f788e5f3a75c84afa89a8e5139c325d3397a
5
5
  SHA512:
6
- metadata.gz: ce78218f60162cda536062dc37e5f27f30b5cd25e1afcac502c3519085988594c01ea149b47ecd536373ba2f4312162d468915fd6792f27f15d1d301bf2e03eb
7
- data.tar.gz: b0b6cec02ec4c531ddbabfa4ff1f3f8a87cf4592dd48fd86b74a8ac3787c602df165b0526cd69af8c585c221dcace1bcfc606a1bc511e3722f1e1b9cd1161e17
6
+ metadata.gz: 3ec9a3d2105f6355485a71820b4631554dfe9a47a6b4fbfb36d690b09693cd54abad75877aa7b17fe235dadcf2f03c0508b5ea33dd0e3a67c69faa73ad6c19b4
7
+ data.tar.gz: 8ed22f2ba7bb7195082d616ab085ead6e1795fa23a06f9bc48035206e1dedec4f146b2934711c2d88ac52e77b8c000838a517bdc8ddb616a3b0d5c1a9c608bd8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
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
+
23
+ ## [0.5.18] - 2025-11-25
24
+
25
+ ### Fixed
26
+
27
+ - See `0.4.32`.
28
+
29
+ ## [0.4.32] - 2025-11-25
30
+
31
+ ### Fixed
32
+
33
+ - Git method commit did not include --dry-run with add command.
34
+ - JoinSet method include? did not always search to start of delimiter.
35
+ - Config viewer did not check for a readable package registry document.
36
+ - Powershell executable did not check for alternate path location.
37
+
3
38
  ## [0.5.17] - 2025-11-22
4
39
 
5
40
  ### Fixed
@@ -1271,6 +1306,8 @@
1271
1306
 
1272
1307
  - Changelog was created.
1273
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
1274
1311
  [0.5.17]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.17
1275
1312
  [0.5.16]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.16
1276
1313
  [0.5.15]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.15
@@ -1289,6 +1326,8 @@
1289
1326
  [0.5.2]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.2-ruby
1290
1327
  [0.5.1]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.1-ruby
1291
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
1292
1331
  [0.4.31]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.31
1293
1332
  [0.4.30]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.30
1294
1333
  [0.4.29]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.29
@@ -112,7 +112,8 @@ module Squared
112
112
  end
113
113
 
114
114
  def shell_bin(name, env: true)
115
- key = name.upcase
115
+ key = name.to_s.upcase
116
+ key = File.basename(key, '.*') if Rake::Win32.windows?
116
117
  shell_quote((env && ENV["PATH_#{key}"]) || PATH[key] || PATH[key.to_sym] || name,
117
118
  option: false, force: false, double: true)
118
119
  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 = 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
@@ -211,7 +211,7 @@ module Squared
211
211
  file = nil
212
212
  ext[0] = mime
213
213
  elsif file
214
- keys.prepend(file)
214
+ keys.unshift(file)
215
215
  alt = basepath "#{main}.{#{ext.join(',')}}"
216
216
  file = Dir[alt].first
217
217
  else
@@ -293,7 +293,7 @@ module Squared
293
293
  if stdin?
294
294
  puts out.map!(&:last).join("\n")
295
295
  else
296
- out.map! { |item| '%-*s : %s' % [pad, item[0], item[1]] }
296
+ out.map! { |a, b| '%-*s : %s' % [pad, a, b] }
297
297
  end
298
298
  end
299
299
 
@@ -309,7 +309,7 @@ module Squared
309
309
  return unless Rake::TaskManager.record_task_metadata
310
310
 
311
311
  val = "#{ext.first}[#{target ? '' : "file?=#{File.basename(main)}.#{ext.last},"}keys+]"
312
- args = *name.split(':').append(command, val)
312
+ args = *name.split(':').push(command, val)
313
313
  if project
314
314
  project.workspace.task_desc(*args)
315
315
  else
@@ -322,7 +322,9 @@ module Squared
322
322
  end
323
323
 
324
324
  def warning?
325
- project ? project.workspace.warning : true
325
+ return true unless project
326
+
327
+ project.workspace.warning
326
328
  end
327
329
 
328
330
  def stdin?
@@ -347,7 +349,9 @@ module Squared
347
349
  end
348
350
 
349
351
  def basepath(*args)
350
- project ? project.basepath(*args) : Pathname.pwd.join(*args)
352
+ return Pathname.pwd.join(*args) unless project
353
+
354
+ project.basepath(*args)
351
355
  end
352
356
  end
353
357
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.5.17'
4
+ VERSION = '0.5.19'
5
5
  end
@@ -29,7 +29,7 @@ module Squared
29
29
  self.impl_project = obj
30
30
  impl_series.base_set(obj)
31
31
  else
32
- kind_project.prepend(obj)
32
+ kind_project.unshift(obj)
33
33
  obj.tasks&.each { |task| impl_series.add(task, obj) }
34
34
  end
35
35
  if (args = obj.batchargs)
@@ -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]
@@ -785,7 +785,7 @@ module Squared
785
785
  end
786
786
  end
787
787
  if step == -1
788
- level.prepend(data.action)
788
+ level.unshift(data.action)
789
789
  step = 0
790
790
  elsif step > 0
791
791
  (level[step -= 1] ||= []).concat(data.action)
@@ -365,7 +365,7 @@ module Squared
365
365
  when 'unpack'
366
366
  format_desc(action, flag, 'tag/url,dir,digest?,f|force?', before: flag == :ext ? 'ext' : nil)
367
367
  params = %i[tag dir digest force]
368
- params.prepend(:ext) if flag == :ext
368
+ params.unshift(:ext) if flag == :ext
369
369
  task flag, params do |_, args|
370
370
  ext = flag == :ext ? param_guard(action, flag, args: args, key: :ext) : flag.to_s
371
371
  tag = param_guard(action, flag, args: args, key: :tag)
@@ -402,8 +402,8 @@ module Squared
402
402
  @asdf[1].children
403
403
  .map(&:basename)
404
404
  .sort { |a, b| b <=> a }
405
- .append('latest', 'system'),
406
- force: true, accept: [['Confirm?', false, true]],
405
+ .push('latest', 'system'),
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,12 +528,12 @@ 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
535
535
  when Hash
536
- cmd = Array(cmd).append(flags)
536
+ cmd = Array(cmd).push(flags)
537
537
  .concat(append_hash(opts, target: [], build: true))
538
538
  .compact
539
539
  .join(' ')
@@ -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)
@@ -1770,7 +1777,7 @@ module Squared
1770
1777
  def command(*args)
1771
1778
  return args.join(' && ') unless workspace.powershell?
1772
1779
 
1773
- "powershell.exe -Command #{shell_quote("& {#{args.join(' ; ')}}", option: false, double: true)}"
1780
+ "#{shell_bin('powershell.exe')} -Command \"& {#{args.join(' ; ')}}\""
1774
1781
  end
1775
1782
 
1776
1783
  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,
@@ -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
@@ -1457,13 +1459,14 @@ module Squared
1457
1459
  append_pathspec op.extras
1458
1460
  end
1459
1461
  co = git_session('commit', options: false)
1460
- pu = git_output 'push', upstream && '--set-upstream'
1462
+ pu = git_output 'push'
1463
+ co << '--amend' if amend
1464
+ pu << '--set-upstream' if upstream
1461
1465
  if dryrun?
1462
- op.delete('--dry-run')
1466
+ op.adjoin('--dry-run')
1463
1467
  co << '--dry-run'
1464
1468
  pu << '--dry-run'
1465
1469
  end
1466
- co << '--amend' if amend
1467
1470
  if message
1468
1471
  append_message message
1469
1472
  elsif flag == :'amend-orig' || option('edit', equals: '0')
@@ -1471,7 +1474,6 @@ module Squared
1471
1474
  end
1472
1475
  pu << '--force-with-lease' if amend
1473
1476
  pu.merge(repotrack(origin, branch))
1474
- puts if pass
1475
1477
  adding = git_spawn 'diff --name-only --no-color'
1476
1478
  source op
1477
1479
  cached = git_spawn 'diff --cached --name-only --no-color'
@@ -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)
@@ -219,7 +219,7 @@ module Squared
219
219
  version = param_guard(action, 'version', args: args, key: :version)
220
220
  args = args.extras
221
221
  args << readline('Enter command', force: true) if args.empty?
222
- args.prepend(File.join(ENV['NVM_DIR'], 'nvm-exec'))
222
+ args.unshift(File.join(ENV['NVM_DIR'], 'nvm-exec'))
223
223
  run(args.join(' '), { 'NODE_VERSION' => version }, banner: false, from: :nvm)
224
224
  end
225
225
  when 'pack'
@@ -632,6 +632,7 @@ module Squared
632
632
  else
633
633
  footer.call(0, found.size)
634
634
  end
635
+ printsucc
635
636
  commit(:add, ['package.json'], pass: true)
636
637
  end
637
638
  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, 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]
@@ -516,7 +526,7 @@ module Squared
516
526
  c < d ? -1 : 1
517
527
  end
518
528
  end
519
- .append('')
529
+ .push('')
520
530
  .each do |val|
521
531
  next unless val.empty? || File.exist?(val.sub('$HOME', Dir.home))
522
532
 
@@ -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
@@ -921,23 +929,23 @@ module Squared
921
929
  out = `#{gem_output(opt, 'list --local -d', gemname)}`
922
930
  if out =~ /#{Regexp.escape(gemname)} \(([^)]+)\)/
923
931
  split_escape($1)
924
- .prepend(version)
932
+ .unshift(version)
925
933
  .uniq
926
934
  .each do |val|
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
@@ -558,7 +559,7 @@ module Squared
558
559
  end
559
560
 
560
561
  def last(val, pat)
561
- (@last ||= []).append([val, pat, $1]) if val =~ pat
562
+ (@last ||= []).push([val, pat, $1]) if val =~ pat
562
563
  self << val
563
564
  end
564
565
 
@@ -641,6 +642,13 @@ module Squared
641
642
  super + extras.size
642
643
  end
643
644
 
645
+ def include?(obj)
646
+ return true if super
647
+ return extras.include?(obj) unless (n = extras.index(@partition))
648
+
649
+ extras[0..n].include?(obj)
650
+ end
651
+
644
652
  def to_a
645
653
  pass
646
654
  end
@@ -663,6 +671,7 @@ module Squared
663
671
 
664
672
  alias add :<<
665
673
  alias add? :<<
674
+ alias member? include?
666
675
 
667
676
  private
668
677
 
@@ -216,7 +216,7 @@ module Squared
216
216
  end
217
217
  end
218
218
 
219
- series.sync.append(
219
+ series.sync.push(
220
220
  task_join(path, 'all'),
221
221
  task_join(path, 'init'),
222
222
  task_join(path, 'sync')
@@ -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.5.17
4
+ version: 0.5.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham