class Bundlegem::CLI

Constants

AUTO_INSTALL_CMDS

Public Class Methods

handle_no_command_error(command, has_namespace = $thor_runner) click to toggle source
# File lib/bundlegem/cli.rb, line 74
def self.handle_no_command_error(command, has_namespace = $thor_runner)
  require 'bundlegem/cli/gem'
  Gem.new(options, name, self).run



  # return super unless command_path = Bundlegem.which("Bundlegem-#{command}")

  # Kernel.exec(command_path, *ARGV[1..-1])
end
new(*args) click to toggle source
Calls superclass method
# File lib/bundlegem/cli.rb, line 19
def initialize(*args)
  super
  current_cmd = args.last[:current_command].name
  # custom_gemfile = options[:gemfile] || Bundlegem.settings[:gemfile]
  # ENV['BUNDLE_GEMFILE']   = File.expand_path(custom_gemfile) if custom_gemfile
  # Bundlegem::Retry.attempts = options[:retry] || Bundlegem.settings[:retry] || Bundlegem::Retry::DEFAULT_ATTEMPTS
  # Bundlegem.rubygems.ui = UI::RGProxy.new(Bundlegem.ui)
  # auto_install if AUTO_INSTALL_CMDS.include?(current_cmd)
rescue UnknownArgumentError => e
  raise InvalidOption, e.message
ensure
  self.options ||= {}
  # Bundlegem.ui = UI::Shell.new(options)
  # Bundlegem.ui.level = "debug" if options["verbose"]
end
source_root() click to toggle source
# File lib/bundlegem/cli.rb, line 125
def self.source_root
  File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
end
start(*) click to toggle source
Calls superclass method
# File lib/bundlegem/cli.rb, line 9
def self.start(*)
  super
rescue Exception => e
  # Bundlegem.ui = UI::Shell.new
  puts e
  raise e
ensure
  # Bundlegem.cleanup
end

Public Instance Methods

env() click to toggle source
# File lib/bundlegem/cli.rb, line 140
def env
  Env.new.write($stdout)
end
gem(name) click to toggle source
# File lib/bundlegem/cli.rb, line 117
def gem(name)
  # options = {"bin"=>false, "ext"=>false}
  # name = "gem_name"
  # self.class == Bundlegem::CLI
  require 'bundlegem/cli/gem'
  Gem.new(options, name, self).run
end
help(cli = nil) click to toggle source
Calls superclass method
# File lib/bundlegem/cli.rb, line 44
def help(cli = nil)
  case cli
  when "gemfile" then command = "gemfile.5"
  when nil       then command = "bundle"
  else command = "bundle-#{cli}"
  end

  manpages = %w(
      bundle
      bundle-config
      bundle-exec
      bundle-install
      bundle-package
      bundle-update
      bundle-platform
      gemfile.5)

  if manpages.include?(command)
    root = File.expand_path("../man", __FILE__)

    if Bundlegem.which("man") && root !~ %r{^file:/.+!/META-INF/jruby.home/.+}
      Kernel.exec "man #{root}/#{command}"
    else
      puts File.read("#{root}/#{command}.txt")
    end
  else
    super
  end
end
init() click to toggle source
# File lib/bundlegem/cli.rb, line 92
def init
  require 'bundlegem/cli/init'
  Init.new(options.dup).run
end
platform() click to toggle source
# File lib/bundlegem/cli.rb, line 133
def platform
  require 'bundlegem/cli/platform'
  Platform.new(options).run
end
version() click to toggle source
# File lib/bundlegem/cli.rb, line 100
def version
  Bundler.ui.info "Bundler version #{Bundler::VERSION}"
end

Private Instance Methods

auto_install() click to toggle source

Automatically invoke `bundle install` and resume if Bundler.settings exists. This is set through config cmd `bundle config auto_install 1`.

Note that this method `nil`s out the global Definition object, so it should be called first, before you instantiate anything like an `Installer` that'll keep a reference to the old one instead.

# File lib/bundlegem/cli.rb, line 153
def auto_install
  return unless Bundler.settings[:auto_install]

  begin
    Bundler.definition.specs
  rescue GemNotFound
    Bundler.ui.info "Automatically installing missing gems."
    Bundler.reset!
    invoke :install, []
    Bundler.reset!
  end
end