Parent

Methods

Class/Module Index [+]

Quicksearch

Bundler::CLI::Inject

Attributes

gems[R]
name[R]
options[R]
version[R]

Public Class Methods

new(options, name, version, gems) click to toggle source
# File lib/bundler/cli/inject.rb, line 4
def initialize(options, name, version, gems)
  @options = options
  @name = name
  @version = version
  @gems = gems
end

Public Instance Methods

run() click to toggle source
# File lib/bundler/cli/inject.rb, line 11
def run
  # The required arguments allow Thor to give useful feedback when the arguments
  # are incorrect. This adds those first two arguments onto the list as a whole.
  gems.unshift(version).unshift(name)

  # Build an array of Dependency objects out of the arguments
  deps = []
  gems.each_slice(2) do |gem_name, gem_version|
    deps << Bundler::Dependency.new(gem_name, gem_version)
  end

  added = Injector.inject(deps)

  if added.any?
    Bundler.ui.confirm "Added to Gemfile:"
    Bundler.ui.confirm added.map{ |g| "  #{g}" }.join("\n")
  else
    Bundler.ui.confirm "All injected gems were already present in the Gemfile"
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.