module RubyInstaller::Runtime::Ridk

Constants

DEFAULT_COMPONENTS

The ASCII art is thankfully generated by: patorjk.com/software/taag/#p=display&f=Big&t=RubyInstaller2 patorjk.com/software/taag/#p=display&f=Bigfig&t=for%20Windows

Public Class Methods

install(args) click to toggle source
# File lib/ruby_installer/runtime/ridk.rb, line 56
def install(args)
  ci = ComponentsInstaller.new
  inst_defaults = DEFAULT_COMPONENTS

  if args.empty?
    # Interactive installation
    loop do
      ci.installable_components.each do |comp|
        puts format("  % 2d - %s", comp.task_index, comp.description)
      end
      puts
      print "Which components shall be installed? If unsure press ENTER [#{inst_defaults.join(",")}] "

      inp = STDIN.gets
      inp = inp.tr(",", " ").strip if inp
      if !inp
        break
      elsif inp.empty? && inst_defaults.empty?
        break
      elsif inp.empty?
        inst_list = inst_defaults
      elsif inp =~ /\A(?:(\d+|\w+)\s*)+\z/
        inst_list = [inp]
      else
        puts red("Please enter a comma separated list of the components to be installed")
      end

      if inst_list
        puts
        begin
          ci.install(args_to_tasks(ci, inst_list).map(&:name))
        rescue => err
          puts red("Installation failed: #{err}")
        end

        ci.reload
        inst_defaults = []
        puts
      end
    end

  else
    # Unattended installation
    ci.install(args_to_tasks(ci, args).map(&:name))
  end
end
msys_version_info(msys_path) click to toggle source
# File lib/ruby_installer/runtime/ridk.rb, line 115
def msys_version_info(msys_path)
  require "rexml/document"
  doc = File.open( File.join(msys_path, "components.xml") ) do |fd|
    REXML::Document.new fd
  end
  {
    "title" => doc.elements.to_a("//Packages/Package/Title").first.text,
    "version" => doc.elements.to_a("//Packages/Package/Version").first.text,
  }
end
print_help() click to toggle source
print_version() click to toggle source
run!(args) click to toggle source
# File lib/ruby_installer/runtime/ridk.rb, line 8
def run!(args)
  enable_colors
  case args[0]
    when 'install'
      print_logo
      puts
      install(args[1..-1])
    when 'enable', 'exec'
      puts Runtime.msys2_installation.enable_msys_apps_per_cmd
    when 'disable'
      puts Runtime.msys2_installation.disable_msys_apps_per_cmd
    when 'enableps1', 'execps1'
      puts Runtime.msys2_installation.enable_msys_apps_per_ps1
    when 'disableps1'
      puts Runtime.msys2_installation.disable_msys_apps_per_ps1
    when 'version'
      print_version
    when 'help', '--help', '-?', '/?', nil
      print_logo
      print_help
    else
      $stderr.puts "Invalid option #{args[0].inspect}"
  end
end

Private Class Methods

args_to_tasks(ci, args) click to toggle source
# File lib/ruby_installer/runtime/ridk.rb, line 103
        def args_to_tasks(ci, args)
  tasks = args.join(" ").split(" ").map do |idx_or_name|
    if idx_or_name =~ /\A\d+\z/ && (task=ci.installable_components.find{|c| idx_or_name.to_i == c.task_index })
      task
    elsif idx_or_name =~ /\A\w+\z/ && (task=ci.installable_components.find{|c| idx_or_name == c.name })
      task
    else
      puts red("Can not find component #{idx_or_name.inspect}")
    end
  end.compact
end
ignore_err() { || ... } click to toggle source
# File lib/ruby_installer/runtime/ridk.rb, line 126
        def ignore_err
  orig_verbose, $VERBOSE = $VERBOSE, nil
  begin
    yield
  rescue
  end
  $VERBOSE = orig_verbose
end