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.


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

def initialize
  @path_sources       = []
  @git_sources        = []
  @svn_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

#svn_sourcesObject (readonly)

Returns the value of attribute svn_sources


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

def svn_sources
  @svn_sources
end

Instance Method Details

#add_git_source(options = {}) ⇒ Object


19
20
21
# File 'lib/bundler/source_list.rb', line 19

def add_git_source(options = {})
  add_source_to_list Source::Git.new(options), git_sources
end

#add_path_source(options = {}) ⇒ Object


15
16
17
# File 'lib/bundler/source_list.rb', line 15

def add_path_source(options = {})
  add_source_to_list Source::Path.new(options), path_sources
end

#add_rubygems_remote(uri) ⇒ Object


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

def add_rubygems_remote(uri)
  @rubygems_aggregate.add_remote(uri)
  @rubygems_aggregate
end

#add_rubygems_source(options = {}) ⇒ Object


27
28
29
# File 'lib/bundler/source_list.rb', line 27

def add_rubygems_source(options = {})
  add_source_to_list Source::Rubygems.new(options), @rubygems_sources
end

#add_svn_source(options = {}) ⇒ Object


23
24
25
# File 'lib/bundler/source_list.rb', line 23

def add_svn_source(options = {})
  add_source_to_list Source::SVN.new(options), svn_sources
end

#all_sourcesObject


44
45
46
# File 'lib/bundler/source_list.rb', line 44

def all_sources
  path_sources + git_sources + svn_sources + rubygems_sources
end

#cached!Object


75
76
77
# File 'lib/bundler/source_list.rb', line 75

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

#get(source) ⇒ Object


48
49
50
# File 'lib/bundler/source_list.rb', line 48

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

#lock_sourcesObject


52
53
54
55
# File 'lib/bundler/source_list.rb', line 52

def lock_sources
  lock_sources = (path_sources + git_sources + svn_sources).sort_by(&:to_s)
  lock_sources << combine_rubygems_sources
end

#remote!Object


79
80
81
# File 'lib/bundler/source_list.rb', line 79

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

#replace_sources!(replacement_sources) ⇒ Object


57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/bundler/source_list.rb', line 57

def replace_sources!(replacement_sources)
  return true if replacement_sources.empty?

  [path_sources, git_sources, svn_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

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

#rubygems_remotesObject


40
41
42
# File 'lib/bundler/source_list.rb', line 40

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

#rubygems_sourcesObject


36
37
38
# File 'lib/bundler/source_list.rb', line 36

def rubygems_sources
  @rubygems_sources + [@rubygems_aggregate]
end