Class: Bundler::Dependency
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
::Gem::Dependency
|
|
Instance Chain:
self,
::Gem::Dependency ,
ForcePlatform
|
|
Inherits: |
Gem::Dependency
|
Defined in: | lib/bundler/dependency.rb |
Constant Summary
-
ALL_RUBY_VERSIONS =
# File 'lib/bundler/dependency.rb', line 12((18..27).to_a + (30..33).to_a).freeze
-
PLATFORM_MAP =
# File 'lib/bundler/dependency.rb', line 13{ :ruby => [Gem::Platform::RUBY, ALL_RUBY_VERSIONS], :mri => [Gem::Platform::RUBY, ALL_RUBY_VERSIONS], :rbx => [Gem::Platform::RUBY], :truffleruby => [Gem::Platform::RUBY], :jruby => [Gem::Platform::JAVA, [18, 19]], :windows => [Gem::Platform::WINDOWS, ALL_RUBY_VERSIONS], :mswin => [Gem::Platform::MSWIN, ALL_RUBY_VERSIONS], :mswin64 => [Gem::Platform::MSWIN64, ALL_RUBY_VERSIONS - [18]], :mingw => [Gem::Platform::MINGW, ALL_RUBY_VERSIONS], :x64_mingw => [Gem::Platform::X64_MINGW, ALL_RUBY_VERSIONS - [18, 19]], }.each_with_object({}) do |(platform, spec), hash| hash[platform] = spec[0] spec[1]&.each {|version| hash[:"#{platform}_#{version}"] = spec[0] } end.freeze
Class Method Summary
Instance Attribute Summary
- #autorequire readonly
- #branch readonly
- #current_env? ⇒ Boolean readonly
- #current_platform? ⇒ Boolean readonly
- #gemfile readonly
- #git readonly
- #github readonly
- #groups readonly
- #path readonly
- #platforms readonly
- #ref readonly
- #should_include? ⇒ Boolean readonly
- #specific? ⇒ Boolean readonly
::Gem::Dependency
- Inherited
Instance Method Summary
- #expanded_platforms
-
#gem_platforms(valid_platforms)
Returns the platforms this dependency is valid for, in the same order as passed in the
valid_platforms
parameter. - #to_lock
::Gem::Dependency
- Inherited
ForcePlatform
- Included
#default_force_ruby_platform | The |
Constructor Details
.new(name, version, options = {}, &blk) ⇒ Dependency
# File 'lib/bundler/dependency.rb', line 29
def initialize(name, version, = {}, &blk) type = ["type"] || :runtime super(name, version, type) @autorequire = nil @groups = Array( ["group"] || :default).map(&:to_sym) @source = ["source"] @path = ["path"] @git = ["git"] @github = ["github"] @branch = ["branch"] @ref = ["ref"] @platforms = Array( ["platforms"]) @env = ["env"] @should_include = .fetch("should_include", true) @gemfile = ["gemfile"] @force_ruby_platform = ["force_ruby_platform"] if .key?("force_ruby_platform") @autorequire = Array( ["require"] || []) if .key?("require") end
Instance Attribute Details
#autorequire (readonly)
[ GitHub ]# File 'lib/bundler/dependency.rb', line 9
attr_reader :autorequire
#branch (readonly)
[ GitHub ]
#current_env? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/bundler/dependency.rb', line 67
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 78
def current_platform? return true if @platforms.empty? @platforms.any? do |p| Bundler.current_ruby.send("#{p}?") end end
#gemfile (readonly)
[ GitHub ]#git (readonly)
[ GitHub ]#github (readonly)
[ GitHub ]#groups (readonly)
[ GitHub ]#path (readonly)
[ GitHub ]#platforms (readonly)
[ GitHub ]#ref (readonly)
[ GitHub ]
#should_include? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/bundler/dependency.rb', line 63
def should_include? @should_include && current_env? && current_platform? end
#specific? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/bundler/dependency.rb', line 91
def specific? super rescue NoMethodError requirement != ">= 0" end
Instance Method Details
#expanded_platforms
[ GitHub ]# File 'lib/bundler/dependency.rb', line 59
def @expanded_platforms ||= @platforms.map {|pl| PLATFORM_MAP[pl] }.compact.flatten.uniq end
#gem_platforms(valid_platforms)
Returns the platforms this dependency is valid for, in the same order as passed in the valid_platforms
parameter
# File 'lib/bundler/dependency.rb', line 52
def gem_platforms(valid_platforms) return [Gem::Platform::RUBY] if force_ruby_platform return valid_platforms if @platforms.empty? valid_platforms.select {|p| .include?(GemHelpers.generic(p)) } end
#to_lock
[ GitHub ]# File 'lib/bundler/dependency.rb', line 85
def to_lock out = super out << "!" if source out end