class Bundler::Dependency

Constants

PLATFORM_MAP

Attributes

autorequire[R]
groups[R]
platforms[R]

Public Class Methods

new(name, version, options = {}, &blk) click to toggle source
Calls superclass method
# File lib/bundler/dependency.rb, line 29
def initialize(name, version, options = {}, &blk)
  type = options["type"] || :runtime
  super(name, version, type)

  @autorequire = nil
  @groups      = Array(options["group"] || :default).map { |g| g.to_sym }
  @source      = options["source"]
  @platforms   = Array(options["platforms"])
  @env         = options["env"]

  if options.key?('require')
    @autorequire = Array(options['require'] || [])
  end
end

Public Instance Methods

current_env?() click to toggle source
# File lib/bundler/dependency.rb, line 60
def current_env?
  return true unless @env
  if Hash === @env
    @env.all? do |key, val|
      ENV[key.to_s] && (String === val ? ENV[key.to_s] == val : ENV[key.to_s] =~ val)
    end
  else
    ENV[@env.to_s]
  end
end
current_platform?() click to toggle source
# File lib/bundler/dependency.rb, line 71
def current_platform?
  return true if @platforms.empty?
  @platforms.any? { |p| send("#{p}?") }
end
gem_platforms(valid_platforms) click to toggle source
# File lib/bundler/dependency.rb, line 44
def gem_platforms(valid_platforms)
  return valid_platforms if @platforms.empty?

  platforms = []
  @platforms.each do |p|
    platform = PLATFORM_MAP[p]
    next unless valid_platforms.include?(platform)
    platforms |= [platform]
  end
  platforms
end
should_include?() click to toggle source
# File lib/bundler/dependency.rb, line 56
def should_include?
  current_env? && current_platform?
end
to_lock() click to toggle source
Calls superclass method Gem::Dependency#to_lock
# File lib/bundler/dependency.rb, line 76
def to_lock
  out = super
  out << '!' if source
  out << "\n"
end

Private Instance Methods

jruby?() click to toggle source
# File lib/bundler/dependency.rb, line 133
def jruby?
  defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
end
maglev?() click to toggle source
# File lib/bundler/dependency.rb, line 137
def maglev?
  defined?(RUBY_ENGINE) && RUBY_ENGINE == "maglev"
end
mingw?() click to toggle source
# File lib/bundler/dependency.rb, line 145
def mingw?
  Bundler::WINDOWS && Gem::Platform.local.os == "mingw32"
end
mingw_18?() click to toggle source
# File lib/bundler/dependency.rb, line 149
def mingw_18?
  mingw? && on_18?
end
mingw_19?() click to toggle source
# File lib/bundler/dependency.rb, line 153
def mingw_19?
  mingw? && on_19?
end
mingw_20?() click to toggle source
# File lib/bundler/dependency.rb, line 157
def mingw_20?
  mingw? && on_20?
end
mri?() click to toggle source
# File lib/bundler/dependency.rb, line 112
def mri?
  !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby")
end
mri_18?() click to toggle source
# File lib/bundler/dependency.rb, line 116
def mri_18?
  mri? && on_18?
end
mri_19?() click to toggle source
# File lib/bundler/dependency.rb, line 120
def mri_19?
  mri? && on_19?
end
mri_20?() click to toggle source
# File lib/bundler/dependency.rb, line 125
def mri_20?
  mri? && on_20?
end
mswin?() click to toggle source
# File lib/bundler/dependency.rb, line 141
def mswin?
  Bundler::WINDOWS
end
on_18?() click to toggle source
# File lib/bundler/dependency.rb, line 84
def on_18?
  RUBY_VERSION =~ /^1\.8/
end
on_19?() click to toggle source
# File lib/bundler/dependency.rb, line 88
def on_19?
  RUBY_VERSION =~ /^1\.9/
end
on_20?() click to toggle source
# File lib/bundler/dependency.rb, line 92
def on_20?
  RUBY_VERSION =~ /^2\.0/
end
rbx?() click to toggle source
# File lib/bundler/dependency.rb, line 129
def rbx?
  ruby? && defined?(RUBY_ENGINE) && RUBY_ENGINE == "rbx"
end
ruby?() click to toggle source
# File lib/bundler/dependency.rb, line 96
def ruby?
  !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby" || RUBY_ENGINE == "rbx" || RUBY_ENGINE == "maglev")
end
ruby_18?() click to toggle source
# File lib/bundler/dependency.rb, line 100
def ruby_18?
  ruby? && on_18?
end
ruby_19?() click to toggle source
# File lib/bundler/dependency.rb, line 104
def ruby_19?
  ruby? && on_19?
end
ruby_20?() click to toggle source
# File lib/bundler/dependency.rb, line 108
def ruby_20?
  ruby? && on_20?
end