Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
Gem::RequestSet::GemDependencyAPI#gem
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/request_set/gem_dependency_api.rb, line 359
def gem(name, *requirements)
options = requirements.pop if requirements.last.is_a?(Hash)
options ||= {}
options[:git] = @current_repository if @current_repository
source_set = false
source_set ||= gem_path name, options
source_set ||= gem_git name, options
source_set ||= gem_git_source name, options
source_set ||= gem_source name, options
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, options
groups = gem_group name, options
return unless (groups & @without_groups).empty?
pin_gem_source name, :default unless source_set
gem_requires name, options
if duplicate
warn <<-WARNING
Gem dependencies file #{@path} requires #{name} more than once.
WARNING
end
@set.gem name, *requirements
end
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 inBundler. A single file or anArrayof files may be given.To disable requiring any file give
false:Examplegem 'rake', require: false
- group:
-
Place the dependencies in the given dependency group. A single group or an
Arrayof groups may be given.See also
group - platform:
-
Only install the dependency on the given platform. A single platform or an
Arrayof platforms may be given.See
platformfor a list of platforms available. - path:
-
Install this dependency from an unpacked gem in the given directory.
Examplegem 'modified_gem', path: 'vendor/modified_gem'
- git:
-
Install this dependency from a git repository:
Examplegem 'private_gem', git: '[email protected]:private_gem.git'
- gist:
-
Install this dependency from the gist ID:
Examplegem 'bang', gist: '1232884'
- github:
-
Install this dependency from a github git repository:
Examplegem 'private_gem', github: 'my_company/private_gem'
- submodules:
-
Set to
trueto 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.