class Bundler::SourceList - bundler-1.9.9 Documentation

# class Bundler::SourceList

### Attributes

git_sources[R]
path_sources[R]

### Public Class Methods

new() click to toggle source

    # File lib/bundler/source_list.rb, line 6
    def initialize
      @path_sources       = []
      @git_sources        = []
      @rubygems_aggregate = Source::Rubygems.new
      @rubygems_sources   = []
    end

### Public Instance Methods

add_git_source(options = {}) click to toggle source

    # File lib/bundler/source_list.rb, line 17
    def add_git_source(options = {})
      add_source_to_list Source::Git.new(options), git_sources
    end

add_path_source(options = {}) click to toggle source

    # File lib/bundler/source_list.rb, line 13
    def add_path_source(options = {})
      add_source_to_list Source::Path.new(options), path_sources
    end

add_rubygems_remote(uri) click to toggle source

    # File lib/bundler/source_list.rb, line 25
    def add_rubygems_remote(uri)
      @rubygems_aggregate.add_remote(uri)
      @rubygems_aggregate
    end

add_rubygems_source(options = {}) click to toggle source

    # File lib/bundler/source_list.rb, line 21
    def add_rubygems_source(options = {})
      add_source_to_list Source::Rubygems.new(options), @rubygems_sources
    end

all_sources() click to toggle source

    # File lib/bundler/source_list.rb, line 38
    def all_sources
      path_sources + git_sources + rubygems_sources
    end

cached!() click to toggle source

    # File lib/bundler/source_list.rb, line 69
    def cached!
      all_sources.each(&:cached!)
    end

get(source) click to toggle source

    # File lib/bundler/source_list.rb, line 42
    def get(source)
      source_list_for(source).find { |s| source == s }
    end

lock_sources() click to toggle source

    # File lib/bundler/source_list.rb, line 46
    def lock_sources
      lock_sources = (path_sources + git_sources).sort_by(&:to_s)
      lock_sources << combine_rubygems_sources
    end

remote!() click to toggle source

    # File lib/bundler/source_list.rb, line 73
    def remote!
      all_sources.each(&:remote!)
    end

replace_sources!(replacement_sources) click to toggle source

    # File lib/bundler/source_list.rb, line 51
    def replace_sources!(replacement_sources)
      return true if replacement_sources.empty?

      [path_sources, git_sources].each do |source_list|
        source_list.map! do |source|
          replacement_sources.find { |s| s == source } || source
        end
      end

      replacement_rubygems =
        replacement_sources.detect { |s| s.is_a?(Source::Rubygems) }
      @rubygems_aggregate = replacement_rubygems if replacement_rubygems

      # Return true if there were changes
      lock_sources.to_set != replacement_sources.to_set ||
        rubygems_remotes.to_set != replacement_rubygems.remotes.to_set
    end

rubygems_primary_remotes() click to toggle source

    # File lib/bundler/source_list.rb, line 77
    def rubygems_primary_remotes
      @rubygems_aggregate.remotes
    end

rubygems_remotes() click to toggle source

    # File lib/bundler/source_list.rb, line 34
    def rubygems_remotes
      rubygems_sources.map(&:remotes).flatten.uniq
    end

rubygems_sources() click to toggle source

    # File lib/bundler/source_list.rb, line 30
    def rubygems_sources
      @rubygems_sources + [@rubygems_aggregate]
    end

### Private Instance Methods

add_source_to_list(source, list) click to toggle source

    # File lib/bundler/source_list.rb, line 83
    def add_source_to_list(source, list)
      list.unshift(source).uniq!
      source
    end

combine_rubygems_sources() click to toggle source

    # File lib/bundler/source_list.rb, line 97
    def combine_rubygems_sources
      Source::Rubygems.new("remotes" => rubygems_remotes)
    end

source_list_for(source) click to toggle source

    # File lib/bundler/source_list.rb, line 88
    def source_list_for(source)
      case source
      when Source::Git      then git_sources
      when Source::Path     then path_sources
      when Source::Rubygems then rubygems_sources
      else raise ArgumentError, "Invalid source: #{source.inspect}"
      end
    end