Class: Bundler::SourceList

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/source_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSourceList

Returns a new instance of SourceList.



6
7
8
9
10
11
# File 'lib/bundler/source_list.rb', line 6

def initialize
  @path_sources       = []
  @git_sources        = []
  @rubygems_aggregate = Source::Rubygems.new
  @rubygems_sources   = []
end

Instance Attribute Details

#git_sourcesObject (readonly)

Returns the value of attribute git_sources.



3
4
5
# File 'lib/bundler/source_list.rb', line 3

def git_sources
  @git_sources
end

#path_sourcesObject (readonly)

Returns the value of attribute path_sources.



3
4
5
# File 'lib/bundler/source_list.rb', line 3

def path_sources
  @path_sources
end

Instance Method Details

#add_git_source(options = {}) ⇒ Object



17
18
19
# 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 = {}) ⇒ Object



13
14
15
# 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) ⇒ Object



25
26
27
28
# 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 = {}) ⇒ Object



21
22
23
# 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_sourcesObject



38
39
40
# File 'lib/bundler/source_list.rb', line 38

def all_sources
  path_sources + git_sources + rubygems_sources
end

#cached!Object



69
70
71
# File 'lib/bundler/source_list.rb', line 69

def cached!
  all_sources.each(&:cached!)
end

#get(source) ⇒ Object



42
43
44
# File 'lib/bundler/source_list.rb', line 42

def get(source)
  source_list_for(source).find { |s| source == s }
end

#lock_sourcesObject



46
47
48
49
# 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!Object



73
74
75
# File 'lib/bundler/source_list.rb', line 73

def remote!
  all_sources.each(&:remote!)
end

#replace_sources!(replacement_sources) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# 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_remotesObject



77
78
79
# File 'lib/bundler/source_list.rb', line 77

def rubygems_primary_remotes
  @rubygems_aggregate.remotes
end

#rubygems_remotesObject



34
35
36
# File 'lib/bundler/source_list.rb', line 34

def rubygems_remotes
  rubygems_sources.map(&:remotes).flatten.uniq
end

#rubygems_sourcesObject



30
31
32
# File 'lib/bundler/source_list.rb', line 30

def rubygems_sources
  @rubygems_sources + [@rubygems_aggregate]
end