squared 0.4.36 → 0.4.38

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: 31323c0d6d0f5d2d45c7e4cc882237fb5cc687d6f7f1d3b618b86385f26d6398
4
- data.tar.gz: ddb3271ef90874b2a716418bfc344744c58a2b433954bd8034551621de500232
3
+ metadata.gz: dc06fd43c026c03e1a4ef6b082967f726f0a6a75dd3ab2ecca128198f8f51985
4
+ data.tar.gz: 6547492956431f6272a7f1165b2cb3a24f0e8b20787969837dabf13560c11815
5
5
  SHA512:
6
- metadata.gz: 281d00f10b66df75ed5e2269f566b892a768fa493e68701fd9a73de787c77e0d191e10e1165e846dbd7d93d6de8427811e6193e8970564310d56a42085dd7e5b
7
- data.tar.gz: 6672b181a9e792ff624dc8876d0b45b954c3b304f8e78abcb6a2ac674e2188aabd347e6f4d86a91c6550c11c2ac6ba842e728562a74dfb8a0740f7214a5200f3
6
+ metadata.gz: 8982c15e41b7de8e786b7d10515ff44b23e15c8e3e0b403f82db79067b792119b1df6a2b62756314f065fc21f7322c8c27e68edc5f1530fa098747272a703abb
7
+ data.tar.gz: eb886ff5f4d5d15afb15c84f1f739d410a53b7fd5aa22ac5b15112e3e5438b2ed7f590d2fd2b3601579212309565be9c51f65c1978b49cf1f78dc11ffeb0ed2c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.38] - 2026-06-14
4
+
5
+ ### Added
6
+
7
+ - Application project commands can be defined without a reference.
8
+ - Git command branch action all was implemented.
9
+
10
+ ### Changed
11
+
12
+ - Override alias methods were created for suffix "!" to "\_".
13
+ - Project banners do not display boolean attributes.
14
+ - OptionPartition method append strips single quotes when quoting strings.
15
+
16
+ ### Fixed
17
+
18
+ - Application methods log and exclude were non-functional.
19
+ - Docker command bake action build does not support changing context.
20
+ - Project base method semver did not include prerelease delimiter.
21
+ - Project session cleanup did not compare by reference.
22
+
23
+ ## [0.4.37] - 2026-04-29
24
+
25
+ ### Changed
26
+
27
+ - Project base method dependindex replaces private instance variable.
28
+
29
+ ### Fixed
30
+
31
+ - Ruby command version did not abort asdf "Not installed" error.
32
+ - Git command pull action all did not pass option flags to branches.
33
+ - Python command exec did not activate virtual environment.
34
+ - Docker command bake did not reinsert failed check for context directory.
35
+ - Common method shell_quote argument preserve did not bypass requoting.
36
+
3
37
  ## [0.4.36] - 2026-03-11
4
38
 
5
39
  ### Added
@@ -1195,6 +1229,8 @@
1195
1229
 
1196
1230
  - Changelog was created.
1197
1231
 
1232
+ [0.4.38]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.38
1233
+ [0.4.37]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.37
1198
1234
  [0.4.36]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.36
1199
1235
  [0.4.35]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.35
1200
1236
  [0.4.34]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.34
@@ -46,24 +46,31 @@ module Squared
46
46
  end
47
47
  end
48
48
 
49
- def shell_quote(val, option: true, force: true, double: false, preserve: true, override: false)
49
+ def shell_quote(val, option: true, force: true, double: false, preserve: true, pass: false, override: false)
50
50
  val = val.to_s
51
51
  return val if (!force && !val.include?(' ')) || val.empty?
52
+ return val if option && val.match?(/\A(?:-[^=\s-](?:=|\s+)?|(--)?[^=\s-][^=\s]*(?(1)(?:=|\s+)|=))(["']).+\2\z/m)
52
53
 
53
- if option
54
- pat = /\A(?:-[^=\s-](?:=|\s+)?|(--)?[^=\s-][^=\s]*(?(1)(?:=|\s+)|=))(["']).+\2\z/m
55
- return val if val.match?(pat)
56
- end
57
- q = ->(s) { s.gsub("'\\\\''", "'") }
58
54
  if val =~ QUOTE_VALUE
59
- return val if $1 == '"' && Rake::Win32.windows? && val.match?(/(?:[#{File::SEPARATOR} ]|\\")/o)
60
-
61
- base = $2 unless preserve
55
+ if pass == '"' || pass == "'"
56
+ return val if pass == $1
57
+ elsif pass || ($1 == '"' && Rake::Win32.windows? && val.match?(/(?:[#{File::SEPARATOR} ]|\\")/o))
58
+ return val
59
+ end
60
+ case preserve
61
+ when false
62
+ base = $2
63
+ when '"'
64
+ base = $2 if $1 == "'"
65
+ when "'"
66
+ base = $2 if $1 == '"'
67
+ end
62
68
  end
69
+ q = -> { (base || val).gsub("'\\\\''", "'") }
63
70
  if double || Rake::Win32.windows? || (ARG[:QUOTE] == '"' && !override)
64
- "\"#{q.call(base || val).gsub(/(?<!\\)"/, '\\"')}\""
71
+ "\"#{q.call.gsub(/(?<!\\)"/, '\\"')}\""
65
72
  else
66
- base ? val : "'#{q.call(val).gsub("'", "'\\\\''")}'"
73
+ "'#{q.call.gsub("'", "'\\\\''")}'"
67
74
  end
68
75
  end
69
76
 
@@ -9,6 +9,7 @@ module Squared
9
9
  module_function
10
10
 
11
11
  def shell(*args, name: :system, **kwargs)
12
+ kwargs.delete(:exception) unless name == :system
12
13
  if RUBY_ENGINE == 'jruby' && Rake::Win32.windows?
13
14
  e = kwargs[:exception]
14
15
  if (dir = kwargs[:chdir]) && ((pwd = Dir.pwd) != dir)
@@ -24,7 +25,7 @@ module Squared
24
25
  else
25
26
  return Kernel.send(name, *args, **kwargs)
26
27
  end
27
- return ret unless e && !ret && name == :system
28
+ return ret unless e && !ret
28
29
 
29
30
  raise $?.to_s
30
31
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.4.36'
4
+ VERSION = '0.4.38'
5
5
  end
@@ -837,7 +837,7 @@ module Squared
837
837
  log_console(*args, pipe: kwargs[:pipe] || pipe)
838
838
  end
839
839
 
840
- def script_command(task, val, group, ref, on, &blk)
840
+ def script_command(task, val, group, ref, on = nil, &blk)
841
841
  if block_given?
842
842
  val = Struct::RunData.new(val, blk)
843
843
  elsif !val
@@ -848,7 +848,7 @@ module Squared
848
848
  items = as_a(group, :to_sym)
849
849
  else
850
850
  label = :ref
851
- items = as_a(ref, :to_sym)
851
+ items = as_a(ref || :_, :to_sym)
852
852
  end
853
853
  items.each do |name|
854
854
  @script[label][name][task] = val
@@ -881,6 +881,8 @@ module Squared
881
881
  nil
882
882
  elsif ref && target[:ref].key?(ref)
883
883
  target[:ref][ref]
884
+ else
885
+ target[:ref][:_]
884
886
  end
885
887
  end
886
888
 
@@ -20,7 +20,7 @@ module Squared
20
20
  VAR_SET = %i[parent global script index envname desc dependfile dependindex theme archive env dev prod graph
21
21
  pass only exclude].freeze
22
22
  BLK_SET = %i[run depend doc lint test copy clean].freeze
23
- SEM_VER = /\b(\d+)(?:(\.)(\d+))?(?:(\.)(\d+))?[-.]?(\S+)?\b/.freeze
23
+ SEM_VER = /\b(\d+)(?:(\.)(\d+))?(?:(\.)(\d+))?(?:([-.])?(\S+))?\b/.freeze
24
24
  URI_SCHEME = %r{\A([a-z][a-z\d+-.]*)://[^@:\[\]\\^<>|\s]}i.freeze
25
25
  TASK_METADATA = Rake::TaskManager.record_task_metadata
26
26
  private_constant :VAR_SET, :BLK_SET, :SEM_VER, :URI_SCHEME, :TASK_METADATA
@@ -816,9 +816,9 @@ module Squared
816
816
  end
817
817
 
818
818
  def run(cmd = @session, var = nil, exception: self.exception, sync: true, from: nil, banner: true, chdir: path,
819
- interactive: nil, hint: nil, **)
819
+ interactive: nil, hint: nil, send: :system, **)
820
820
  unless cmd
821
- print_error('no command session started', subject: project, hint: from || 'unknown', pass: true)
821
+ print_error('no command session started', subject: project, hint: from, pass: true)
822
822
  return
823
823
  end
824
824
  cmd = cmd.target if cmd.is_a?(OptionPartition)
@@ -854,7 +854,7 @@ module Squared
854
854
  end
855
855
  end
856
856
  args = var.is_a?(Hash) ? [var, cmd] : [cmd]
857
- ret = shell(*args, chdir: chdir, exception: exception)
857
+ ret = shell(*args, name: send, chdir: chdir, exception: exception)
858
858
  end
859
859
  rescue StandardError => e
860
860
  on_error(e, from, exception: true)
@@ -904,7 +904,7 @@ module Squared
904
904
  run_set(output[0], *args, **kwargs)
905
905
  when :dependfile
906
906
  @dependindex = nil
907
- @dependfile = val.nil? ? nil : basepath(*args)
907
+ @dependfile = (basepath(*args) if val)
908
908
  else
909
909
  if block_given?
910
910
  if blocks.include?(key)
@@ -1009,7 +1009,7 @@ module Squared
1009
1009
  end
1010
1010
 
1011
1011
  def dependtype(*)
1012
- @dependindex ? @dependindex.succ : 0
1012
+ dependindex&.succ || 0
1013
1013
  end
1014
1014
 
1015
1015
  def log
@@ -1268,7 +1268,7 @@ module Squared
1268
1268
  return cmd unless cmd.respond_to?(:done)
1269
1269
 
1270
1270
  raise_error('no args added', hint: cmd.first) unless cmd.size > 1
1271
- @session = nil if cmd == @session
1271
+ @session = nil if cmd.equal?(@session)
1272
1272
  cmd.done
1273
1273
  end
1274
1274
 
@@ -1409,7 +1409,7 @@ module Squared
1409
1409
  __send__(meth)
1410
1410
  end
1411
1411
  end
1412
- val = val.compact.join(s)
1412
+ val = val.reject { |item| !item || item == true }.join(s)
1413
1413
  next unless found && !val.empty?
1414
1414
  elsif (val = __send__(val)).nil?
1415
1415
  next
@@ -1790,9 +1790,9 @@ module Squared
1790
1790
 
1791
1791
  a, b = [a.first, b.first].map! do |c|
1792
1792
  begin
1793
- d = Integer(c[5]).to_s
1793
+ d = Integer(c[6]).to_s
1794
1794
  rescue StandardError
1795
- d = c[5] ? '-1' : '0'
1795
+ d = c[6] ? '-1' : '0'
1796
1796
  end
1797
1797
  [c[0], c[2], c[4] || '0', d]
1798
1798
  end
@@ -2012,10 +2012,21 @@ module Squared
2012
2012
  end
2013
2013
  end
2014
2014
 
2015
- def dependfile_set(list)
2016
- @dependindex = list.index { |file| basepath(file).exist? }.tap do |index|
2017
- @dependfile = basepath(list[index || 0])
2018
- end
2015
+ def dependfile_set(list, default: 0)
2016
+ @dependindex = if @dependname
2017
+ @dependfile = basepath @dependname
2018
+ list.index(@dependname)
2019
+ else
2020
+ list.index { |file| basepath(file).exist? }.tap do |i|
2021
+ @dependfile = basepath(list[i || default])
2022
+ end
2023
+ end || (list unless enabled?)
2024
+ end
2025
+
2026
+ def dependindex
2027
+ dependfile_set @dependindex if @dependindex.is_a?(Array)
2028
+
2029
+ @dependindex unless @dependindex.is_a?(Array)
2019
2030
  end
2020
2031
 
2021
2032
  def as_get(val, from)
@@ -2066,7 +2077,7 @@ module Squared
2066
2077
  end
2067
2078
 
2068
2079
  def semmajor?(cur, want)
2069
- (cur[0] == '0' && want[0] == '0' ? cur[2] != want[2] : cur[0] != want[0]) && !want[5]
2080
+ (cur[0] == '0' && want[0] == '0' ? cur[2] != want[2] : cur[0] != want[0]) && !want[6]
2070
2081
  end
2071
2082
 
2072
2083
  def printfirst?
@@ -20,7 +20,7 @@ module Squared
20
20
  sbom=q].freeze
21
21
  }.freeze,
22
22
  compose: {
23
- common: %w[all-resources compatibility dry-run ansi|b env-file=p f|file=p parallel=n profile=b progress=b
23
+ common: %w[all-resources compatibility dry-run ansi=b env-file=p f|file=p parallel=n profile=b progress=b
24
24
  project-directory=p p|project-name=e].freeze,
25
25
  build: %w[check no-cache print pull push with-dependencies q|quiet build-arg=qq builder=b m|memory=b
26
26
  provenance=q sbom=q ssh=qq].freeze,
@@ -330,19 +330,8 @@ module Squared
330
330
  append_tag(tag || option('tag', ignore: false) || self.tag)
331
331
  append_context context
332
332
  when :bake
333
- unless op.empty?
334
- args = op.dup
335
- op.reset
336
- if Dir.exist?(args.last)
337
- if projectpath?(val = args.pop)
338
- context = val
339
- else
340
- op.push(val)
341
- end
342
- end
343
- op.append(args, escape: true, strip: /^:/)
344
- contextdir context if context
345
- end
333
+ op.append(escape: true, strip: /^:/, clear: true)
334
+ op.push(context) if context
346
335
  end
347
336
  op.clear(pass: false)
348
337
  run(from: :"buildx:#{flag}")
@@ -362,6 +351,7 @@ module Squared
362
351
  end
363
352
  run(from: :"compose:#{flag}")
364
353
  end
354
+ alias compose_ compose!
365
355
 
366
356
  def container(flag, opts = [], id: nil)
367
357
  cmd, opts = docker_session('container', flag, opts: opts)
@@ -339,7 +339,7 @@ module Squared
339
339
  end
340
340
 
341
341
  subtasks({
342
- 'branch' => %i[create track delete move copy list current].freeze,
342
+ 'branch' => %i[create track delete move copy list all current].freeze,
343
343
  'checkout' => %i[commit branch track detach path].freeze,
344
344
  'commit' => %i[add all amend amend-orig fixup].freeze,
345
345
  'diff' => %i[head branch files view between contain].freeze,
@@ -697,12 +697,7 @@ module Squared
697
697
  task flag do |_, args|
698
698
  branch flag, args.to_a
699
699
  end
700
- when :current
701
- format_desc action, flag
702
- task flag do
703
- branch flag
704
- end
705
- else
700
+ when :move, :copy
706
701
  format_desc action, flag, 'branch,oldbranch?'
707
702
  task flag, [:branch, :oldbranch] do |_, args|
708
703
  if (branch = args.branch)
@@ -713,6 +708,11 @@ module Squared
713
708
  end
714
709
  branch(flag, refs: [oldbranch, branch])
715
710
  end
711
+ else
712
+ format_desc action, flag
713
+ task flag do
714
+ branch flag
715
+ end
716
716
  end
717
717
  when 'switch'
718
718
  case flag
@@ -983,12 +983,8 @@ module Squared
983
983
  printsucc
984
984
  end
985
985
  op = OptionPartition.new(opts, OPT_GIT[:pull], cmd, project: self, no: OPT_GIT[:no][:pull])
986
- reg = if op.empty?
987
- []
988
- else
989
- opts = op.uniq(opts)
990
- matchmap op
991
- end
986
+ opts -= op.extras
987
+ reg = matchmap op
992
988
  session_done op.target
993
989
  heads = []
994
990
  cur = nil
@@ -1361,6 +1357,7 @@ module Squared
1361
1357
  append_pathspec op.extras
1362
1358
  source(exception: false)
1363
1359
  end
1360
+ alias log_ log!
1364
1361
 
1365
1362
  def diff(flag, opts = [], refs: [], branch: nil, range: [], index: [])
1366
1363
  cmd, opts = git_session('diff', opts: opts)
@@ -1804,6 +1801,10 @@ module Squared
1804
1801
 
1805
1802
  def source(cmd = @session, exception: true, io: false, sync: true, stdout: false, stderr: false, banner: true,
1806
1803
  multiple: false, hint: nil, from: nil, send: :system, **kwargs)
1804
+ unless cmd
1805
+ print_error('no git session started', subject: project, hint: from, pass: true)
1806
+ return
1807
+ end
1807
1808
  cmd = cmd.target if cmd.is_a?(OptionPartition)
1808
1809
  if io && banner == false
1809
1810
  from = nil
@@ -1990,7 +1991,7 @@ module Squared
1990
1991
  end
1991
1992
  op << '--verbose' if (flag || from == :fetch) && stdout? && !op.arg?('quiet')
1992
1993
  if remote
1993
- op.append(remote, delim: true)
1994
+ op.append(remote)
1994
1995
  if (val = option('refspec', target: target, strict: true))
1995
1996
  op.append(*split_escape(val))
1996
1997
  else
@@ -552,7 +552,7 @@ module Squared
552
552
  when :patch
553
553
  upgrade = a == c && b == d && f[4] != w[4]
554
554
  end
555
- if upgrade && !w[5]
555
+ if upgrade && !w[6]
556
556
  next if file == want
557
557
 
558
558
  found << [key, file, want, if a != c
@@ -87,7 +87,7 @@ module Squared
87
87
  initialize_build(Python.ref, **kwargs)
88
88
  initialize_env(**kwargs)
89
89
  end
90
- dependfile_set DEP_PYTHON
90
+ dependfile_set(DEP_PYTHON, default: 2)
91
91
  editable_set editable
92
92
  venv_set kwargs[:venv]
93
93
  end
@@ -176,11 +176,11 @@ module Squared
176
176
  end
177
177
  break
178
178
  end
179
- unless found.anybits?(1)
180
- puts log_message(found == 0 ? Logger::INFO : Logger.WARN,
181
- "no scripts #{found == 0 ? 'found' : 'executed'}",
182
- subject: name, hint: pyprojectfile)
183
- end
179
+ next if found.anybits?(1)
180
+
181
+ puts log_message(found == 0 ? Logger::INFO : Logger::WARN,
182
+ "no scripts #{found == 0 ? 'found' : 'executed'}",
183
+ subject: name, hint: pyprojectfile)
184
184
  end
185
185
  when 'exec'
186
186
  format_desc action, nil, 'command|:,args*'
@@ -196,7 +196,7 @@ module Squared
196
196
  end
197
197
  args.join(' ')
198
198
  end
199
- shell(cmd, name: :exec, chdir: path)
199
+ run(cmd, send: :exec, banner: false)
200
200
  end
201
201
  end
202
202
  else
@@ -516,6 +516,7 @@ module Squared
516
516
  op.clear
517
517
  run(from: :"#{flag}:build")
518
518
  end
519
+ alias build_ build!
519
520
 
520
521
  def publish(flag, opts = [])
521
522
  case flag
@@ -7,7 +7,7 @@ module Squared
7
7
  GEMFILE = %w[Gemfile Gemfile.lock gem.deps.rb gems.rb Isolate].freeze
8
8
  DIR_RUBY = (GEMFILE + Rake::Application::DEFAULT_RAKEFILES + ['README.rdoc']).freeze
9
9
  OPT_RUBY = {
10
- ruby: %w[0=im? a c C=pm e=q E=bm F=qm i=bm? I=pm l n p r=bm s S w W=bm? x=pm? d|debug jit rjit verbose
10
+ ruby: %w[a c l n p s S w 0=im? C=pm e=q E=bm F=qm i=bm? I=pm r=bm W=bm? x=pm? d|debug jit rjit verbose
11
11
  y|yydebug backtrace-limit=i crash-report=q disable=q dump=q enable=q encoding=b external-encoding=b
12
12
  internal-encoding=b parser=b].freeze,
13
13
  rake: %w[A|all B|build-all comments n|dry-run m|multitask P|prereqs q|quiet X|no-deprecation-warnings
@@ -496,7 +496,7 @@ module Squared
496
496
  ].each do |val|
497
497
  next unless val.empty? || File.exist?(val.sub('$HOME', Dir.home))
498
498
 
499
- trim = ->(s) { s[/\A\D+\d+\.\d+(?:\.\S+)?/, 0].sub(/\A([a-z]+)-/i, '\1 ') }
499
+ trim = ->(s) { s =~ /^\D+\d+\.\d+(?:\.\S+)?/ ? $&.sub(/^([a-z]+)-/i, '\1 ') : s }
500
500
  ver = '.ruby-version'
501
501
  out << trim.call(case (cmd = File.basename(val))
502
502
  when 'rvm'
@@ -509,7 +509,8 @@ module Squared
509
509
  `#{chruby.with('ruby --version')}`
510
510
  when 'install'
511
511
  ver = '.tool-versions'
512
- `asdf current ruby`[/ruby\s+\S+/, 0].sub(/\s+/, ' ')
512
+ exit 1 unless (cur = `asdf current ruby`[/ruby\s+\S+/, 0])
513
+ cur.sub(/\s+/, ' ')
513
514
  else
514
515
  ver = nil
515
516
  `ruby --version`
@@ -21,7 +21,7 @@ module Squared
21
21
  include Prompt
22
22
 
23
23
  def append(target, *args, delim: false, escape: false, quote: true, strip: nil, force: true, double: false,
24
- **)
24
+ preserve: true, **)
25
25
  return if (ret = args.flatten).empty?
26
26
 
27
27
  target << '--' if delim && !target.include?('--')
@@ -35,7 +35,7 @@ module Squared
35
35
  if !(pa = val.is_a?(Pathname)) && escape
36
36
  shell_escape(val, quote: quote, double: double)
37
37
  elsif quote || pa
38
- shell_quote(val, force: force, double: double)
38
+ shell_quote(val, force: force, double: double, preserve: preserve)
39
39
  else
40
40
  val
41
41
  end
@@ -294,9 +294,9 @@ module Squared
294
294
  self
295
295
  end
296
296
 
297
- def append(*args, **kwargs)
298
- args = extras if args.empty?
299
- OptionPartition.append(target, *args, **kwargs)
297
+ def append(*args, clear: false, preserve: '"', **kwargs)
298
+ args = clear ? extras.dup.tap { extras.clear } : extras if args.empty?
299
+ OptionPartition.append(target, *args, preserve: preserve, **kwargs)
300
300
  self
301
301
  end
302
302
 
@@ -16,7 +16,7 @@ module Squared
16
16
  attr_reader :manifest_url, :manifest
17
17
 
18
18
  def repo(url, manifest = 'latest', run: nil, script: nil, args: nil, dev: nil, prod: nil,
19
- ref: @ref, group: @group)
19
+ ref: @ref, group: @group, **)
20
20
  @home = if (val = env('REPO_HOME'))
21
21
  path = Pathname.new(val)
22
22
  if main == path.basename.to_s
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.36
4
+ version: 0.4.38
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
- rubygems_version: 4.0.3
128
+ rubygems_version: 4.0.10
129
129
  specification_version: 4
130
130
  summary: Rake task generator for managing multi-language workspaces.
131
131
  test_files: []