squared 0.6.2 → 0.6.3

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.
@@ -507,7 +507,7 @@ module Squared
507
507
  b = dest + val
508
508
  c = glob[i] || glob.first
509
509
  log.info "cp #{a + c} #{b}"
510
- copy_dir(a, b, c, pass: pass, verbose: verbosetype > 0)
510
+ copy_dir(a, b, c, pass: pass, verbose: !silent?)
511
511
  rescue StandardError => e
512
512
  on_error e, :copy
513
513
  end
@@ -548,13 +548,13 @@ module Squared
548
548
  c = cur.join
549
549
  l = lat.join
550
550
  styles = []
551
- major_set = lambda do
551
+ ma = lambda do
552
552
  styles = %i[green bold]
553
553
  major += 1
554
554
  end
555
- minor_set = -> { styles[0] = cur[2] == lat[2] ? :yellow : :green }
555
+ mi = -> { styles[0] = cur[2] == lat[2] ? :yellow : :green }
556
556
  if data.empty?
557
- semmajor?(cur, lat) ? major_set.call : minor_set.call
557
+ semmajor?(cur, lat) ? ma.call : mi.call
558
558
  else
559
559
  data.each do |val|
560
560
  break unless line =~ /(>=?|=|~>|!=|<=?) (#{Regexp.escape(val.join)})/
@@ -562,11 +562,11 @@ module Squared
562
562
  v = semver(val).join
563
563
  case $1
564
564
  when '>', '>='
565
- semmajor?(cur, lat) ? major_set.call : minor_set.call
565
+ semmajor?(cur, lat) ? ma.call : mi.call
566
566
  when '<', '<='
567
567
  if c <= v
568
568
  if semmajor?(cur, lat)
569
- major_set.call
569
+ ma.call
570
570
  else
571
571
  styles[0] = :yellow
572
572
  end
@@ -592,14 +592,14 @@ module Squared
592
592
  unless styles.empty?
593
593
  case styles.first
594
594
  when :green
595
- line = sub_style(line, **opt_style(theme[styles.last == :bold ? :major : :active], /^(\S+)(.+)$/))
595
+ sub_style!(line, **opt_style(theme[styles.last == :bold ? :major : :active], /^(\S+)(.+)$/))
596
596
  found += 1
597
597
  when :yellow
598
598
  found += 1
599
599
  end
600
600
  l = Regexp.escape(l)
601
- line = sub_style(line, **opt_style(tc, /^(.+)(#{Regexp.escape(c)})(.+)$/, 2)) if tc
602
- line = sub_style(line, **opt_style(colormap(styles), /^((?:\S+\s+){2})(#{l})(.*)$/, 2))
601
+ sub_style!(line, **opt_style(tc, /^(.+)(#{Regexp.escape(c)})(.+)$/, 2)) if tc
602
+ sub_style!(line, **opt_style(colormap(styles), /^((?:\S+\s+){2})(#{l})(.*)$/, 2))
603
603
  end
604
604
  end
605
605
  items&.push([line, name])
@@ -799,8 +799,7 @@ module Squared
799
799
  when :build, :cert, :generate_index, :mirror, :outdated, :push, :server, :signin, :signout, :sources, :stale
800
800
  opts.concat(args)
801
801
  end
802
- op = OptionPartition.new(opts, gemopts(flag), gem_session(flag, *preopts), project: self,
803
- no: OPT_GEM[:no][flag])
802
+ op = OptionPartition.new(opts, gemopts(flag), gem_session(flag), project: self, no: OPT_GEM[:no][flag])
804
803
  from = :"gem:#{flag}"
805
804
  if flag == :outdated
806
805
  op.adjoin(gempwd, start: 0) if gempwd
@@ -848,6 +847,7 @@ module Squared
848
847
  e = 0
849
848
  f = 0
850
849
  j = 0
850
+ col4 = 0
851
851
  queue = nil
852
852
  rows.each do |row|
853
853
  a, b, c = row.first
@@ -861,14 +861,15 @@ module Squared
861
861
  a, b, c = row.first
862
862
  if i == 0
863
863
  line = '%-*s %-*s %*s %*s' % [pad, ' #', d, a, e, b, f, c]
864
- n = line.size
864
+ col4 = line.size
865
+ s = ARG[:BORDER][1] * col4
865
866
  queue = if stdin?
866
- [line, ARG[:BORDER][1] * n]
867
+ [line, s]
867
868
  else
868
869
  2.times do
869
- line = sub_style(line, **opt_style(theme[:header], /^(.+)(?<!\dm)(#{a}|#{c})(.*)$/, 2))
870
+ sub_style!(line, **opt_style(theme[:header], /^(.+)(?<!\dm)(#{a}|#{c})(.*)$/, 2))
870
871
  end
871
- [line, sub_style(ARG[:BORDER][1] * n, styles: borderstyle)]
872
+ [line, sub_style(s, borderstyle)]
872
873
  end
873
874
  else
874
875
  g = a.ljust(d)
@@ -884,7 +885,7 @@ module Squared
884
885
  next
885
886
  end
886
887
  unless stdin?
887
- g = sub_style(g, styles: theme[:major])
888
+ sub_style! g, theme[:major]
888
889
  styles = %i[green bold]
889
890
  pat = (pat.first if pre)
890
891
  latest << :bold
@@ -898,7 +899,7 @@ module Squared
898
899
  next
899
900
  end
900
901
  unless stdin?
901
- g = sub_style(g, styles: theme[:active])
902
+ sub_style! g, theme[:active]
902
903
  styles = %i[green]
903
904
  pat = pre ? pat.last : pat.first
904
905
  end
@@ -917,8 +918,8 @@ module Squared
917
918
  b = b.rjust(e)
918
919
  h = c.rjust(f)
919
920
  unless stdin?
920
- b = sub_style(b, **opt_style(colormap(styles), pat, 2))
921
- h = sub_style(h, **opt_style(latest.flatten.compact, pat, 2))
921
+ sub_style!(b, **opt_style(colormap(styles), pat, 2))
922
+ sub_style!(h, **opt_style(latest.flatten.compact, pat, 2))
922
923
  end
923
924
  j += 1
924
925
  if queue
@@ -931,7 +932,7 @@ module Squared
931
932
  else
932
933
  out.call('%*s %s' % [pad, "#{j}.", s])
933
934
  end
934
- update.delete(a) if ia && !confirm_outdated(a, c, row.last, timeout: 0)
935
+ update.delete(a) if ia && !confirm_outdated(a, c, row.last, col4: col4, timeout: 0)
935
936
  end
936
937
  end
937
938
  end
@@ -1257,7 +1258,7 @@ module Squared
1257
1258
  dir = basepath sig, file.dirname
1258
1259
  dir.mkpath unless dir.exist?
1259
1260
  base = file.basename.to_s
1260
- rbs = dir.join(base.stripext + '.rbs')
1261
+ rbs = dir.join("#{base.stripext}.rbs")
1261
1262
  status = if rbs.exist?
1262
1263
  case y
1263
1264
  when '0', 'false'
@@ -1394,18 +1395,11 @@ module Squared
1394
1395
  end
1395
1396
 
1396
1397
  def gem_session(*cmd, **kwargs)
1397
- ret = session('gem', *cmd, **kwargs)
1398
- return ret if cmd.empty?
1399
-
1400
- ret.merge(preopts)
1398
+ session('gem', *cmd, *preopts, **kwargs)
1401
1399
  end
1402
1400
 
1403
1401
  def bundle_session(*cmd, **kwargs)
1404
- ret = session('bundle', *cmd, **kwargs)
1405
- return ret if cmd.empty?
1406
-
1407
- append_nocolor
1408
- ret.merge(preopts)
1402
+ session('bundle', *cmd, *preopts, **kwargs).tap { append_nocolor }
1409
1403
  end
1410
1404
 
1411
1405
  def rake_session(*cmd, **kwargs)
@@ -1458,7 +1452,7 @@ module Squared
1458
1452
  end
1459
1453
 
1460
1454
  def preopts
1461
- verbose? && !session_arg?('quiet') ? ['--verbose'] : []
1455
+ verbose? ? ['--verbose'] : []
1462
1456
  end
1463
1457
 
1464
1458
  def variables
@@ -1538,8 +1532,7 @@ module Squared
1538
1532
  end
1539
1533
 
1540
1534
  def gemlib
1541
- @gemlib ||= begin
1542
- lib = Set.new(['lib'])
1535
+ @gemlib ||= Set.new(['lib']).yield_self do |lib|
1543
1536
  if (spec = gemspec)
1544
1537
  lib.merge(spec.require_paths || [])
1545
1538
  end
@@ -1552,7 +1545,9 @@ module Squared
1552
1545
  end
1553
1546
 
1554
1547
  def gemdir?
1555
- !@gemdir.nil? && @gemdir.exist? && !@gemdir.empty?
1548
+ return false unless @gemdir
1549
+
1550
+ @gemdir.exist? && !@gemdir.empty?
1556
1551
  end
1557
1552
  end
1558
1553