Class: Herve::CLI::RubyCommands::Install

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/herve/cli/ruby_commands/install.rb

Instance Attribute Summary

Attributes inherited from BaseCommand

#config, #logger

Instance Method Summary collapse

Methods inherited from BaseCommand

inherited

Instance Method Details

#call(version:, **options) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/herve/cli/ruby_commands/install.rb', line 16

def call(version:, **options)
  install_dir = Herve.expand_path(options[:install_dir])
  logger.info { "Installing ruby #{Rainbow(version).cyan} into #{Rainbow(install_dir).cyan}" }
  requested = Herve::Ruby::Request.parse(version)
  if requested.patch.nil?
    raise VersionError,
          "major, minor and patch are required in version, but get #{version}"
  end

  url = ruby_url(requested.to_s)
  tarball_path = local_tarball_path(config, url)
  download_ruby_tarball_if_needed(url, tarball_path)

  extract_ruby_tarball(tarball_path, install_dir)
  logger.info { "Ruby #{Rainbow(version).cyan} installed" }
end