class Bundler::CLI::Add - bundler-1.15.4 Documentation

# class Bundler::CLI::Add

### Public Class Methods

new(options, gem_name) click to toggle source

    # File lib/bundler/cli/add.rb, line 5
    def initialize(options, gem_name)
      @gem_name = gem_name
      @options = options
      @options[:group] = @options[:group].split(",").map(&:strip) if !@options[:group].nil? && !@options[:group].empty?
    end

### Public Instance Methods

run() click to toggle source

    # File lib/bundler/cli/add.rb, line 11
    def run
      version = @options[:version].nil? ? nil : @options[:version].split(",").map(&:strip)

      unless version.nil?
        version.each do |v|
          raise InvalidOption, "Invalid gem requirement pattern '#{v}'" unless Gem::Requirement::PATTERN =~ v.to_s
        end
      end
      dependency = Bundler::Dependency.new(@gem_name, version, @options)

      Injector.inject([dependency], :conservative_versioning => @options[:version].nil?) # Perform conservative versioning only when version is not specified
      Installer.install(Bundler.root, Bundler.definition)
    end