Sha256: 6ce12aefa6e1f1835ab203025fc00f4e250cf10facd370d110e22ca6ef53a89b

Contents?: true

Size: 1.05 KB

Versions: 133

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module Bundler
  class CLI::Console
    attr_reader :options, :group
    def initialize(options, group)
      @options = options
      @group = group
    end

    def run
      Bundler::SharedHelpers.major_deprecation 2, "bundle console will be replaced " \
                           "by `bin/console` generated by `bundle gem <name>`"

      group ? Bundler.require(:default, *group.split(" ").map!(&:to_sym)) : Bundler.require
      ARGV.clear

      console = get_console(Bundler.settings[:console] || "irb")
      console.start
    end

    def get_console(name)
      require name
      get_constant(name)
    rescue LoadError
      Bundler.ui.error "Couldn't load console #{name}, falling back to irb"
      require "irb"
      get_constant("irb")
    end

    def get_constant(name)
      const_name = {
        "pry"  => :Pry,
        "ripl" => :Ripl,
        "irb"  => :IRB,
      }[name]
      Object.const_get(const_name)
    rescue NameError
      Bundler.ui.error "Could not find constant #{const_name}"
      exit 1
    end
  end
end

Version data entries

133 entries across 133 versions & 4 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/bundler-2.3.5/lib/bundler/cli/console.rb
bundler-2.3.27 lib/bundler/cli/console.rb
rubygems-update-3.3.27 bundler/lib/bundler/cli/console.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/bundler-2.3.5/lib/bundler/cli/console.rb
rubygems-update-3.2.34 bundler/lib/bundler/cli/console.rb
bundler-2.2.34 lib/bundler/cli/console.rb
tdiary-5.2.4 vendor/bundle/ruby/3.1.0/gems/bundler-2.3.7/lib/bundler/cli/console.rb
rubygems-update-3.3.26 bundler/lib/bundler/cli/console.rb
bundler-2.3.26 lib/bundler/cli/console.rb
rubygems-update-3.3.25 bundler/lib/bundler/cli/console.rb
bundler-2.3.25 lib/bundler/cli/console.rb
rubygems-update-3.3.24 bundler/lib/bundler/cli/console.rb
bundler-2.3.24 lib/bundler/cli/console.rb
rubygems-update-3.3.23 bundler/lib/bundler/cli/console.rb
bundler-2.3.23 lib/bundler/cli/console.rb
rubygems-update-3.3.22 bundler/lib/bundler/cli/console.rb
bundler-2.3.22 lib/bundler/cli/console.rb
rubygems-update-3.3.21 bundler/lib/bundler/cli/console.rb
bundler-2.3.21 lib/bundler/cli/console.rb
rubygems-update-3.3.20 bundler/lib/bundler/cli/console.rb