Sha256: 893ea6756144679474b396db404b55116ed82401e6a650c7a52d740e5c436c20

Contents?: true

Size: 879 Bytes

Versions: 5

Compression:

Stored size: 879 Bytes

Contents

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

    def run
      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

5 entries across 5 versions & 1 rubygems

Version Path
bundler-1.11.2 lib/bundler/cli/console.rb
bundler-1.11.1 lib/bundler/cli/console.rb
bundler-1.11.0 lib/bundler/cli/console.rb
bundler-1.11.0.pre.2 lib/bundler/cli/console.rb
bundler-1.11.0.pre.1 lib/bundler/cli/console.rb