In Files

  • rubygems/request_set/gem_dependency_api.rb

Class/Module Index [+]



A semi-compatible DSL for the Bundler Gemfile and Isolate formats.

Public Class Methods

new(set, path) click to toggle source

Creates a new GemDependencyAPI that will add dependencies to the Gem::RequestSet set based on the dependency API description in path.

               # File rubygems/request_set/gem_dependency_api.rb, line 134
def initialize set, path
  @set = set
  @path = path

  @current_groups     = nil
  @current_platform   = nil
  @current_repository = nil
  @default_sources    = true
  @git_set            = @set.git_set
  @requires           = { |h, name| h[name] = [] }
  @vendor_set         = @set.vendor_set
  @gem_sources        = {}
  @without_groups     = []

Public Instance Methods

load() click to toggle source

Loads the gem dependency file

               # File rubygems/request_set/gem_dependency_api.rb, line 192
def load
  instance_eval, @path, 1

Gem Dependencies DSL ↑ top

Public Instance Methods

gem(name) click to toggle source
gem(name, *requirements)
gem(name, *requirements, options)

Specifies a gem dependency with the given name and requirements. You may also supply options following the requirements

               # File rubygems/request_set/gem_dependency_api.rb, line 206
def gem name, *requirements
  options = requirements.pop if requirements.last.kind_of?(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_github name, options

  return unless gem_platforms options

  groups = gem_group name, options

  return unless (groups & @without_groups).empty?

  pin_gem_source name, :default unless source_set

  gem_requires name, options

  @set.gem name, *requirements
gemspec(options = {}) click to toggle source

Loads dependencies from a gemspec file.

               # File rubygems/request_set/gem_dependency_api.rb, line 387
def gemspec options = {}
  name              = options.delete(:name) || '{,*}'
  path              = options.delete(:path) || '.'
  development_group = options.delete(:development_group) || :development

  spec = find_gemspec name, path

  groups = gem_group, {}

  add_dependencies groups, spec.runtime_dependencies

  groups << development_group

  add_dependencies groups, spec.development_dependencies

  gem_requires, options
git(repository) click to toggle source

Block form for specifying gems from a git repository.

               # File rubygems/request_set/gem_dependency_api.rb, line 366
def git repository
  @current_repository = repository


  @current_repository = nil
group(*groups) click to toggle source

Block form for placing a dependency in the given groups.

               # File rubygems/request_set/gem_dependency_api.rb, line 409
def group *groups
  @current_groups = groups


  @current_groups = nil
platform(what) click to toggle source

Block form for restricting gems to a particular platform.

               # File rubygems/request_set/gem_dependency_api.rb, line 445
def platform what
  @current_platform = what


  @current_platform = nil
Also aliased as: platforms
platforms(what) click to toggle source

Block form for restricting gems to a particular platform.

Alias for: platform
ruby(version, options = {}) click to toggle source

Restricts this gem dependencies file to the given ruby version. The :engine options from Bundler are currently ignored.

               # File rubygems/request_set/gem_dependency_api.rb, line 466
def ruby version, options = {}
  engine         = options[:engine]
  engine_version = options[:engine_version]

  raise ArgumentError,
        'you must specify engine_version along with the ruby engine' if
          engine and not engine_version

  unless RUBY_VERSION == version then
    message = "Your Ruby version is #{RUBY_VERSION}, " +
              "but your #{gem_deps_file} requires #{version}"

    raise Gem::RubyVersionMismatch, message

  if engine and engine != Gem.ruby_engine then
    message = "Your ruby engine is #{Gem.ruby_engine}, " +
              "but your #{gem_deps_file} requires #{engine}"

    raise Gem::RubyVersionMismatch, message

  if engine_version then
    my_engine_version = Object.const_get "#{Gem.ruby_engine.upcase}_VERSION"

    if engine_version != my_engine_version then
      message =
        "Your ruby engine version is #{Gem.ruby_engine} #{my_engine_version}, " +
        "but your #{gem_deps_file} requires #{engine} #{engine_version}"

      raise Gem::RubyVersionMismatch, message

  return true
source(url) click to toggle source

Sets url as a source for gems for this dependency API.

               # File rubygems/request_set/gem_dependency_api.rb, line 508
def source url
  Gem.sources.clear if @default_sources

  @default_sources = false

  Gem.sources << url

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit