mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
be7b592912
* lib/bundler, spec/bundler: Merge bundler-1.16.0. * common.mk: rspec examples of bundler-1.16.0 needs require option. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
25 lines
885 B
Ruby
25 lines
885 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Bundler
|
|
class CLI::Add
|
|
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
|
|
|
|
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
|
|
end
|
|
end
|