squared 0.3.6 → 0.3.7

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: b59f278e65c23dac20a5c1e9b297190c54f780684979b6573b02acbf26656ac1
4
- data.tar.gz: f932dfb230ca2e002f011c14c216e85360165911bd70524d1a7462b9fec3357d
3
+ metadata.gz: 404b6e4de1ff62a628030bfa5487287dac6a962a6e052297537533a29ff6be2c
4
+ data.tar.gz: a136f94da4653d88325e3ed571523d1d3a57d8974695ce306bfadd6c2264e6c1
5
5
  SHA512:
6
- metadata.gz: 56ab1e6ee032fef15a6ccef5f1f2024336d6e97f0bd3b99e1c13e95a71825c3d732ce44a7e429cc172501764d2838c41a1ea126a10f8dde2391d8f3047998d7b
7
- data.tar.gz: 570232bd61ade909d6d1b7d68d9a367f77b66d6aacdac116896a8109195a74eb2047f58b66f4bcadf208fdb0819cedbc7ad535b4ac03456e4cdfb29581aa62a1
6
+ metadata.gz: 26e2e83cdefdb8b3c9641f1aa5880432426cfbd807ddb659252f10735eafb0353d61d80ef87876251c6b8720fa434d5cb0df7a541476ff4573f71e6c8a49b27d
7
+ data.tar.gz: c457360ca63c5941594781613662c51b3d5ae18d9bac436f70357ebbc4ef2418504f8f376981cc03bb5590bc20d9540909fd2318414b631c091b64ee8e58df04
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.7] - 2025-04-08
4
+
5
+ - See `0.2.7`.
6
+
7
+ ## [0.2.7] - 2025-04-08
8
+
9
+ ### Fixed
10
+
11
+ - Paths that conflict with git options can be quoted.
12
+ - Bundle command update did not append package names.
13
+ - Git result status type was truncated.
14
+ - Log messages were concatenated without separator.
15
+ - Python pip environment options used undefined session.
16
+ - Regexp "o" modifier was not used properly.
17
+ - Rake did not run individual project Rakefile.
18
+ - Ruby commands did not delimit exec arguments.
19
+
3
20
  ## [0.3.6] - 2025-03-12
4
21
 
5
22
  ### Added
@@ -314,6 +331,7 @@
314
331
 
315
332
  - Changelog was created.
316
333
 
334
+ [0.3.7]: https://github.com/anpham6/squared/releases/tag/v0.3.7-ruby
317
335
  [0.3.6]: https://github.com/anpham6/squared/releases/tag/v0.3.6-ruby
318
336
  [0.3.5]: https://github.com/anpham6/squared/releases/tag/v0.3.5-ruby
319
337
  [0.3.4]: https://github.com/anpham6/squared/releases/tag/v0.3.4-ruby
@@ -321,6 +339,7 @@
321
339
  [0.3.2]: https://github.com/anpham6/squared/releases/tag/v0.3.2-ruby
322
340
  [0.3.1]: https://github.com/anpham6/squared/releases/tag/v0.3.1-ruby
323
341
  [0.3.0]: https://github.com/anpham6/squared/releases/tag/v0.3.0-ruby
342
+ [0.2.7]: https://github.com/anpham6/squared/releases/tag/v0.2.7-ruby
324
343
  [0.2.6]: https://github.com/anpham6/squared/releases/tag/v0.2.6-ruby
325
344
  [0.2.5]: https://github.com/anpham6/squared/releases/tag/v0.2.5-ruby
326
345
  [0.2.4]: https://github.com/anpham6/squared/releases/tag/v0.2.4-ruby
@@ -114,7 +114,7 @@ module Squared
114
114
  if !val.is_a?(::Numeric)
115
115
  val = val.to_sym
116
116
  ret << val if colors.key?(val) || TEXT_STYLE.include?(val)
117
- elsif val >= 0 && val <= 256
117
+ elsif val.between?(0, 256)
118
118
  ret << val
119
119
  elsif val < 0 && (b = val.to_s.split('.')[1])
120
120
  b = b[0, 3]
@@ -174,12 +174,8 @@ module Squared
174
174
  emphasize(args, title: title + (subject ? " #{subject}" : ''), sub: sub)
175
175
  else
176
176
  msg = [log_title(level, color: color)]
177
- if subject
178
- msg << (color ? sub_style(subject, :underline) : subject)
179
- else
180
- msg += args
181
- args.clear
182
- end
177
+ msg << (color ? sub_style(subject, :underline) : subject) if subject
178
+ msg << args.shift if msg.size == 1
183
179
  message(msg.join(' '), *args, hint: hint)
184
180
  end
185
181
  end
@@ -27,7 +27,8 @@ module Squared
27
27
 
28
28
  def shell_quote(val, force: true)
29
29
  val = val.to_s
30
- return val if (!force && !val.include?(' ')) || val.match?(/(?:^|\S=|[^=]\s+)(["']).+\1\z/m)
30
+ return val if !force && !val.include?(' ')
31
+ return val if option && val =~ /(?:^|\S=|[^=]\s+|#{Rake::Win32.windows? ? '[\\\/]' : '\/'})(["']).+\1\z/m
31
32
 
32
33
  Rake::Win32.windows? || ARG[:QUOTE] == '"' ? "\"#{double_quote(val)}\"" : "'#{single_quote(val)}'"
33
34
  end
@@ -79,7 +80,7 @@ module Squared
79
80
  end
80
81
 
81
82
  def split_escape(val, char: ',')
82
- val.split(/\s*(?<!\\)#{char}\s*/o)
83
+ val.split(/\s*(?<!\\)#{char}\s*/)
83
84
  end
84
85
  end
85
86
  end
@@ -88,7 +88,7 @@ module Squared
88
88
  return ret.to_i
89
89
  end
90
90
  when ::Numeric
91
- return key if key >= 0 && key <= 2
91
+ return key if key.between?(0, 2)
92
92
  end
93
93
  default
94
94
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.3.6'
4
+ VERSION = '0.3.7'
5
5
  end
@@ -404,7 +404,7 @@ module Squared
404
404
  end
405
405
 
406
406
  def task_localname(val)
407
- prefix && val.is_a?(String) ? val.sub(/\A#{Regexp.escape(prefix)}:/o, '') : val.to_s
407
+ prefix && val.is_a?(String) ? val.sub(/\A#{Regexp.escape(prefix)}:/, '') : val.to_s
408
408
  end
409
409
 
410
410
  def task_desc(*args, **kwargs)
@@ -898,7 +898,7 @@ module Squared
898
898
  nil
899
899
  end
900
900
 
901
- def option_sanitize(opts, list, target: @session, no: nil, first: false, pass: ['='])
901
+ def option_sanitize(opts, list, target: @session, no: nil, args: false, first: false, pass: ['='])
902
902
  ret = []
903
903
  reg = []
904
904
  bare = []
@@ -967,6 +967,7 @@ module Squared
967
967
  opt = a
968
968
  else
969
969
  ret << opt
970
+ found = true if args
970
971
  end
971
972
  found = true if first && pass.none? { |val| opt.include?(val) }
972
973
  end
@@ -975,9 +976,11 @@ module Squared
975
976
  end
976
977
 
977
978
  def option_clear(opts, target: @session, **kwargs)
979
+ return if opts.empty?
980
+
978
981
  kwargs[:subject] ||= target&.first
979
- kwargs[:hint] ||= 'not used'
980
- warn log_message(Logger::WARN, opts.join(', '), **kwargs) unless opts.empty?
982
+ kwargs[:hint] ||= 'unrecognized'
983
+ warn log_message(:warn, opts.join(', '), **kwargs)
981
984
  end
982
985
 
983
986
  def print_item(*val)
@@ -1227,7 +1230,7 @@ module Squared
1227
1230
 
1228
1231
  def param_guard(action, flag, args: nil, key: nil, pat: nil)
1229
1232
  if args && key
1230
- val = args[key]
1233
+ val = args.fetch(key, nil)
1231
1234
  return val unless val.nil? || (pat && !val.match?(pat))
1232
1235
 
1233
1236
  @session = nil
@@ -79,7 +79,7 @@ module Squared
79
79
  contains=e format=q merged=e no-contains=e no-merged=e points-at=e u|set-upstream-to=e sort=q
80
80
  t|track=b].freeze,
81
81
  checkout: %w[l d|detach f|force ignore-other-worktrees ignore-skip-worktree-bits m|merge p|patch
82
- pathspec-file-nul q quiet orphan=e ours theirs conflict=b pathspec-from-file=p
82
+ pathspec-file-nul q|quiet orphan=e ours theirs conflict=b pathspec-from-file=p
83
83
  t|track=b].freeze,
84
84
  diff: {
85
85
  base: %w[0 1|base 2|ours 3|theirs].freeze,
@@ -546,7 +546,7 @@ module Squared
546
546
  format_desc action, flag, 'remote,opts*,pattern*'
547
547
  task flag, [:remote] do |_, args|
548
548
  remote = param_guard(action, flag, args: args, key: :remote)
549
- ls_remote(flag, args.to_a.drop(1), remote: remote)
549
+ ls_remote(flag, args.extras, remote: remote)
550
550
  end
551
551
  else
552
552
  format_desc action, flag, 'opts*,pattern*'
@@ -914,10 +914,10 @@ module Squared
914
914
  unless (origin = option('repository', prefix: 'git', ignore: false))
915
915
  out = source(git_output('log -n1 --format=%h%d'), io: true, stdout: true, banner: false).first
916
916
  if out =~ /^#{data[2]} \(HEAD -> #{Regexp.escape(branch)}, (.+?)\)$/
917
- split_escape($1).each do |val|
918
- next unless val.end_with?("/#{branch}")
917
+ split_escape($1).each do |s|
918
+ next unless s.end_with?("/#{branch}")
919
919
 
920
- origin = val[0, val.size - branch.size - 1]
920
+ origin = s[0, s.size - branch.size - 1]
921
921
  break
922
922
  end
923
923
  end
@@ -1212,7 +1212,7 @@ module Squared
1212
1212
  if size > 0
1213
1213
  styles = theme.fetch(:banner, []).reject { |s| s.to_s.end_with?('!') }
1214
1214
  styles << :bold if styles.size <= 1
1215
- puts print_footer("#{size} #{size == 1 ? type.sub(/e?s\z/, '') : type}",
1215
+ puts print_footer("#{size} #{size == 1 ? type.sub(/(?:(?<!l)e)?s\z/, '') : type}",
1216
1216
  sub: { pat: /\A(\d+)(.+)\z/, styles: styles })
1217
1217
  else
1218
1218
  puts empty_status("No #{type} were #{action}", 'grep', grep.is_a?(Array) ? case grep.size
@@ -265,10 +265,12 @@ module Squared
265
265
  end
266
266
 
267
267
  def append_pip(flag, opts, target: @session, from: nil)
268
- append_nocolor(target: target)
269
- return [] unless from && !opts.empty?
270
-
268
+ if !from || opts.empty?
269
+ append_global(target: target)
270
+ return []
271
+ end
271
272
  opts, pat = option_sanitize(opts, OPT_PIP[from] + OPT_PIP[:common], target: target)
273
+ append_global(target: target)
272
274
  out = []
273
275
  edit = nil
274
276
  opts.each do |opt|
@@ -302,18 +304,18 @@ module Squared
302
304
  end
303
305
  end
304
306
 
305
- def append_global
307
+ def append_global(target: @session)
306
308
  if (val = option('cache-dir'))
307
- cmd << case val
308
- when '0', 'false'
309
- '--no-cache-dir'
310
- else
311
- quote_option('cache-dir', basepath(val))
312
- end
309
+ target << case val
310
+ when '0', 'false'
311
+ '--no-cache-dir'
312
+ else
313
+ quote_option('cache-dir', basepath(val))
314
+ end
313
315
  end
314
- cmd << shell_option('proxy', val) if (val = option('proxy'))
315
- cmd << quote_option('python', basepath(val)) if (val = option('python'))
316
- append_nocolor
316
+ target << shell_option('proxy', val) if (val = option('proxy'))
317
+ target << quote_option('python', basepath(val)) if (val = option('python'))
318
+ append_nocolor(target: target)
317
319
  end
318
320
  end
319
321
 
@@ -7,7 +7,7 @@ module Squared
7
7
  GEMFILE = %w[Gemfile Gemfile.lock gem.deps.rb Isolate].freeze
8
8
  DIR_RUBY = (GEMFILE + Rake::Application::DEFAULT_RAKEFILES + ['README.rdoc']).freeze
9
9
  OPT_BUNDLE = {
10
- common: %w[no-color V verbose retry=i].freeze,
10
+ common: %w[no-color V|verbose retry=i].freeze,
11
11
  install: %w[frozen no-cache no-prune system path=p binstubs=p? standalone=q? target-rbconfig=p trust-policy=b
12
12
  with=q without=q].freeze,
13
13
  install_base: %w[full-index quiet retry gemfile=p j|jobs=i].freeze,
@@ -342,7 +342,8 @@ module Squared
342
342
 
343
343
  def update(flag, opts = [])
344
344
  bundle_session 'update', "--#{flag}"
345
- append_bundle opts, OPT_BUNDLE[:install_base] + OPT_BUNDLE[:update] + OPT_BUNDLE[:common]
345
+ append_bundle(opts, OPT_BUNDLE[:install_base] + OPT_BUNDLE[:update] + OPT_BUNDLE[:common],
346
+ append: flag != :all)
346
347
  run_rb(from: :update)
347
348
  end
348
349
 
@@ -366,8 +367,11 @@ module Squared
366
367
  when :install, :'user-install', :update
367
368
  list += OPT_GEM[:shared]
368
369
  no = OPT_GEM[:shared_no]
370
+ first = true
371
+ when :pristine
372
+ first = true
369
373
  end
370
- opts, pat = option_sanitize(opts, list, no: no, first: true)
374
+ opts, pat = option_sanitize(opts, list, no: no, first: first)
371
375
  out = []
372
376
  opts.each do |opt|
373
377
  if opt =~ pat
@@ -502,7 +506,7 @@ module Squared
502
506
  cmd = bundle_session flag
503
507
  case flag
504
508
  when 'exec', 'check'
505
- args = option_sanitize(args, OPT_BUNDLE[flag.to_sym] + OPT_BUNDLE[:common]).first
509
+ args = option_sanitize(args, OPT_BUNDLE[flag.to_sym] + OPT_BUNDLE[:common], args: flag == :exec).first
506
510
  end
507
511
  raise_error('bundle', flag, hint: 'no command given') unless !args.empty? || flag == 'check'
508
512
  cmd.merge(args)
@@ -511,7 +515,7 @@ module Squared
511
515
 
512
516
  def rake(*cmd)
513
517
  if cmd.empty?
514
- run_s(rake_output(rakeapp), from: :rake, chdir: workspace.pwd)
518
+ run_s(rake_output(rakeapp), from: :rake, chdir: workspace.pwd, banner: false)
515
519
  else
516
520
  cmd = cmd.flatten.map { |val| rake_output(rakeapp, val) }
517
521
  run_s(cmd, from: :rake, chdir: workspace.pwd, banner: false)
@@ -588,9 +592,13 @@ module Squared
588
592
  run(banner: !@session.include?('--quiet'), **kwargs)
589
593
  end
590
594
 
591
- def append_bundle(opts, list, target: @session)
595
+ def append_bundle(opts, list, target: @session, append: false)
592
596
  out = option_sanitize(opts, list, target: target).first
593
- option_clear(out, target: target)
597
+ if append
598
+ append_value(out, target: target, escape: true)
599
+ else
600
+ option_clear(out, target: target)
601
+ end
594
602
  end
595
603
 
596
604
  def gem_session(*cmd, **kwargs)
@@ -651,7 +659,7 @@ module Squared
651
659
  end
652
660
 
653
661
  def rakeapp
654
- quote_option 'rakefile', Rake.application.rakefile
662
+ quote_option 'f', rakefile
655
663
  end
656
664
 
657
665
  def rakepwd
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squared
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-03-12 00:00:00.000000000 Z
10
+ date: 2025-04-09 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rake