Class: Ready::ByExecutable

Inherits:
Object
  • Object
show all
Defined in:
lib/ready/by_executable.rb

Overview

Builds the ruby invocation used to run the "by" executable, toggling rubygems and YJIT, and renders it as a shell alias.

Instance Method Summary collapse

Constructor Details

#initialize(current_ruby: RbConfig.ruby, by_bin: Gem.activate_bin_path("by", "by")) ⇒ ByExecutable

Returns a new instance of ByExecutable.



8
9
10
11
12
13
14
15
# File 'lib/ready/by_executable.rb', line 8

def initialize(
  current_ruby: RbConfig.ruby,
  by_bin: Gem.activate_bin_path("by", "by")
)
  @current_ruby = current_ruby
  @by_bin = by_bin
  @args = []
end

Instance Method Details

#command_argsObject



37
38
39
40
41
42
43
# File 'lib/ready/by_executable.rb', line 37

def command_args
  [
    @current_ruby,
    *@args,
    @by_bin,
  ]
end

#to_aliasObject



45
46
47
48
49
# File 'lib/ready/by_executable.rb', line 45

def to_alias
  command_args
    .then { Shellwords.join(it) }
    .then { "#{it} \"${@}\"" }
end

#with_rubygemsObject



22
23
24
25
# File 'lib/ready/by_executable.rb', line 22

def with_rubygems
  @args.delete "--disable-gems"
  self
end

#with_yjitObject



27
28
29
30
# File 'lib/ready/by_executable.rb', line 27

def with_yjit
  @args << "--yjit"
  self
end

#without_rubygemsObject



17
18
19
20
# File 'lib/ready/by_executable.rb', line 17

def without_rubygems
  @args << "--disable-gems" unless @args.include? "--disable-gems"
  self
end

#without_yjitObject



32
33
34
35
# File 'lib/ready/by_executable.rb', line 32

def without_yjit
  @args.delete("--yjit")
  self
end