diff options
author | Andre Arko <andre@arko.net> | 2014-07-15 16:55:10 +1000 |
---|---|---|
committer | Tim Moore <tmoore@incrementalism.net> | 2014-07-30 14:16:35 +1000 |
commit | ca2a8fa969982322732a969fff18f1ba1f4eadcf (patch) | |
tree | 1910d21522326037bce84a9d1f3bd604e712ed1a | |
parent | ab78e7449ba1c1024de22ff798c6a32fb581abca (diff) | |
download | bundler-ca2a8fa969982322732a969fff18f1ba1f4eadcf.tar.gz |
Encapsulate Definition#sources.
-rw-r--r-- | lib/bundler/cli/cache.rb | 2 | ||||
-rw-r--r-- | lib/bundler/cli/install.rb | 2 | ||||
-rw-r--r-- | lib/bundler/cli/package.rb | 2 | ||||
-rw-r--r-- | lib/bundler/definition.rb | 17 | ||||
-rw-r--r-- | lib/bundler/runtime.rb | 2 |
5 files changed, 17 insertions, 8 deletions
diff --git a/lib/bundler/cli/cache.rb b/lib/bundler/cli/cache.rb index d404676afa..653ead7f56 100644 --- a/lib/bundler/cli/cache.rb +++ b/lib/bundler/cli/cache.rb @@ -23,7 +23,7 @@ module Bundler def setup_cache_all Bundler.settings[:cache_all] = options[:all] if options.key?("all") - if Bundler.definition.sources.any? { |s| !s.is_a?(Source::Rubygems) } && !Bundler.settings[:cache_all] + if Bundler.definition.has_local_dependencies? && !Bundler.settings[:cache_all] Bundler.ui.warn "Your Gemfile contains path and git dependencies. If you want " \ "to package them as well, please pass the --all flag. This will be the default " \ "on Bundler 2.0." diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb index 64f4803a2c..9bb7f68134 100644 --- a/lib/bundler/cli/install.rb +++ b/lib/bundler/cli/install.rb @@ -112,7 +112,7 @@ module Bundler Bundler.ui.warn "Some gems seem to be missing from your vendor/cache directory." end - if Bundler.definition.rubygems_remotes.empty? + unless Bundler.definition.has_rubygems_remotes? Bundler.ui.warn <<-WARN, :wrap => true Your Gemfile has no gem server sources. If you need gems that are \ not already on your machine, add a line like this to your Gemfile: diff --git a/lib/bundler/cli/package.rb b/lib/bundler/cli/package.rb index 9f272a68cb..b2946038c3 100644 --- a/lib/bundler/cli/package.rb +++ b/lib/bundler/cli/package.rb @@ -26,7 +26,7 @@ module Bundler def setup_cache_all Bundler.settings[:cache_all] = options[:all] if options.key?("all") - if Bundler.definition.sources.any? { |s| !s.is_a?(Source::Rubygems) } && !Bundler.settings[:cache_all] + if Bundler.definition.has_local_dependencies? && !Bundler.settings[:cache_all] Bundler.ui.warn "Your Gemfile contains path and git dependencies. If you want " \ "to package them as well, please pass the --all flag. This will be the default " \ "on Bundler 2.0." diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 527c021db8..dd0750ac15 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -5,8 +5,7 @@ module Bundler class Definition include GemHelpers - attr_reader :dependencies, :platforms, :sources, :ruby_version, - :locked_deps + attr_reader :dependencies, :platforms, :ruby_version, :locked_deps # Given a gemfile and lockfile creates a Bundler definition # @@ -232,8 +231,16 @@ module Bundler end end - def rubygems_remotes - @sources.select{|s| s.is_a?(Source::Rubygems) }.map{|s| s.remotes }.flatten + def has_rubygems_remotes? + @sources.any?{|s| s.is_a?(Source::Rubygems) && s.remotes.any? } + end + + def has_local_dependencies? + @sources.any? { |s| !s.is_a?(Source::Rubygems) } + end + + def spec_git_paths + @sources.select {|s| s.is_a?(Bundler::Source::Git) }.map {|s| s.path.to_s } end def groups @@ -393,6 +400,8 @@ module Bundler private + attr_reader :sources + def nothing_changed? !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes end diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb index b3862711cb..b09a8814e5 100644 --- a/lib/bundler/runtime.rb +++ b/lib/bundler/runtime.rb @@ -139,7 +139,7 @@ module Bundler gemspec_files = Dir["#{Gem.dir}/specifications/*.gemspec"] spec_gem_paths = [] # need to keep git sources around - spec_git_paths = @definition.sources.select {|s| s.is_a?(Bundler::Source::Git) }.map {|s| s.path.to_s } + spec_git_paths = @definition.spec_git_paths spec_git_cache_dirs = [] spec_gem_executables = [] spec_cache_paths = [] |