123456789_123456789_123456789_123456789_123456789_

Class: Bundler::Dependency

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: Gem::Dependency
Defined in: lib/bundler/dependency.rb

Constant Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

::Gem::Dependency - Inherited

::Gem::Dependency::FilterIgnoredSpecs - Included

ForcePlatform - Included

#default_force_ruby_platform

The :force_ruby_platform value used by dependencies for resolution, and by locked specifications for materialization is false by default, except for TruffleRuby.

Constructor Details

.new(name, version, options = {}, &blk) ⇒ Dependency

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 8

def initialize(name, version, options = {}, &blk)
  type = options["type"] || :runtime
  super(name, version, type)

  @options = options
end

Instance Attribute Details

#current_env?Boolean (readonly)

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 121

def current_env?
  return true unless env
  if env.is_a?(Hash)
    env.all? do |key, val|
      ENV[key.to_s] && (val.is_a?(String) ? ENV[key.to_s] == val : ENV[key.to_s] =~ val)
    end
  else
    ENV[env.to_s]
  end
end

#current_platform?Boolean (readonly)

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 132

def current_platform?
  return true if platforms.empty?
  platforms.any? do |p|
    Bundler.current_ruby.send("#{p}?")
  end
end

#gemfile_dep?Boolean (readonly)

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 117

def gemfile_dep?
  !gemspec_dev_dep?
end

#gemspec_dev_dep?Boolean (readonly)

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 113

def gemspec_dev_dep?
  @gemspec_dev_dep ||= @options.fetch("gemspec_dev_dep", false)
end

#should_include (readonly)

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 71

def should_include
  @should_include ||= @options.fetch("should_include", true)
end

#should_include?Boolean (readonly)

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 109

def should_include?
  should_include && current_env? && current_platform?
end

#specific?Boolean (readonly)

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 145

def specific?
  super
rescue NoMethodError
  requirement != ">= 0"
end

Instance Method Details

#autorequire

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 87

def autorequire
  return @autorequire if defined?(@autorequire)

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

#branch

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 43

def branch
  return @branch if defined?(@branch)

  @branch = @options["branch"]
end

#env

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 65

def env
  return @env if defined?(@env)

  @env = @options["env"]
end

#expanded_platforms

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 105

def expanded_platforms
  @expanded_platforms ||= platforms.filter_map {|pl| CurrentRuby::PLATFORM_MAP[pl] }.flatten.uniq
end

#force_ruby_platform

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 81

def force_ruby_platform
  return @force_ruby_platform if defined?(@force_ruby_platform)

  @force_ruby_platform = @options["force_ruby_platform"]
end

#gem_platforms(valid_platforms)

Returns the platforms this dependency is valid for, in the same order as passed in the valid_platforms parameter

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 98

def gem_platforms(valid_platforms)
  return RUBY_PLATFORM_ARRAY if force_ruby_platform
  return valid_platforms if platforms.empty?

  valid_platforms.select {|p| expanded_platforms.include?(GemHelpers.generic(p)) }
end

#gemfile

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 75

def gemfile
  return @gemfile if defined?(@gemfile)

  @gemfile = @options["gemfile"]
end

#git

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 31

def git
  return @git if defined?(@git)

  @git = @options["git"]
end

#github

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 37

def github
  return @github if defined?(@github)

  @github = @options["github"]
end

#glob

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 55

def glob
  return @glob if defined?(@glob)

  @glob = @options["glob"]
end

#groups

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 15

def groups
  @groups ||= Array(@options["group"] || :default).map(&:to_sym)
end

#path

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 25

def path
  return @path if defined?(@path)

  @path = @options["path"]
end

#platforms

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 61

def platforms
  @platforms ||= Array(@options["platforms"])
end

#ref

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 49

def ref
  return @ref if defined?(@ref)

  @ref = @options["ref"]
end

#source

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 19

def source
  return @source if defined?(@source)

  @source = @options["source"]
end

#to_lock

[ GitHub ]

  
# File 'lib/bundler/dependency.rb', line 139

def to_lock
  out = super
  out << "!" if source
  out
end