squared 0.6.8 → 0.6.9

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: f3fd4d34940e2ce81d6aff4d5bb9ccd827c8c11f755808778c0f266fc53fbf00
4
- data.tar.gz: 4a030838743ef95041fe4cd53a6a4491f9d5a5f89cca6dc1283c04429644cdc1
3
+ metadata.gz: bd07ce40c31b81be676defc0120ee1090e6bf020153b0234bcc9656e791279d3
4
+ data.tar.gz: e4179c5daf66d93a6795a3a15be28f93936d90da081fdfde2f779d05cddbc20e
5
5
  SHA512:
6
- metadata.gz: d4e1ddf573b20ea122f1b03d0c7d14ac23542d09aac252ae5eda2185a13a1e42fc32302b82896a6ca07ec6dfcf58dfed81dc3e009f2f7b8c2b8f4ba10fddfe5c
7
- data.tar.gz: 97bda796bfed20453137241f0f6cd98362d877fccc4674e1a1a0e615f1059ea8067d28a9f1d31e4a96b60c7fbb4011bb58ee05877e47ae3be0c41aea855bc872
6
+ metadata.gz: 437e260ef864d9734038ef84cf17bef22582d68f0081f4a8a7c4c16157bc32b3322673d2cb069ee84313b61243df30d65e3a3be432d613a2b977981e95b32aae
7
+ data.tar.gz: 02efccc2029b33cdfa91cf0da6454f7c9116e12320c7a378d8ccdf19d16a70414f36999fbf97bfd975ca24007c932e3d62d13753c4227ca565e6c569e3a36824
data/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.6.9] - 2025-01-07
4
+
5
+ ### Added
6
+
7
+ - Bundler command config can be executed without [set|get] actions.
8
+
9
+ ### Changed
10
+
11
+ - Application method with using hide and pass compatibility was implemented.
12
+
13
+ ## [0.5.21] - 2025-12-31
14
+
15
+ ### Fixed
16
+
17
+ - See `0.4.35`.
18
+
19
+ ## [0.4.35] - 2025-12-31
20
+
21
+ ### Changed
22
+
23
+ - Ruby task copy uses GEM_HOME as fallback for autodetect.
24
+
25
+ ### Fixed
26
+
27
+ - Git commands [rebase|clone] did not forward sync flag.
28
+ - Pip command install carelessly used an undefined method.
29
+ - Common prompt method readline with multiline did not permit empty lines.
30
+ - Application method with using pass did not ignore exceptions.
31
+ - Git method source did not check command object for supported method.
32
+
3
33
  ## [0.6.8] - 2025-12-26
4
34
 
5
35
  ### Added
@@ -1565,6 +1595,7 @@
1565
1595
 
1566
1596
  - Changelog was created.
1567
1597
 
1598
+ [0.6.9]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.9
1568
1599
  [0.6.8]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.8
1569
1600
  [0.6.7]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.7
1570
1601
  [0.6.6]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.6
@@ -1574,6 +1605,7 @@
1574
1605
  [0.6.2]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.2
1575
1606
  [0.6.1]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.1
1576
1607
  [0.6.0]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.0
1608
+ [0.5.21]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.21
1577
1609
  [0.5.20]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.20
1578
1610
  [0.5.19]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.19
1579
1611
  [0.5.18]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.18
@@ -1595,6 +1627,7 @@
1595
1627
  [0.5.2]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.2-ruby
1596
1628
  [0.5.1]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.1-ruby
1597
1629
  [0.5.0]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.0-ruby
1630
+ [0.4.35]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.35
1598
1631
  [0.4.34]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.34
1599
1632
  [0.4.33]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.33
1600
1633
  [0.4.32]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.32
@@ -261,6 +261,8 @@ module Squared
261
261
  lines = val.to_s.lines(chomp: true)
262
262
  lines[0] = "#{val.class}: #{lines.first}" if (err = val.is_a?(::StandardError))
263
263
  end
264
+ return if lines.empty?
265
+
264
266
  n = (cols.is_a?(::Array) ? cols.map(&:size).max : cols) || max.call(lines)
265
267
  if $stdout.tty?
266
268
  require 'io/console'
@@ -138,7 +138,11 @@ module Squared
138
138
  elsif block_given?
139
139
  Readline.readmultiline(msg, history, &blk)
140
140
  else
141
- Readline.readmultiline(msg, history) { |line| multiline.any? { |val| line.split.last.end_with?(val.to_s) } }
141
+ Readline.readmultiline(msg, history) do |line|
142
+ next if line.strip.empty?
143
+
144
+ multiline.any? { |val| line.split.last.end_with?(val.to_s) }
145
+ end
142
146
  end
143
147
  end
144
148
  case force
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.6.8'
4
+ VERSION = '0.6.9'
5
5
  end
@@ -201,8 +201,25 @@ module Squared
201
201
  self
202
202
  end
203
203
 
204
- def with(*val, pass: false, group: nil, **kwargs, &blk)
205
- return self if pass == true || (pass && as_a(pass, :to_s).any? { |s| respond_to?(s) && __send__(s) })
204
+ def with(*val, hide: nil, group: nil, **kwargs, &blk)
205
+ if hide.nil? && kwargs.key?(:pass)
206
+ pass = kwargs[:pass]
207
+ case pass
208
+ when true, false
209
+ hide = pass
210
+ kwargs.delete(:pass)
211
+ else
212
+ hide, pass = Array(pass).partition { |s| respond_to?(s) || s.to_s.end_with?('?') }
213
+ if pass.empty?
214
+ kwargs.delete(:pass)
215
+ elsif hide.empty?
216
+ hide = nil
217
+ else
218
+ kwargs[:pass] = pass
219
+ end
220
+ end
221
+ end
222
+ return self if hide == true || (hide && Array(hide).any? { |s| respond_to?(s) && __send__(s) rescue nil })
206
223
 
207
224
  @group = nil
208
225
  @ref = nil
@@ -508,7 +508,7 @@ module Squared
508
508
  end
509
509
 
510
510
  def build(*args, sync: invoked_sync?('build'), from: :run, **)
511
- banner = verbose
511
+ banner = !silent?
512
512
  if args.empty?
513
513
  return unless from == :run
514
514
 
@@ -716,7 +716,7 @@ module Squared
716
716
  end
717
717
 
718
718
  def unpack(target, file = nil, uri: nil, sync: true, digest: nil, ext: nil, force: false, depth: 1, headers: {},
719
- verbose: self.verbose, from: :unpack)
719
+ verbose: !silent?, from: :unpack)
720
720
  if !target.exist?
721
721
  target.mkpath
722
722
  elsif !target.directory?
@@ -1226,8 +1226,7 @@ module Squared
1226
1226
  run(val, var, sync: sync, banner: banner, **kwargs)
1227
1227
  end
1228
1228
  rescue StandardError => e
1229
- ret = on :error, from, e
1230
- raise unless ret == true
1229
+ on_error(e, from, exception: kwargs.fetch(:exception, exception))
1231
1230
  end
1232
1231
  on :last, from
1233
1232
  end
@@ -1277,6 +1276,8 @@ module Squared
1277
1276
  else
1278
1277
  items = data[target.name] - done
1279
1278
  end
1279
+ return done if items.empty?
1280
+
1280
1281
  if out
1281
1282
  a, b, c, d, e = ARG[:GRAPH]
1282
1283
  f = tag.call(target)
@@ -1370,8 +1371,8 @@ module Squared
1370
1371
  if (obj = workspace.find(name: val))
1371
1372
  obj.enabled? ? [obj] : []
1372
1373
  else
1373
- workspace.find(group: val, ref: val.to_sym)
1374
- end.sort.each do |proj|
1374
+ workspace.find(group: val, ref: val.to_sym).sort
1375
+ end.each do |proj|
1375
1376
  next if pass.include?(name = proj.name)
1376
1377
 
1377
1378
  if proj.graph? && !data.key?(name) && !root.include?(name)
@@ -1541,7 +1542,7 @@ module Squared
1541
1542
  end
1542
1543
 
1543
1544
  def print_run(cmd, banner = true, verbose: nil, **)
1544
- return if banner || !stdout? || verbose == false
1545
+ return if banner || !stdout? || verbose == false || env('BANNER', equals: '0')
1545
1546
 
1546
1547
  puts "\n> #{cmd}"
1547
1548
  printsucc
@@ -1725,7 +1726,9 @@ module Squared
1725
1726
  next if val.nil?
1726
1727
  end
1727
1728
  case val
1728
- when Array
1729
+ when Hash
1730
+ append_hash(val, target: target, build: build)
1731
+ when Enumerable
1729
1732
  append_repeat(key, val, target: target)
1730
1733
  when Numeric
1731
1734
  target << basic_option(key, val)
@@ -1809,10 +1812,10 @@ module Squared
1809
1812
  next unless data.key?(key)
1810
1813
 
1811
1814
  out[key] = case (val = data[key])
1812
- when Array
1813
- base.fetch(key, []) + val
1814
1815
  when Hash
1815
1816
  base.fetch(key, {}).update(val)
1817
+ when Enumerable
1818
+ Array(base.fetch(key, [])) + val.to_a
1816
1819
  else
1817
1820
  val
1818
1821
  end
@@ -2269,7 +2272,9 @@ module Squared
2269
2272
  end
2270
2273
  self.global = global
2271
2274
  case cmd
2272
- when Array
2275
+ when Hash
2276
+ @output = parse.call(data)
2277
+ when Enumerable
2273
2278
  @output = if cmd.all? { |data| data.is_a?(Hash) }
2274
2279
  noopt = false
2275
2280
  noenv = false
@@ -2278,8 +2283,6 @@ module Squared
2278
2283
  cmd.dup
2279
2284
  end
2280
2285
  return
2281
- when Hash
2282
- @output = parse.call(data)
2283
2286
  else
2284
2287
  @output[0] = cmd
2285
2288
  end
@@ -774,8 +774,8 @@ module Squared
774
774
  [cmd, status, no]
775
775
  end
776
776
 
777
- def list_image(flag, cmd = docker_output('image ls -a'), hint: nil, from: nil, no: true)
778
- pwd_set do
777
+ def list_image(flag, cmd = docker_output('image ls -a'), hint: nil, no: true, from: nil)
778
+ pwd_set(from: from) do
779
779
  index = 1
780
780
  all = option('all', prefix: 'docker')
781
781
  y = from == :'image:rm' && option('y', prefix: 'docker')
@@ -1075,7 +1075,7 @@ module Squared
1075
1075
 
1076
1076
  cmd << "--#{command}"
1077
1077
  end
1078
- source
1078
+ source(sync: sync)
1079
1079
  end
1080
1080
 
1081
1081
  def autostash(*, sync: invoked_sync?('autostash'), **)
@@ -1128,7 +1128,7 @@ module Squared
1128
1128
  append_hash opts
1129
1129
  cmd << '--quiet' if option('quiet') || !verbose
1130
1130
  append_value(data[0], path, delim: true)
1131
- source(banner: sync && !quiet?, multiple: !sync || quiet?)
1131
+ source(sync: sync, banner: sync && !quiet?, multiple: !sync || quiet?)
1132
1132
  end
1133
1133
 
1134
1134
  def stash(flag = nil, opts = [], sync: invoked_sync?('stash', flag))
@@ -1892,16 +1892,19 @@ module Squared
1892
1892
  banner = nil unless banner? && !multiple
1893
1893
  args = true
1894
1894
  end
1895
- if from.nil? && (from = cmd.drop(1).find { |val| val.match?(/\A[a-z]{1,2}[a-z-]*\z/) })
1896
- from = :"git:#{from}"
1897
- elsif from == false
1895
+ if from == false
1898
1896
  from = nil
1897
+ elsif !from && cmd.respond_to?(:drop)
1898
+ from = cmd.drop(1).find { |val| val.match?(/\A[a-z]{1,2}[a-z-]*\z/) }
1899
+ from &&= :"git:#{from}"
1899
1900
  end
1900
1901
  banner &&= cmd.temp { |val| val.start_with?(/--(?:work-tree|git-dir)/) } if cmd.respond_to?(:temp)
1901
1902
  end
1902
1903
  cmd = session_done cmd
1903
1904
  log&.info cmd
1904
- banner = format_banner(banner.is_a?(String) ? banner : cmd, hint: hint, strip: true) if banner
1905
+ banner = if banner
1906
+ format_banner(banner.is_a?(String) ? banner : cmd, hint: hint, strip: true)
1907
+ end
1905
1908
  on :first, from
1906
1909
  begin
1907
1910
  if io
@@ -1914,7 +1917,7 @@ module Squared
1914
1917
  raise(ret.empty? ? $?.to_s : ret) unless $?.success?
1915
1918
 
1916
1919
  if ret.empty?
1917
- success?(nil, !banner.nil?)
1920
+ success?(true, !banner.nil?)
1918
1921
  else
1919
1922
  puts ret
1920
1923
  end
@@ -1928,7 +1931,7 @@ module Squared
1928
1931
  n = write_lines(out, banner: banner, pass: true, **kwargs)
1929
1932
  if n == 0
1930
1933
  n = write_lines(err, banner: banner)
1931
- success?(nil, n == 0 && !banner.nil?)
1934
+ success?(n == 0, n == 0 && !banner.nil?)
1932
1935
  else
1933
1936
  write_lines(err, loglevel: Logger::DEBUG)
1934
1937
  end
@@ -877,7 +877,7 @@ module Squared
877
877
  log.info cmd.to_s
878
878
  end
879
879
  if sync
880
- run(from: from, sync: sync, interactive: !dryrun && ['Publish', 'N', npmname])
880
+ run(sync: sync, from: from, interactive: !dryrun && ['Publish', 'N', npmname])
881
881
  else
882
882
  require 'open3'
883
883
  on :first, from
@@ -1055,7 +1055,7 @@ module Squared
1055
1055
  raise_error 'version not found', hint: dependfile
1056
1056
  end
1057
1057
  rescue StandardError => e
1058
- on_error e, :bump
1058
+ on_error(e, :bump, dryrun: dryrun?)
1059
1059
  end
1060
1060
 
1061
1061
  def pack(opts = [])
@@ -404,7 +404,7 @@ module Squared
404
404
  cmd << "-r #{DEP_PYTHON[4]}" if exist?(DEP_PYTHON[4]) && !session_arg?('r', 'requirement')
405
405
  append_editable
406
406
  end
407
- run(from: :depend, sync: sync)
407
+ run(sync: sync, from: :depend)
408
408
  end
409
409
  end
410
410
 
@@ -48,7 +48,7 @@ module Squared
48
48
  cache: %w[frozen no-all no-install no-prune quiet cache-path=p gemfile=p].freeze,
49
49
  check: %w[dry-run gemfile=p path=p].freeze,
50
50
  clean: %w[dry-run force].freeze,
51
- config: %w[global local].freeze,
51
+ config: %w[global local skip-parseable].freeze,
52
52
  doctor: %w[quiet ssl gemfile=p].freeze,
53
53
  doctor_ssl: %w[host=q tls-version=b verify-mode=b].freeze,
54
54
  exec: %w[gemfile=p].freeze,
@@ -69,6 +69,7 @@ module Squared
69
69
  show: %w[outdated paths].freeze,
70
70
  update: %w[all conservative local major minor patch pre ruby strict bundler=b? g|group=q source=q].freeze,
71
71
  no: {
72
+ config: %w[parseable].freeze,
72
73
  gem: %w[changelog ci coc exe linter mit test].freeze
73
74
  }.freeze
74
75
  }.freeze
@@ -442,10 +443,10 @@ module Squared
442
443
  when :exec then 'command,args*|:'
443
444
  end)
444
445
  task flag do |_, args|
445
- bundle(flag, opts: args.to_a, banner: true)
446
+ bundle(flag, opts: args.to_a, banner: flag == :exec ? verbose? : true)
446
447
  end
447
448
  when :config
448
- format_desc action, flag, 'list|set|get|unset?,args*'
449
+ format_desc action, flag, 'list|set|get|unset?,opts*,args*'
449
450
  task flag do |_, args|
450
451
  bundle(flag, *args.to_a, banner: true)
451
452
  end
@@ -551,7 +552,7 @@ module Squared
551
552
  end
552
553
  end
553
554
  option('jobs') { |n| cmd << "-j#{n}" if n.to_i > 0 }
554
- run_rb(from: :depend, sync: sync)
555
+ run_rb(sync: sync, from: :depend)
555
556
  end
556
557
  end
557
558
 
@@ -765,41 +766,42 @@ module Squared
765
766
  order = { 'rbenv' => -1, 'rvm' => -1, 'asdf' => -1, 'chruby' => -1 }
766
767
  ENV.fetch('PATH', '').split(':').each_with_index do |val, index|
767
768
  order.each_key do |key|
768
- if val.match?(%r{[/.]#{key}/})
769
- order[key] = index
770
- break
771
- end
769
+ next unless val.match?(%r{[/.]#{key}/})
770
+
771
+ order[key] = index
772
+ break
772
773
  end
773
774
  end
774
- paths = [
775
- "#{ENV.fetch('RBENV_ROOT', '$HOME/.rbenv')}/bin/rbenv",
776
- '$HOME/.rvm/bin/rvm',
777
- @asdf ? "#{ENV.fetch('ASDF_DATA_DIR', '$HOME/.asdf')}/installs/#{@asdf.first}" : nil,
778
- '/usr/bin/rbenv',
779
- '/usr/local/rvm/bin/rvm',
780
- '/usr/share/rvm/bin/rvm',
781
- '/usr/local/share/chruby/chruby.sh'
782
- ].compact
783
- paths.sort do |a, b|
784
- c = -1
785
- d = -1
786
- order.each do |key, val|
787
- pat = %r{/\.?#{key}}
788
- c = val if a.match?(pat)
789
- d = val if b.match?(pat)
790
- end
791
- if c == d
792
- 0
793
- elsif c == -1
794
- 1
795
- elsif d == -1
796
- -1
797
- else
798
- c < d ? -1 : 1
775
+ if @asdf
776
+ [File.join(ENV.fetch('ASDF_DATA_DIR', '$HOME/.asdf'), "installs/#{@asdf.first}")]
777
+ else
778
+ [
779
+ "#{ENV.fetch('RBENV_ROOT', '$HOME/.rbenv')}/bin/rbenv",
780
+ '$HOME/.rvm/bin/rvm',
781
+ '/usr/bin/rbenv',
782
+ '/usr/local/rvm/bin/rvm',
783
+ '/usr/share/rvm/bin/rvm',
784
+ '/usr/local/share/chruby/chruby.sh'
785
+ ].sort do |a, b|
786
+ c = -1
787
+ d = -1
788
+ order.each do |key, val|
789
+ pat = %r{/\.?#{key}}
790
+ c = val if a.match?(pat)
791
+ d = val if b.match?(pat)
792
+ end
793
+ if c == d
794
+ 0
795
+ elsif c == -1
796
+ 1
797
+ elsif d == -1
798
+ -1
799
+ else
800
+ c < d ? -1 : 1
801
+ end
799
802
  end
800
- end
801
- .push('')
802
- .each do |val|
803
+ .push('')
804
+ end.each do |val|
803
805
  next unless val.empty? || File.exist?(val.sub('$HOME', Dir.home))
804
806
 
805
807
  trim = ->(s) { s[/^\D+\d+\.\d+(?:\.\S+)?/, 0].sub(/^([a-z]+)-/i, '\1 ') }
@@ -1258,15 +1260,27 @@ module Squared
1258
1260
  when :cache, :check, :clean, :init, :install, :lock, :pack, :package, :platform
1259
1261
  pre = true
1260
1262
  opts.concat(args)
1263
+ when :config
1264
+ if args.empty?
1265
+ pre = true
1266
+ else
1267
+ case (pre = args.shift)
1268
+ when 'list', 'get', 'set', 'unset'
1269
+ cmd << pre
1270
+ else
1271
+ args.unshift(pre)
1272
+ end
1273
+ opts.concat(args)
1274
+ end
1261
1275
  when :doctor
1262
1276
  case (pre = (val = args.shift) || opts.shift)
1263
1277
  when 'diagnose', 'ssl'
1264
1278
  cmd << pre
1265
1279
  else
1266
1280
  if val
1267
- args << val
1281
+ args.unshift(val)
1268
1282
  elsif pre
1269
- opts << pre
1283
+ opts.unshift(pre)
1270
1284
  end
1271
1285
  pre = true
1272
1286
  end
@@ -1286,54 +1300,57 @@ module Squared
1286
1300
  else
1287
1301
  flag
1288
1302
  end),
1289
- cmd, project: self, no: OPT_BUNDLE[:no][flag], args: flag == :exec)
1303
+ cmd,
1304
+ project: self, no: OPT_BUNDLE[:no][flag], args: flag == :exec || flag == :config)
1290
1305
  op.concat(args) unless pre
1291
1306
  output = false
1292
1307
  invalid = ->(a) { raise_error ArgumentError, "unrecognized args: #{a.join(', ')}", hint: flag }
1293
1308
  case flag
1294
1309
  when :config
1295
- if op.empty?
1296
- op << (val = readline('Enter arguments', force: false))
1297
- output = val.match?(/(?:un)?set/)
1298
- else
1310
+ if pre == 'list'
1311
+ op.clear
1312
+ elsif !op.empty?
1299
1313
  a = op.dup
1300
- b, c, d = op.slice!(0, 3)
1301
- e = op.arg?('global', 'local')
1302
- op << b
1303
- getname = -> { op << (c || readline('Enter name', force: true)) }
1304
- case b
1305
- when 'list'
1306
- nil
1314
+ b, c = op.slice!(0, 2)
1315
+ d = op.arg?('global', 'local')
1316
+ getname = -> { op << (b || readline('Enter name', force: true)) }
1317
+ case pre
1307
1318
  when 'get'
1308
1319
  getname.call
1309
1320
  when 'set'
1310
- if e
1311
- op << c
1312
- c = d
1313
- d = op.shift
1321
+ if d
1322
+ op << b
1323
+ b = c
1324
+ c = op.shift
1314
1325
  end
1315
1326
  getname.call
1316
- op << (d || readline('Enter value', force: true))
1327
+ op << (c || readline('Enter value', force: true))
1317
1328
  output = true
1318
1329
  when 'unset'
1319
- if e
1320
- op << c
1321
- c = d
1330
+ if d
1331
+ op << b
1332
+ b = c
1322
1333
  end
1323
1334
  getname.call
1324
1335
  output = true
1325
1336
  else
1326
- if b
1327
- op << b
1328
- if c
1329
- op.add_quote(c)
1330
- output = true
1331
- end
1337
+ if c && !op.arg?('parseable', 'no-parseable')
1338
+ op.adjoin('set') << b
1339
+ op.add_quote(c)
1340
+ output = true
1341
+ exit 1 unless confirm_basic('Confirm?', op, 'Y')
1342
+ elsif b
1343
+ op.adjoin('get') << b
1344
+ op.unshift(c) if c
1332
1345
  else
1333
1346
  invalid.call(a)
1334
1347
  end
1335
1348
  end
1336
1349
  op.clear
1350
+ else
1351
+ val = readline('Enter arguments', force: false)
1352
+ op << (val.empty? ? 'list' : val)
1353
+ output = val.match?(/^(un)?set/)
1337
1354
  end
1338
1355
  when :plugin
1339
1356
  case plu
@@ -1485,7 +1502,17 @@ module Squared
1485
1502
  def copy?
1486
1503
  return true if @copy.is_a?(Hash) ? copy[:into] : super
1487
1504
  return gemdir? if gemdir
1505
+ return false unless @autodetect
1488
1506
 
1507
+ set = lambda do |val, path|
1508
+ base = Pathname.new(path.strip)
1509
+ dir = base + gempath
1510
+ return false unless dir.writable? && base.join(gempath(val, 'specifications')).exist?
1511
+
1512
+ log.warn "using version #{val}".subhint("given #{version}") if version && version != val
1513
+ self.version = val
1514
+ self.gemdir = dir
1515
+ end
1489
1516
  if version
1490
1517
  begin
1491
1518
  case @autodetect
@@ -1496,36 +1523,23 @@ module Squared
1496
1523
  File.join($1, 'lib/ruby/gems', "#{$2}.0")
1497
1524
  end
1498
1525
  when 'asdf'
1499
- pwd_set { `asdf where ruby` }.yield_self do |val|
1526
+ pwd_set { `asdf where ruby`.chomp }.yield_self do |val|
1500
1527
  val =~ /(\d\.\d)\.[^.]+$/ && File.join(val, 'lib/ruby/gems', "#{$1}.0")
1501
1528
  end
1502
- when 'env'
1503
- ENV['GEM_HOME'] || ENV['GEM_ROOT']
1504
1529
  when /bundler?/
1505
1530
  pwd_set { `bundle env` }[/^\s+Gem Path\s+(.+)$/, 1].split(File::PATH_SEPARATOR).find do |val|
1506
- Dir.exist?(val)
1531
+ Dir.exist?(File.join(val, 'gems'))
1507
1532
  end
1508
- end.tap { |val| self.gemdir = val if val }
1533
+ else
1534
+ ENV['GEM_HOME'] || ENV['GEM_ROOT']
1535
+ end.tap do |val|
1536
+ return true if val && set.call(version, val)
1537
+ end
1509
1538
  rescue StandardError => e
1510
1539
  log.debug e
1511
1540
  end
1512
- return true if gemdir?
1513
- end
1514
- return false unless @autodetect
1515
-
1516
- set = lambda do |val, path|
1517
- base = Pathname.new(path.strip)
1518
- dir = base + gempath
1519
- return false unless dir.writable? && base.join(gempath(val, 'specification')).exist?
1520
-
1521
- log.warn "using version #{val}".subhint("given #{version}") if version && version != val
1522
- self.version = val
1523
- self.gemdir = dir
1524
- end
1525
- if version
1526
- opt = gempwd
1527
- pwd_set(pass: !opt.nil?) do
1528
- out = `#{gem_output(opt, 'list --local -d', gemname)}`
1541
+ pwd_set(pass: !gempwd.nil?) do
1542
+ out = `#{gem_output(gempwd, 'list --local -d', gemname)}`
1529
1543
  next unless out =~ /#{Regexp.escape(gemname)}\s+\((.+)\)$/
1530
1544
 
1531
1545
  split_escape($1)
@@ -587,10 +587,12 @@ module Squared
587
587
  elsif exclude.first.is_a?(Symbol)
588
588
  partition(&exclude.first)
589
589
  else
590
+ exclude.map! { |pat| Regexp.new(pat) }
590
591
  partition do |val|
591
- next false if pattern && OptionPartition.pattern?(val)
592
+ val = val.to_s
593
+ next if pattern && OptionPartition.pattern?(val)
592
594
 
593
- exclude.none? { |pat| val.match?(Regexp.new(pat)) }
595
+ exclude.none? { |pat| val.match?(pat) }
594
596
  end
595
597
  end
596
598
  unless temp.empty?
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.6.8
4
+ version: 0.6.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  requirements: []
127
- rubygems_version: 3.6.9
127
+ rubygems_version: 4.0.3
128
128
  specification_version: 4
129
129
  summary: Rake task generator for managing multi-language workspaces.
130
130
  test_files: []