Class: Bundler::SourceList
- Inherits:
-
Object
- Object
- Bundler::SourceList
- Defined in:
- lib/bundler/source_list.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#git_sources ⇒ Object
readonly
Returns the value of attribute git_sources.
-
#global_path_source ⇒ Object
readonly
Returns the value of attribute global_path_source.
-
#metadata_source ⇒ Object
readonly
Returns the value of attribute metadata_source.
-
#path_sources ⇒ Object
readonly
Returns the value of attribute path_sources.
-
#plugin_sources ⇒ Object
readonly
Returns the value of attribute plugin_sources.
Instance Method Summary collapse
- #add_git_source(options = {}) ⇒ Object
- #add_path_source(options = {}) ⇒ Object
- #add_plugin_source(source, options = {}) ⇒ Object
- #add_rubygems_remote(uri) ⇒ Object
- #add_rubygems_source(options = {}) ⇒ Object
- #all_sources ⇒ Object
- #cached! ⇒ Object
- #default_source ⇒ Object
- #get(source) ⇒ Object
- #global_rubygems_source ⇒ Object
- #global_rubygems_source=(uri) ⇒ Object
-
#initialize ⇒ SourceList
constructor
A new instance of SourceList.
- #lock_sources ⇒ Object
- #remote! ⇒ Object
-
#replace_sources!(replacement_sources) ⇒ Object
Returns true if there are changes.
- #rubygems_remotes ⇒ Object
- #rubygems_sources ⇒ Object
Constructor Details
#initialize ⇒ SourceList
Returns a new instance of SourceList.
15 16 17 18 19 20 21 22 23 |
# File 'lib/bundler/source_list.rb', line 15 def initialize @path_sources = [] @git_sources = [] @plugin_sources = [] @global_rubygems_source = nil @global_path_source = nil @rubygems_sources = [] @metadata_source = Source::Metadata.new end |
Instance Attribute Details
#git_sources ⇒ Object (readonly)
Returns the value of attribute git_sources.
5 6 7 |
# File 'lib/bundler/source_list.rb', line 5 def git_sources @git_sources end |
#global_path_source ⇒ Object (readonly)
Returns the value of attribute global_path_source.
5 6 7 |
# File 'lib/bundler/source_list.rb', line 5 def global_path_source @global_path_source end |
#metadata_source ⇒ Object (readonly)
Returns the value of attribute metadata_source.
5 6 7 |
# File 'lib/bundler/source_list.rb', line 5 def @metadata_source end |
#path_sources ⇒ Object (readonly)
Returns the value of attribute path_sources.
5 6 7 |
# File 'lib/bundler/source_list.rb', line 5 def path_sources @path_sources end |
#plugin_sources ⇒ Object (readonly)
Returns the value of attribute plugin_sources.
5 6 7 |
# File 'lib/bundler/source_list.rb', line 5 def plugin_sources @plugin_sources end |
Instance Method Details
#add_git_source(options = {}) ⇒ Object
35 36 37 38 39 |
# File 'lib/bundler/source_list.rb', line 35 def add_git_source( = {}) add_source_to_list(Source::Git.new(), git_sources).tap do |source| warn_on_git_protocol(source) end end |
#add_path_source(options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/bundler/source_list.rb', line 25 def add_path_source( = {}) if ["gemspec"] add_source_to_list Source::Gemspec.new(), path_sources else path_source = add_source_to_list Source::Path.new(), path_sources @global_path_source ||= path_source if ["global"] path_source end end |
#add_plugin_source(source, options = {}) ⇒ Object
45 46 47 |
# File 'lib/bundler/source_list.rb', line 45 def add_plugin_source(source, = {}) add_source_to_list Plugin.source(source).new(), @plugin_sources end |
#add_rubygems_remote(uri) ⇒ Object
53 54 55 56 |
# File 'lib/bundler/source_list.rb', line 53 def add_rubygems_remote(uri) global_rubygems_source.add_remote(uri) global_rubygems_source end |
#add_rubygems_source(options = {}) ⇒ Object
41 42 43 |
# File 'lib/bundler/source_list.rb', line 41 def add_rubygems_source( = {}) add_source_to_list Source::Rubygems.new(), @rubygems_sources end |
#all_sources ⇒ Object
70 71 72 |
# File 'lib/bundler/source_list.rb', line 70 def all_sources path_sources + git_sources + plugin_sources + rubygems_sources + [] end |
#cached! ⇒ Object
106 107 108 |
# File 'lib/bundler/source_list.rb', line 106 def cached! all_sources.each(&:cached!) end |
#default_source ⇒ Object
58 59 60 |
# File 'lib/bundler/source_list.rb', line 58 def default_source global_path_source || global_rubygems_source end |
#get(source) ⇒ Object
74 75 76 |
# File 'lib/bundler/source_list.rb', line 74 def get(source) source_list_for(source).find {|s| equal_source?(source, s) || equivalent_source?(source, s) } end |
#global_rubygems_source ⇒ Object
11 12 13 |
# File 'lib/bundler/source_list.rb', line 11 def global_rubygems_source @global_rubygems_source ||= rubygems_aggregate_class.new end |
#global_rubygems_source=(uri) ⇒ Object
49 50 51 |
# File 'lib/bundler/source_list.rb', line 49 def global_rubygems_source=(uri) @global_rubygems_source ||= rubygems_aggregate_class.new("remotes" => uri) end |
#lock_sources ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/bundler/source_list.rb', line 78 def lock_sources lock_sources = (path_sources + git_sources + plugin_sources).sort_by(&:to_s) if Bundler.feature_flag.disable_multisource? lock_sources + rubygems_sources.sort_by(&:to_s) else lock_sources << combine_rubygems_sources end end |
#remote! ⇒ Object
110 111 112 |
# File 'lib/bundler/source_list.rb', line 110 def remote! all_sources.each(&:remote!) end |
#replace_sources!(replacement_sources) ⇒ Object
Returns true if there are changes
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/bundler/source_list.rb', line 88 def replace_sources!(replacement_sources) return true if replacement_sources.empty? [path_sources, git_sources, plugin_sources].each do |source_list| source_list.map! do |source| replacement_sources.find {|s| s == source } || source end end replacement_rubygems = !Bundler.feature_flag.disable_multisource? && replacement_sources.detect {|s| s.is_a?(Source::Rubygems) } @global_rubygems_source = replacement_rubygems if replacement_rubygems return true if !equal_sources?(lock_sources, replacement_sources) && !equivalent_sources?(lock_sources, replacement_sources) false end |
#rubygems_remotes ⇒ Object
66 67 68 |
# File 'lib/bundler/source_list.rb', line 66 def rubygems_remotes rubygems_sources.map(&:remotes).flatten.uniq end |
#rubygems_sources ⇒ Object
62 63 64 |
# File 'lib/bundler/source_list.rb', line 62 def rubygems_sources @rubygems_sources + [global_rubygems_source] end |