Method: Gem::RequestSet::GemDependencyAPI#gem
- Defined in:
- lib/rubygems/request_set/gem_dependency_api.rb
#gem(name, *requirements) ⇒ Object
:category: Gem Dependencies DSL
:call-seq:
gem(name)
gem(name, *requirements)
gem(name, *requirements, )
Specifies a gem dependency with the given name
and requirements
. You may also supply options
following the requirements
options
include:
- require:
-
RubyGems does not provide any autorequire features so requires in a gem dependencies file are recorded but ignored.
In bundler the require: option overrides the file to require during Bundler.require. By default the name of the dependency is required in Bundler. A single file or an Array of files may be given.
To disable requiring any file give
false
:gem 'rake', require: false
- group:
-
Place the dependencies in the given dependency group. A single group or an Array of groups may be given.
See also #group
- platform:
-
Only install the dependency on the given platform. A single platform or an Array of platforms may be given.
See #platform for a list of platforms available.
- path:
-
Install this dependency from an unpacked gem in the given directory.
gem 'modified_gem', path: 'vendor/modified_gem'
- git:
-
Install this dependency from a git repository:
gem 'private_gem', git: '[email protected]:private_gem.git'
- gist:
-
Install this dependency from the gist ID:
gem 'bang', gist: '1232884'
- github:
-
Install this dependency from a github git repository:
gem 'private_gem', github: 'my_company/private_gem'
- submodules:
-
Set to
true
to include submodules when fetching the git repository for git:, gist: and github: dependencies. - ref:
-
Use the given commit name or SHA for git:, gist: and github: dependencies.
- branch:
-
Use the given branch for git:, gist: and github: dependencies.
- tag:
-
Use the given tag for git:, gist: and github: dependencies.
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
# File 'lib/rubygems/request_set/gem_dependency_api.rb', line 359 def gem(name, *requirements) = requirements.pop if requirements.last.is_a?(Hash) ||= {} [:git] = @current_repository if @current_repository source_set = false source_set ||= gem_path name, source_set ||= gem_git name, source_set ||= gem_git_source name, source_set ||= gem_source name, duplicate = @dependencies.include? name @dependencies[name] = if requirements.empty? && !source_set Gem::Requirement.default elsif source_set Gem::Requirement.source_set else Gem::Requirement.create requirements end return unless gem_platforms name, groups = gem_group name, return unless (groups & @without_groups).empty? pin_gem_source name, :default unless source_set gem_requires name, if duplicate warn <<-WARNING Gem dependencies file #{@path} requires #{name} more than once. WARNING end @set.gem name, *requirements end |