squared 0.7.14 → 0.8.0

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.
@@ -226,10 +226,9 @@ module Squared
226
226
  serve_set kwargs[:serve]
227
227
  gemfile_set kwargs[:gemspec]
228
228
  self.autodetect = autodetect
229
- @bundle = { exec: exec }
229
+ @bundle = { exec: exec.is_a?(String) ? basepath!(exec) : false }
230
230
  @steepfile = basepath! steep if steep
231
- rubocop = rootpath('.rubocop.yml', ascend: Dir.home) if rubocop == true
232
- @rubocopfile = basepath! rubocop if rubocop
231
+ @rubocopfile = Pathname.new(rubocop).realpath rescue basepath!(Dir.home, '.rubocop.yml') if rubocop
233
232
  @rubygems = kwargs.fetch(:rubygems, 0)
234
233
  return unless rakefile && @output[0].nil? && @copy.nil? && !version && !self.autodetect
235
234
 
@@ -383,7 +382,7 @@ module Squared
383
382
  if val.include?('*')
384
383
  out.concat(Dir.glob(val, base: path))
385
384
  elsif !(file = basepath!(val))
386
- print_error(val, hint: 'not found')
385
+ print_error('file not found', hint: val)
387
386
  elsif file.directory?
388
387
  out.concat(file.glob('**/*.rb'))
389
388
  else
@@ -439,17 +438,18 @@ module Squared
439
438
  when 'gem'
440
439
  case flag
441
440
  when :outdated
442
- format_desc action, flag, "semver?=major|minor|patch,#{shortname('i', 's', 'u', 'd')},opts*"
441
+ format_desc action, flag, "semver?=(=)major|minor|patch,#{shortname('i', 's', 'u', 'd')},opts*"
443
442
  task flag, [:semver] do |_, args|
444
- opts = case (semver = args.semver)
445
- when 'major', 'minor', 'patch'
443
+ opts = if args.semver =~ /^(=)?(major|minor|patch)$/i
444
+ equals = !$1.nil?
445
+ semver = $2.downcase
446
446
  args.extras
447
447
  else
448
- semver = nil
449
448
  args.to_a
450
449
  end
451
450
  gem(flag, opts: opts, banner: true, filter: {
452
451
  semver: semver,
452
+ equals: equals,
453
453
  update: has_value!(opts, 'u', 'update'),
454
454
  interactive: has_value!(opts, 'i', 'interactive'),
455
455
  select: has_value!(opts, 's', 'select'),
@@ -507,22 +507,16 @@ module Squared
507
507
  format_desc action, flag, 'f/orce?,l/ocal?,opts*'
508
508
  task flag do |_, args|
509
509
  opts = args.to_a
510
- opts << 'local' if has_value!(opts, 'l', 'local')
510
+ opts << 'local' if has_value!(opts, 'l')
511
511
  opts << 'redownload' if has_value!(opts, 'f', 'force')
512
512
  if (lock = basepath!('Gemfile.lock'))
513
- case (val = ENV['BUNDLE_FROZEN'])
514
- when '0', 'false' then nil
515
- else
516
- if val
517
- print_error("BUNDLE_FROZEN: #{val}", loglevel: Logger::INFO, subject: name, hint: flag)
513
+ config = basepath '.bundle', 'config'
514
+ if config.exist? && config.read.match?(/\bBUNDLE_FROZEN:\s+"true"/)
515
+ if opts.include?('redownload')
516
+ run(bundle_output('config unset frozen'), banner: false)
517
+ else
518
+ print_error('Gemfile.lock is frozen', subject: name, hint: flag)
518
519
  lock = nil
519
- elsif basepath!('.bundle', 'config')&.read&.match?(/\bBUNDLE_FROZEN:\s+"true"/)
520
- if opts.include?('redownload')
521
- run(bundle_output('config unset frozen'), banner: false)
522
- else
523
- print_error('Gemfile.lock is frozen', subject: name, hint: flag)
524
- lock = nil
525
- end
526
520
  end
527
521
  end
528
522
  lock&.delete
@@ -569,7 +563,7 @@ module Squared
569
563
  else
570
564
  %w[## ;]
571
565
  end
572
- msg = if Readline.respond_to?(:readmultiline)
566
+ msg = if Prompt.reline.respond_to?(:readmultiline)
573
567
  'ruby>'
574
568
  else
575
569
  multiline = Array(multiline)
@@ -698,9 +692,9 @@ module Squared
698
692
  .lines
699
693
  .map { |line| line.sub(/#.*$/, '').strip }
700
694
  .reject(&:empty?)
701
- .yield_self do |data|
702
- target = data.find { |line| line.include?(tool) }
703
- target ? [target] : data
695
+ .yield_self do |lines|
696
+ target = lines.find { |line| line.include?(tool) }
697
+ target ? [target] : lines
704
698
  end
705
699
  .join(', ')
706
700
  end
@@ -734,7 +728,7 @@ module Squared
734
728
  out.map!(&:split)
735
729
  pad = as_a(out, :first, :size).max
736
730
  print_item
737
- puts(out.map { |line| '%*s %s' % [pad, line.first, line[1..-1].join(' ')] })
731
+ puts(out.map { |line| '%*s %s' % [pad, line.first, line.drop(1).join(' ')] })
738
732
  end
739
733
  end
740
734
  when :reshim
@@ -782,7 +776,8 @@ module Squared
782
776
  next if val == '0' || val == 'false'
783
777
 
784
778
  run(bundle_output('binstubs --all', case val
785
- when '1', 'true' then nil
779
+ when '1', 'true'
780
+ nil
786
781
  else
787
782
  if val.start_with?('~')
788
783
  val = File.join(Dir.home, val == '~' ? '.bundle' : val[1..-1])
@@ -1073,7 +1068,7 @@ module Squared
1073
1068
  buffer = []
1074
1069
  filter = kwargs.fetch(:filter, {})
1075
1070
  semver = filter[:semver]
1076
- dryrun = filter[:dryrun] || dryrun?(prefix: 'gem')
1071
+ equals = filter[:equals]
1077
1072
  update = if sync && filter[:select]
1078
1073
  semver ||= 'major'
1079
1074
  items = []
@@ -1150,6 +1145,8 @@ module Squared
1150
1145
  when 2
1151
1146
  case semver
1152
1147
  when 'major', 'minor'
1148
+ next if equals && semver == 'major'
1149
+
1153
1150
  update&.push(a)
1154
1151
  when 'patch'
1155
1152
  next
@@ -1163,6 +1160,8 @@ module Squared
1163
1160
  else
1164
1161
  case semver
1165
1162
  when 'major', 'minor', 'patch'
1163
+ next if equals && semver != 'patch'
1164
+
1166
1165
  update&.push(a)
1167
1166
  end
1168
1167
  unless stdin?
@@ -1226,7 +1225,7 @@ module Squared
1226
1225
  'user-install'
1227
1226
  end
1228
1227
  end
1229
- if dryrun
1228
+ if filter[:dryrun]
1230
1229
  print_run gem_output('update -f', *update.quote!(escape: true)), false
1231
1230
  else
1232
1231
  gem(:update, *update, opts: opts)
@@ -1261,26 +1260,36 @@ module Squared
1261
1260
  case flag
1262
1261
  when :build
1263
1262
  if op.empty?
1264
- raise_error Errno::ENOENT, 'gemspec', hint: project unless gemfile
1263
+ raise Errno::ENOENT, message('gemspec', hint: project) unless gemfile
1264
+
1265
1265
  op.add_path(gemfile)
1266
1266
  else
1267
- op.add_first(path: true)
1267
+ op.add_first(path: !op.first.include?('*'), quote: true)
1268
1268
  .clear(pass: false)
1269
1269
  end
1270
1270
  when :push
1271
- if op.empty? || ia
1272
- file = basepath(if !ia && (spec = gemspec)
1271
+ target = gemname
1272
+ if op.empty? || (n = op.index(':'))
1273
+ file = basepath(if !n && (spec = gemspec)
1273
1274
  "#{spec.name}-#{spec.version}.gem"
1274
1275
  else
1275
1276
  choice_index 'Select a file', Dir.glob('*.gem', base: path)
1276
1277
  end)
1278
+ op.add_path(file)
1279
+ elsif (file = op.shift).include?('*')
1280
+ file = '*.gem' if file == '*'
1281
+ target = Dir.glob(file, base: path).join(', ')
1282
+ raise Errno::ENOENT, message(file, hint: flag) if target.empty?
1283
+
1284
+ op.add_quote(file)
1277
1285
  else
1278
- file = basepath(op.shift.yield_self { |val| val.include?('.') ? val : "#{val}.gem" })
1279
- raise_error Errno::ENOENT, file, hint: flag unless file.exist?
1280
- raise_error ArgumentError, "unrecognized args: #{op.join(', ')}", hint: flag unless op.empty?
1286
+ file = basepath(file.include?('.') ? file : "#{file}.gem")
1287
+ raise Errno::ENOENT, message(file, hint: flag) unless file.exist?
1288
+ raise ArgumentError, message('unrecognized args', op.join(', '), hint: flag) unless op.empty?
1289
+
1290
+ op.add_path(file)
1281
1291
  end
1282
- op.add_path(file)
1283
- return run(from: from, interactive: ['Push', 'N', gemname]) unless with || !banner
1292
+ return run(from: from, interactive: ['Push', 'N', target]) unless with || !banner
1284
1293
  when :exec
1285
1294
  min = if op.arg?('g', 'gem')
1286
1295
  1
@@ -1336,7 +1345,8 @@ module Squared
1336
1345
  op.unshift(name)
1337
1346
  end
1338
1347
  end
1339
- raise_error ArgumentError, 'missing gem name', hint: flag if op.empty?
1348
+ raise ArgumentError, message('missing gem name', hint: flag) if op.empty?
1349
+
1340
1350
  if op.arg?('all')
1341
1351
  if flag == :pristine
1342
1352
  append_repeat 'skip', op.extras
@@ -1376,7 +1386,7 @@ module Squared
1376
1386
  op << action
1377
1387
  op.clear
1378
1388
  else
1379
- raise_error ArgumentError, "unrecognized arg: #{action}", hint: flag
1389
+ raise ArgumentError, message('unrecognized command', action, hint: flag)
1380
1390
  end
1381
1391
  end
1382
1392
  when :open, :owner, :unpack, :yank
@@ -1413,7 +1423,7 @@ module Squared
1413
1423
  end
1414
1424
  end
1415
1425
  opts = session_opts(with, args: args, kwargs: kwargs, pass: pass)
1416
- invalid = ->(a) { raise_error ArgumentError, "unrecognized args: #{a.join(', ')}", hint: flag }
1426
+ invalid = ->(a) { raise ArgumentError, message('unrecognized args', a.join(', '), hint: flag) }
1417
1427
  cmd = bundle_session flag
1418
1428
  case flag
1419
1429
  when :cache, :check, :clean, :init, :install, :lock, :pack, :package, :platform
@@ -1564,7 +1574,7 @@ module Squared
1564
1574
 
1565
1575
  def rdbg(*args, banner: verbose?, with: nil, pass: PASS_RUBY[:rdbg], **kwargs)
1566
1576
  opts = session_opts(with, args: args, kwargs: kwargs, pass: pass)
1567
- cmd = session(*bundle_args('rdbg'))
1577
+ cmd = session 'rdbg'
1568
1578
  args.each_with_index do |val, index|
1569
1579
  break if val == '--'
1570
1580
  next unless exist?(val, type: 'f')
@@ -1738,7 +1748,7 @@ module Squared
1738
1748
  def project
1739
1749
  return @project unless @project.frozen?
1740
1750
 
1741
- @project = ((spec = gemspec) ? spec.name : @project).dup
1751
+ @project = (gemspec&.name || @project).dup
1742
1752
  end
1743
1753
 
1744
1754
  def depend?
@@ -1833,8 +1843,8 @@ module Squared
1833
1843
  private
1834
1844
 
1835
1845
  def run_repl(*args, opts:, banner:, from:, delim: true, **kwargs)
1836
- op = OptionPartition.new(opts, OPT_RUBY[from], session(*bundle_args(from)),
1837
- project: self, strict: strict?, first: [/\.rb$/])
1846
+ op = OptionPartition.new(opts, OPT_RUBY[from], session(*bundle_args(from)), project: self, strict: strict?,
1847
+ first: [/\.rb$/])
1838
1848
  r = []
1839
1849
  r << 'bundler/setup' if !op.arg?('r') && bundle_load
1840
1850
  r.concat(Array(kwargs[:name])) if kwargs[:name]
@@ -1847,7 +1857,7 @@ module Squared
1847
1857
  end
1848
1858
 
1849
1859
  def ruby_session(*cmd, **kwargs)
1850
- session(*bundle_args('ruby'), *preopts, *cmd, **kwargs)
1860
+ session('ruby', *preopts, *cmd, **kwargs)
1851
1861
  end
1852
1862
 
1853
1863
  def gem_session(*cmd, **kwargs)
@@ -1865,10 +1875,11 @@ module Squared
1865
1875
  end
1866
1876
 
1867
1877
  def rbs_session(*cmd, opts: nil)
1868
- return session(*bundle_args('rbs'), *cmd) unless opts
1878
+ args = bundle_args 'rbs'
1879
+ return session(*args, *cmd) unless opts
1869
1880
 
1870
1881
  op = OptionPartition.new(opts, OPT_RUBY[:rbs], project: self, strict: strict?)
1871
- [session(*bundle_args('rbs'), *op.to_a, *cmd), op.extras]
1882
+ [session(*args, *op.to_a, *cmd), op.extras]
1872
1883
  end
1873
1884
 
1874
1885
  def gem_output(*cmd, **kwargs)
@@ -1876,7 +1887,7 @@ module Squared
1876
1887
  end
1877
1888
 
1878
1889
  def ruby_output(*cmd, **kwargs)
1879
- session_output(*bundle_args('ruby'), *cmd, **kwargs)
1890
+ session_output('ruby', *cmd, **kwargs)
1880
1891
  end
1881
1892
 
1882
1893
  def bundle_output(*cmd, **kwargs)
@@ -1889,20 +1900,7 @@ module Squared
1889
1900
 
1890
1901
  def bundle_args(*args)
1891
1902
  if (val = @bundle[:exec])
1892
- app = args.first
1893
- if val.is_a?(Hash)
1894
- env = val[app.to_s] || val[app.to_sym]
1895
- return args unless env
1896
-
1897
- val = env.is_a?(String) ? basepath!(env) : true
1898
- elsif app == 'ruby'
1899
- return args
1900
- end
1901
- if val.is_a?(String)
1902
- return args unless (val = basepath!(val))
1903
-
1904
- args.unshift("--gemfile=#{shell_escape(val.relative_path_from(path), quote: true)}")
1905
- end
1903
+ args.unshift(quote_option('gemfile', val)) unless val == true
1906
1904
  args.unshift('bundle', 'exec')
1907
1905
  end
1908
1906
  args
@@ -1934,7 +1932,8 @@ module Squared
1934
1932
  val = case (val = $2)
1935
1933
  when 'true'
1936
1934
  true
1937
- when '', '[]' then nil
1935
+ when '', '[]'
1936
+ nil
1938
1937
  else
1939
1938
  if val =~ /\A\[:(.+)\]\z/
1940
1939
  $1.split(', :').map { |s| (s[/\A"(.+)"\z/, 1] || s).to_sym }
@@ -1966,10 +1965,6 @@ module Squared
1966
1965
  verbose? ? ['--verbose'] : []
1967
1966
  end
1968
1967
 
1969
- def variables
1970
- (super + %i[autodetect]).freeze
1971
- end
1972
-
1973
1968
  def rakefile
1974
1969
  if @rakefile.nil?
1975
1970
  file = Rake::Application::DEFAULT_RAKEFILES.find { |val| exist?(val) }
@@ -125,8 +125,8 @@ module Squared
125
125
  extras.concat(if n == 0
126
126
  data
127
127
  else
128
- super(data[0, n])
129
- data[n..-1]
128
+ super(data.take(n))
129
+ data.drop(n)
130
130
  end)
131
131
  self
132
132
  else
@@ -20,8 +20,8 @@ module Squared
20
20
  include Shell
21
21
  include Prompt
22
22
 
23
- def append(target, *args, delim: false, escape: false, quote: true, strip: nil, force: true, double: false,
24
- filter: nil, pass: nil, preserve: true, **)
23
+ def append(target, *args, delim: false, escape: false, quote: true, strip: nil, double: false, filter: nil,
24
+ pass: nil, **kwargs)
25
25
  return if (ret = args.flatten(1)).empty?
26
26
 
27
27
  target << '--' if delim && !target.include?('--')
@@ -52,7 +52,7 @@ module Squared
52
52
  if !(pa = val.is_a?(Pathname)) && escape
53
53
  shell_escape(val, quote: quote, double: double)
54
54
  elsif quote || pa
55
- shell_quote(val, force: force, double: double, preserve: preserve)
55
+ shell_quote(val, double: double, **kwargs)
56
56
  else
57
57
  val
58
58
  end
@@ -87,25 +87,8 @@ module Squared
87
87
 
88
88
  def strip(val)
89
89
  val = shell_split val if val.is_a?(String)
90
- ret = []
91
- pass = -1
92
- (args = Array(val)).each_with_index do |s, i|
93
- next if s.empty? || pass == i
94
-
95
- if s == '--'
96
- ret << s << args[i.succ..-1].join(' ')
97
- break
98
- end
99
- next ret << s unless s.start_with?('-')
100
-
101
- if !s.include?('=') && (j = args[i.succ]) && !j.start_with?('-')
102
- ret << "#{s.sub(/^-{1,2}/, '')}=#{j}"
103
- pass = i.succ
104
- else
105
- ret << s.sub(OPT_SINGLE, '\1=\2').sub(OPT_VALUE, '\1=\2').sub(OPT_NAME, '\2')
106
- end
107
- end
108
- ret
90
+ Array(val).map { |s| s.sub(OPT_SINGLE, '\1=\2').sub(OPT_VALUE, '\1=\2').sub(OPT_NAME, '\2') }
91
+ .reject(&:empty?)
109
92
  end
110
93
 
111
94
  def select(list, bare: true, no: true, single: false, double: false)
@@ -152,7 +135,7 @@ module Squared
152
135
  [name, $3, $2 || (name.size == 1 && $1.empty? ? true : '')]
153
136
  end
154
137
 
155
- def arg?(target, *args, value: false, **)
138
+ def arg?(target, *args, value: false)
156
139
  r, s = args.partition { |val| val.is_a?(Regexp) }
157
140
  r << matchopts(s, value) unless s.empty?
158
141
  a = target.to_a
@@ -169,11 +152,8 @@ module Squared
169
152
  end
170
153
 
171
154
  def pattern?(val)
172
- Regexp.new(val)
173
155
  val.start_with?('\A', '^') || val.end_with?('\z', '$') ||
174
156
  val.match?(/[.)][*+?]|\(\?[:=!><]|\\[dsw\d]|\[.+\]|\{\d+,?\d*\}/i)
175
- rescue RegexpError
176
- false
177
157
  end
178
158
 
179
159
  private
@@ -271,13 +251,13 @@ module Squared
271
251
  else
272
252
  [flag]
273
253
  end
274
- bare.concat(mod) if val.chomp!('?')
275
- m.concat(mod) if val.chomp!('m')
276
254
  case val[n.succ]
277
255
  when 'e'
278
256
  e.concat(mod)
279
257
  when 'b'
280
258
  b.concat(mod)
259
+ when 'm'
260
+ m.concat(mod)
281
261
  when 'q'
282
262
  qq.concat(mod) if val[n + 2] == 'q'
283
263
  q.concat(mod)
@@ -296,7 +276,11 @@ module Squared
296
276
  when '+'
297
277
  ml.concat(mod)
298
278
  bare.concat(mod)
279
+ else
280
+ next
299
281
  end
282
+ m.concat(mod) if val[n + 2] == 'm'
283
+ bare.concat(mod) if val.end_with?('?')
300
284
  else
301
285
  bare << val
302
286
  mod = [val]
@@ -331,7 +315,7 @@ module Squared
331
315
  end
332
316
  numtype = [
333
317
  [i, /\A\d+\z/],
334
- [f, /\A(\d+(\.\d*)?|\d*\.\d+)\z/],
318
+ [f, /\A\d*(\.\d+)?\z/],
335
319
  [si, /\A-?\d+\z/]
336
320
  ].freeze
337
321
  numcheck = ->(k, v) { numtype.any? { |flag, pat| flag.include?(k) && v.match?(pat) } }
@@ -364,10 +348,6 @@ module Squared
364
348
  if opt =~ OPT_VALUE
365
349
  key = $1
366
350
  val = $2
367
- if val =~ /\A(["'])(.+)\1\z/
368
- val = $2
369
- double = $1 == '"'
370
- end
371
351
  has = lambda do |a|
372
352
  return true if a.include?(key)
373
353
  return false unless (k = a.find { |s| s.end_with?(':*') })
@@ -375,14 +355,12 @@ module Squared
375
355
  key.start_with?(k.chomp('*')) && !key.end_with?(':')
376
356
  end
377
357
  kwargs = { sep: se[key] || sep, merge: has.call(m), switch: sw[key] }
378
- kwargs[:double] = double unless double.nil?
379
358
  if has.call(e) || (has.call(bl) && %w[true false].include?(val))
380
359
  add shell_option(key, val, **kwargs)
381
360
  elsif has.call(q)
382
- kwargs[:double] = true if has.call(qq)
383
- add quote_option(key, val, **kwargs)
361
+ add quote_option(key, val, double: has.call(qq), **kwargs)
384
362
  elsif has.call(p)
385
- if !double.nil?
363
+ if val.match?(/\A(["']).+\1\z/)
386
364
  add shell_option(key, val, escape: false, **kwargs)
387
365
  elsif path
388
366
  add quote_option(key, path + val, **kwargs)
@@ -631,7 +609,7 @@ module Squared
631
609
  val = OptionPartition.send(:matchopts, val) unless val.is_a?(Regexp)
632
610
  blk = proc { |s| s&.match?(val) }
633
611
  else
634
- raise TypeError, "unknown: #{val}"
612
+ raise TypeError, Common::Format.message('unknown', val, hint: target.first)
635
613
  end
636
614
  end
637
615
  ret = find_all(&blk)
@@ -680,10 +658,7 @@ module Squared
680
658
 
681
659
  def readline(msg, fallback = nil, option: nil, quote: false, force: true, double: false)
682
660
  begin
683
- require 'readline' unless defined?(Readline)
684
- ret = Readline.readline("#{msg}#{force ? ':' : '?'} ", false).strip
685
- rescue LoadError
686
- raise unless (ret = fallback) || !force
661
+ ret = Common::Prompt.reline.readline("#{msg}#{force ? ':' : '?'} ", false).strip
687
662
  rescue Interrupt
688
663
  exit(force ? 1 : 0)
689
664
  else
@@ -7,6 +7,15 @@ module Squared
7
7
  module Utils
8
8
  private
9
9
 
10
+ def symjoin(*args, char: ':')
11
+ args.flatten.join(char).to_sym
12
+ end
13
+
14
+ def collect_hash(data, pass: [])
15
+ data = data.reject { |key,| pass.include?(key) } unless pass.empty?
16
+ data.values.flatten
17
+ end
18
+
10
19
  def rand_s(size)
11
20
  require 'random/formatter'
12
21
  Random.new.alphanumeric(size)
@@ -26,29 +35,13 @@ module Squared
26
35
  end
27
36
  end
28
37
 
29
- def matchmap(list, prefix = nil, negate: false)
30
- ret = negate ? [[], []] : []
31
- list.each do |val|
32
- unless val.is_a?(Regexp)
33
- val = val.dup
34
- n = 1 if negate && val.delete_prefix!('!')
35
- if prefix
36
- a = nil
37
- val.sub!(/\A(\^|\\A)/) do |s|
38
- a = s
39
- nil
40
- end
41
- val = ".*#{val}" unless a
42
- end
43
- end
44
- pat = Regexp.new("#{a}#{prefix}#{val == '*' ? '.+' : val}")
45
- if negate
46
- ret[n || 0] << pat
47
- else
48
- ret << pat
49
- end
38
+ def matchmap(list, prefix: nil)
39
+ list.map do |val|
40
+ next val if val.is_a?(Regexp)
41
+
42
+ val = ".*#{val}" if prefix && !val.sub!(/\A(\^|\\A)/, '')
43
+ Regexp.new("#{prefix}#{val == '*' ? '.+' : val}")
50
44
  end
51
- ret
52
45
  end
53
46
 
54
47
  def matchany?(list, *args, empty: true)
@@ -20,7 +20,7 @@ module Squared
20
20
  elsif !repo_install? && !repo_confirm
21
21
  @root = nil
22
22
  end
23
- raise_error Errno::EEXIST, path.cleanpath, hint: 'REPO_HOME' unless @root
23
+ raise Errno::EEXIST, message(path.cleanpath, hint: 'REPO_HOME') unless @root
24
24
  end
25
25
  path.realdirpath
26
26
  elsif (val = env('REPO_ROOT'))
@@ -28,7 +28,7 @@ module Squared
28
28
  if !@root.exist?
29
29
  @root.mkpath
30
30
  elsif !repo_install?(parent: true) && !repo_confirm
31
- raise_error Errno::EEXIST, @root, hint: 'REPO_ROOT'
31
+ raise Errno::EEXIST, message(@root, hint: 'REPO_ROOT')
32
32
  end
33
33
  @root.join(main).realdirpath
34
34
  elsif repo_install?(parent: true) && (!home.exist? || @root + main == home)
@@ -157,6 +157,8 @@ module Squared
157
157
  [proj, proj.build? && (script || run), doc && proj.doc?, lint && proj.lint?, test && proj.test?]
158
158
  end
159
159
  .select do |proj, run, doc, lint, test|
160
+ next unless proj
161
+
160
162
  proj.doc(sync: true) if doc
161
163
  proj.build(sync: true) if run
162
164
  next if n.anybits?(4)
@@ -184,7 +186,8 @@ module Squared
184
186
  end
185
187
  env('REPO_GROUPS', **envargs) do |val|
186
188
  g = case val
187
- when '0', 'false' then nil
189
+ when '0', 'false'
190
+ nil
188
191
  else
189
192
  val
190
193
  end
@@ -274,13 +277,13 @@ module Squared
274
277
  end
275
278
  end
276
279
 
277
- def repo_run(cmd, opts = [], exception: false, options: true, **kwargs)
280
+ def repo_run(cmd, opts = [], exception: exception?, options: true, **kwargs)
278
281
  cmd = [repo_bin, cmd]
279
282
  cmd << opts.uniq.join(' ') unless opts.empty?
280
283
  env('REPO_OPTIONS', **kwargs) { |val| cmd << val } if options
281
284
  cmd = cmd.join(' ')
282
285
  puts log_message(cmd, subject: main, hint: root) if verbose
283
- Common::System.shell(cmd, chdir: root, exception: exception || env('REPO_FAIL', equals: %w[1 true]))
286
+ Common::System.shell(cmd, chdir: root, exception: exception)
284
287
  end
285
288
 
286
289
  def repo_bin
@@ -307,7 +310,7 @@ module Squared
307
310
  r = r.keys
308
311
  pass = g.empty? && r.empty?
309
312
  select do |proj|
310
- next unless proj.enabled?(baseref)
313
+ next unless proj.enabled?(ref: baseref)
311
314
 
312
315
  proj.global_set(name)
313
316
  i = -1
@@ -338,7 +341,7 @@ module Squared
338
341
  task_invoke(name, **proj.workspace.invokeargs)
339
342
  end
340
343
  rescue => e
341
- raise if exception
344
+ raise if exception?
342
345
 
343
346
  warn log_warn(e, pass: true) if warning
344
347
  end
@@ -38,10 +38,18 @@ module Squared
38
38
  end
39
39
  end
40
40
  if (args = obj.batchargs)
41
- batch_set(*args)
41
+ if args.first.is_a?(Hash)
42
+ batch_set(obj.ref, *args)
43
+ else
44
+ batch_set(*args)
45
+ end
42
46
  end
43
47
  if (args = obj.aliasargs)
44
- alias_set(*args)
48
+ if args.first.is_a?(Hash)
49
+ alias_set(obj.ref, *args)
50
+ else
51
+ alias_set(*args)
52
+ end
45
53
  end
46
54
  end
47
55
  workspace.config_get(:batch)&.each { |args| batch_set(*args) }
@@ -209,9 +217,8 @@ module Squared
209
217
  already_invoked? parallel, val
210
218
  end
211
219
 
212
- def exclude?(key, fallback = false, empty: nil)
213
- fallback = empty unless empty.nil?
214
- @exclude.include?(key) || (fallback && (!key?(key) || self[key].empty?))
220
+ def exclude?(key, empty = false)
221
+ @exclude.include?(key) || (empty && (!key?(key) || self[key].empty?))
215
222
  end
216
223
 
217
224
  private
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.7.14
4
+ version: 0.8.0
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.23
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: []