squared 0.7.5 → 0.7.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.
@@ -8,7 +8,7 @@ module Squared
8
8
  GEMNAME = /\A[A-Za-z\d][A-Za-z\d_.-]*\z/.freeze
9
9
  DIR_RUBY = (GEMFILE + Rake::Application::DEFAULT_RAKEFILES + ['README.rdoc']).freeze
10
10
  OPT_RUBY = {
11
- 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
11
+ 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
12
12
  y|yydebug backtrace-limit=i crash-report=q disable=q dump=q enable=q encoding=b external-encoding=b
13
13
  internal-encoding=b parser=b].freeze,
14
14
  rake: %w[A|all B|build-all comments n|dry-run m|multitask P|prereqs q|quiet X|no-deprecation-warnings
@@ -16,14 +16,14 @@ module Squared
16
16
  D|describe=q? e|execute=q E|execute-continue=q p|execute-print=q f|rakefile=p job-stats=b? j|jobs=i?
17
17
  I|libdir=p R|rakelib=p rakelibdir=p r|require=b suppress-backtrace=q T|tasks=q? t|trace=b?
18
18
  W|where=q?].freeze,
19
- irb: %w[d f U w E=b I=p r=bm W=im? autocomplete colorize echo echo-on-assignment extra-doc-dir inf-ruby-mode
19
+ irb: %w[d f U w E=b I=pm r=bm W=im? autocomplete colorize echo echo-on-assignment extra-doc-dir inf-ruby-mode
20
20
  inspect multiline no-pager noautocomplete nocolorize noecho noecho-on-assignment noinspect
21
21
  nomultiline noprompt noscript nosingleline noverbose regexp-completor sample-book-mode script
22
22
  simple-prompt single-irb singleline tracer truncate-echo-on-assignment type-completor verbose
23
23
  back-trace-limit=i context-mode=i prompt=b prompt-mode=b].freeze,
24
24
  rdbg: %w[no-color no-rc no-sigint-hook c|command n|nonstop stop-at-load cookie=q e=q host=q x|init-script=p
25
25
  O|open=q? port=i port-range=b session-name=q sock-path=q util=q].freeze,
26
- rbs: %w[I=pm r=bm no-stdlib no-collection collection=p log-level=b log-output=p repo=p].freeze,
26
+ rbs: %w[I=pm r=bm no-collection no-stdlib collection=p log-level=b log-output=p repo=p].freeze,
27
27
  rubocop: %w[D P r=bm auto-gen-config a|autocorrect A|autocorrect-all d|debug disable-pending-cops
28
28
  display-only-correctable display-only-fail-level-offenses display-only-failed
29
29
  display-only-safe-correctable S|display-style-guide display-time editor-mode enable-pending-cops
@@ -34,8 +34,8 @@ module Squared
34
34
  start-server stderr stop-server C|cache=b cache-root=p config=p exclude-limit=i fail-level=b
35
35
  f|format=b except=q only=q o|out=p plugin=p require=p show-cops=q show-docs-url=q
36
36
  s|stdin=p].freeze,
37
- pry: %w[f I=pm no-color no-history no-multiline no-pager no-plugins simple-prompt c|context=q
38
- d|disable-plugin=q e=q gem=b r|require=bm s|select-plugin=q].freeze,
37
+ pry: %w[f e=q I=pm no-color no-history no-multiline no-pager no-plugins simple-prompt c|context=q
38
+ d|disable-plugin=q gem=b r|require=bm s|select-plugin=q].freeze,
39
39
  no: {
40
40
  rubocop: %w[auto-gen-enforced-style auto-gen-only-exclude auto-gen-timestamp color display-cop-names
41
41
  offense-counts parallel server].freeze
@@ -69,7 +69,7 @@ module Squared
69
69
  plugin: %w[source=q version=q].freeze,
70
70
  plugin_uninstall: %w[all].freeze,
71
71
  show: %w[paths].freeze,
72
- update: %w[all conservativepre ruby strict bundler=b? g|group=q source=q].freeze,
72
+ update: %w[all conservative pre ruby strict bundler=b? g|group=q source=q].freeze,
73
73
  v3: {
74
74
  binstubs: %w[all].freeze,
75
75
  cache: %w[all frozen no-prune].freeze,
@@ -212,7 +212,8 @@ module Squared
212
212
  attr_reader :gemdir
213
213
  attr_accessor :autodetect
214
214
 
215
- def initialize(*, autodetect: false, steep: 'Steepfile', rubocop: '.rubocop.yml', asdf: 'ruby', **kwargs)
215
+ def initialize(*, autodetect: false, exec: false, steep: 'Steepfile', rubocop: '.rubocop.yml', asdf: 'ruby',
216
+ **kwargs)
216
217
  super
217
218
  if @pass.include?(Ruby.ref)
218
219
  initialize_ref Ruby.ref
@@ -225,6 +226,7 @@ module Squared
225
226
  serve_set kwargs[:serve]
226
227
  gemfile_set kwargs[:gemspec]
227
228
  self.autodetect = autodetect
229
+ @bundle = { exec: exec.is_a?(String) ? basepath!(exec) : false }
228
230
  @steepfile = basepath! steep if steep
229
231
  @rubocopfile = Pathname.new(rubocop).realpath rescue basepath!(Dir.home, '.rubocop.yml') if rubocop
230
232
  @rubygems = kwargs.fetch(:rubygems, 0)
@@ -297,7 +299,7 @@ module Squared
297
299
  queue.call
298
300
  if (item = tasks[n.pred])
299
301
  cmd = [pre, item.first].compact.join(' ')
300
- elsif exception
302
+ elsif exception?
301
303
  indexerror n, tasks
302
304
  else
303
305
  log.warn "rake task #{n} of #{tasks.size}".subhint('out of range')
@@ -602,8 +604,8 @@ module Squared
602
604
  end
603
605
  pwd_set do
604
606
  out = []
605
- tool = args.name || (args.local && !SEM_VER.match?(args.local) ? args.local : 'ruby')
606
- trim = ->(s) { s[/^\D+\d+\.\d+(?:\.\S+)?/, 0].sub(/^([a-z]+)-/i, '\1 ') }
607
+ tool = args.name || (s && !SEM_VER.match?(s) ? s : 'ruby')
608
+ trim = ->(val) { val =~ /^\D+\d+\.\d+(?:\.\S+)?/ ? $&.sub(/^([a-z]+)-/i, '\1 ') : val }
607
609
  vm, bin = vmname(bin: true)
608
610
  out << trim.call(case vm
609
611
  when 'rvm'
@@ -689,10 +691,16 @@ module Squared
689
691
  .lines
690
692
  .map { |line| line.sub(/#.*$/, '').strip }
691
693
  .reject(&:empty?)
694
+ .yield_self do |data|
695
+ target = data.find { |line| line.include?(tool) }
696
+ target ? [target] : data
697
+ end
692
698
  .join(', ')
693
699
  end
694
700
  append.call(file, hint)
695
- throw :found if hint&.include?(out.first[/^(?:j|truffle)?ruby ([\d.]+)/, 1])
701
+ if hint&.include?(out.first[/^(?:(?:j|truffle)?ruby|#{tool}) ([\d.]+)/, 1])
702
+ throw :found
703
+ end
696
704
  rescue
697
705
  nil
698
706
  end
@@ -1617,8 +1625,8 @@ module Squared
1617
1625
 
1618
1626
  def rubocop(*args, sync: true, banner: verbose?, with: nil, pass: PASS_RUBY[:rubocop], **kwargs)
1619
1627
  opts = session_opts(with, args: args, kwargs: kwargs, pass: pass)
1620
- op = OptionPartition.new(opts, OPT_RUBY[:rubocop], session('rubocop'), project: self, strict: strict?,
1621
- no: OPT_RUBY[:no][:rubocop])
1628
+ op = OptionPartition.new(opts, OPT_RUBY[:rubocop], session(*bundle_args('rubocop')),
1629
+ project: self, strict: strict?, no: OPT_RUBY[:no][:rubocop])
1622
1630
  if @rubocopfile && !op.arg?('c', 'config') && !rootpath('.rubocop.yml', ascend: true).exist?
1623
1631
  op.add_path(@rubocopfile, option: 'c')
1624
1632
  end
@@ -1639,6 +1647,9 @@ module Squared
1639
1647
 
1640
1648
  def serve(root, *, bind: nil, port: 3000, **kwargs)
1641
1649
  require 'webrick'
1650
+ rescue LoadError => e
1651
+ print_error(e, pass: true)
1652
+ else
1642
1653
  config = kwargs.merge({ DocumentRoot: root })
1643
1654
  config[:BindAddress] = bind if bind
1644
1655
  config[:Port] = port if port
@@ -1650,7 +1661,7 @@ module Squared
1650
1661
  end
1651
1662
 
1652
1663
  def vmname(bin: false)
1653
- order = { 'rbenv' => -1, 'rvm' => -1, 'chruby' => -1, 'mise' => -1 }
1664
+ order = { 'rbenv' => -1, 'rvm' => -1, 'chruby' => -1, 'asdf' => -1, 'mise' => -1 }
1654
1665
  ENV.fetch('PATH', '').split(':').each_with_index do |val, index|
1655
1666
  order.each_key do |key|
1656
1667
  next unless val.match?(%r{[/.]#{key}/})
@@ -1659,36 +1670,40 @@ module Squared
1659
1670
  break
1660
1671
  end
1661
1672
  end
1673
+ items = [
1674
+ "#{ENV.fetch('RBENV_ROOT', '$HOME/.rbenv')}/bin/rbenv",
1675
+ '$HOME/.rvm/bin/rvm',
1676
+ '$HOME/.local/bin/mise',
1677
+ '/usr/bin/rbenv',
1678
+ '/usr/bin/mise',
1679
+ '/usr/local/rvm/bin/rvm',
1680
+ '/usr/share/rvm/bin/rvm',
1681
+ '/usr/local/share/chruby/chruby.sh'
1682
+ ]
1662
1683
  if @asdf
1663
- [File.join(ENV.fetch('ASDF_DATA_DIR', '$HOME/.asdf'), "installs/#{@asdf.first}")]
1664
- else
1665
- [
1666
- "#{ENV.fetch('RBENV_ROOT', '$HOME/.rbenv')}/bin/rbenv",
1667
- '$HOME/.rvm/bin/rvm',
1668
- '$HOME/.local/bin/mise',
1669
- '/usr/bin/rbenv',
1670
- '/usr/bin/mise',
1671
- '/usr/local/rvm/bin/rvm',
1672
- '/usr/share/rvm/bin/rvm',
1673
- '/usr/local/share/chruby/chruby.sh'
1674
- ]
1675
- .sort do |a, b|
1676
- c = -1
1677
- d = -1
1678
- order.each do |key, val|
1679
- pat = %r{/\.?#{key}}
1680
- c = val if a.match?(pat)
1681
- d = val if b.match?(pat)
1682
- end
1683
- if c == d
1684
- 0
1685
- elsif c == -1
1686
- 1
1687
- elsif d == -1
1688
- -1
1689
- else
1690
- c < d ? -1 : 1
1691
- end
1684
+ dir = File.join(ENV.fetch('ASDF_DATA_DIR', '$HOME/.asdf'), "installs/#{@asdf.first}")
1685
+ if @@asdf.version == 16
1686
+ items = [dir]
1687
+ else
1688
+ items << dir
1689
+ end
1690
+ end
1691
+ items.sort do |a, b|
1692
+ c = -1
1693
+ d = -1
1694
+ order.each do |key, val|
1695
+ pat = %r{/\.?#{key}}
1696
+ c = val if a.match?(pat)
1697
+ d = val if b.match?(pat)
1698
+ end
1699
+ if c == d
1700
+ 0
1701
+ elsif c == -1
1702
+ 1
1703
+ elsif d == -1
1704
+ -1
1705
+ else
1706
+ c < d ? -1 : 1
1692
1707
  end
1693
1708
  end
1694
1709
  .each do |val|
@@ -1811,8 +1826,8 @@ module Squared
1811
1826
  private
1812
1827
 
1813
1828
  def run_repl(*args, opts:, banner:, from:, delim: true, **kwargs)
1814
- op = OptionPartition.new(opts, OPT_RUBY[from], session(from), project: self, strict: strict?,
1815
- first: [/\.rb$/])
1829
+ op = OptionPartition.new(opts, OPT_RUBY[from], session(*bundle_args(from)), project: self, strict: strict?,
1830
+ first: [/\.rb$/])
1816
1831
  r = []
1817
1832
  r << 'bundler/setup' if !op.arg?('r') && bundle_load
1818
1833
  r.concat(Array(kwargs[:name])) if kwargs[:name]
@@ -1839,14 +1854,15 @@ module Squared
1839
1854
  end
1840
1855
 
1841
1856
  def rake_session(*cmd, **kwargs)
1842
- session('rake', *preopts, *cmd, **kwargs)
1857
+ session(*bundle_args('rake'), *preopts, *cmd, **kwargs)
1843
1858
  end
1844
1859
 
1845
1860
  def rbs_session(*cmd, opts: nil)
1846
- return session('rbs', *cmd) unless opts
1861
+ args = bundle_args 'rbs'
1862
+ return session(*args, *cmd) unless opts
1847
1863
 
1848
1864
  op = OptionPartition.new(opts, OPT_RUBY[:rbs], project: self, strict: strict?)
1849
- [session('rbs', *op.to_a, *cmd), op.extras]
1865
+ [session(*args, *op.to_a, *cmd), op.extras]
1850
1866
  end
1851
1867
 
1852
1868
  def gem_output(*cmd, **kwargs)
@@ -1862,7 +1878,15 @@ module Squared
1862
1878
  end
1863
1879
 
1864
1880
  def rake_output(*cmd, **kwargs)
1865
- session_output('rake', *cmd, **kwargs)
1881
+ session_output(*bundle_args('rake'), *cmd, **kwargs)
1882
+ end
1883
+
1884
+ def bundle_args(*args)
1885
+ if (val = @bundle[:exec])
1886
+ args.unshift(quote_option('gemfile', val)) unless val == true
1887
+ args.unshift('bundle', 'exec')
1888
+ end
1889
+ args
1866
1890
  end
1867
1891
 
1868
1892
  def bundle_load
@@ -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
- filter: nil, pass: nil, **)
24
+ filter: nil, pass: nil, preserve: true, **)
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)
55
+ shell_quote(val, force: force, double: double, preserve: preserve)
56
56
  else
57
57
  val
58
58
  end
@@ -395,10 +395,10 @@ module Squared
395
395
  self
396
396
  end
397
397
 
398
- def append(*args, clear: false, **kwargs, &blk)
398
+ def append(*args, clear: false, preserve: '"', **kwargs, &blk)
399
399
  args = clear ? extras.dup.tap { extras.clear } : extras if args.empty?
400
400
  pass = kwargs[:pass] ||= []
401
- OptionPartition.append(target, *args, **kwargs, &blk)
401
+ OptionPartition.append(target, *args, preserve: preserve, **kwargs, &blk)
402
402
  errors.concat(pass)
403
403
  self
404
404
  end
@@ -219,7 +219,7 @@ module Squared
219
219
  opts << "--#{val}"
220
220
  when /^(fetch-)?submodules$/
221
221
  opts << '--fetch-submodules' if repo_submodules?(true, **envargs)
222
- when /^(fail-)?fail$/
222
+ when /^(fail-)?fast$/
223
223
  opts << '--fail-fast'
224
224
  when /^no-(manifest-)?update$/
225
225
  opts << '--no-manifest-update'
@@ -227,7 +227,9 @@ module Squared
227
227
  opts << '--auto-gc'
228
228
  end
229
229
  end
230
- opts << "-j#{ENV.fetch('REPO_JOBS', Rake::CpuCounter.count)}" unless opts.any?(/^--?j(obs)?$/)
230
+ if (jobs = ENV['REPO_JOBS']) || opts.none?(/^--?j(obs)?$/)
231
+ opts << "-j#{jobs || Rake::CpuCounter.count}"
232
+ end
231
233
  opts << '--fetch-submodules' if repo_submodules?(**envargs)
232
234
  begin
233
235
  repo_run('sync', opts, exception: opts.include?('--fail-fast'), options: stage != 'init')
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.5
4
+ version: 0.7.7
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.6
128
+ rubygems_version: 4.0.14
129
129
  specification_version: 4
130
130
  summary: Rake task generator for managing multi-language workspaces.
131
131
  test_files: []