123456789_123456789_123456789_123456789_123456789_

Class: Bundler::PubGrub::StaticPackageSource::DSL

Relationships & Source Files
Inherits: Object
Defined in: lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb

Class Method Summary

Instance Method Summary

Constructor Details

.new(packages, root_deps) ⇒ DSL

[ GitHub ]

  
# File 'lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb', line 10

def initialize(packages, root_deps)
  @packages = packages
  @root_deps = root_deps
end

Instance Method Details

#add(name, version, deps: {})

Raises:

  • (ArgumentError)
[ GitHub ]

  
# File 'lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb', line 19

def add(name, version, deps: {})
  version = Gem::Version.new(version)
  @packages[name] ||= {}
  raise ArgumentError, "#{name} #{version} declared twice" if @packages[name].key?(version)
  @packages[name][version] = clean_deps(name, version, deps)
end

#clean_deps(name, version, deps) (private)

Exclude redundant self-referencing dependencies

[ GitHub ]

  
# File 'lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb', line 29

def clean_deps(name, version, deps)
  deps.reject {|dep_name, req| name == dep_name && Bundler::PubGrub::RubyGems.parse_range(req).include?(version) }
end

#root(deps:)

[ GitHub ]

  
# File 'lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb', line 15

def root(deps:)
  @root_deps.update(deps)
end