diff options
author | joyicecloud <joyicecloud@gmail.com> | 2013-09-03 15:37:56 -0700 |
---|---|---|
committer | joyicecloud <joyicecloud@gmail.com> | 2013-09-18 14:24:17 -0700 |
commit | 43732e9c1b3a7510d0592d2a2f357855abab18d7 (patch) | |
tree | 7e8de92c9e2c2b10dfdd4b11e420727f0a3890fc /lib/bundler | |
parent | 7bd82641de44de6601a03ae455ce9277bcdf04b0 (diff) | |
download | bundler-43732e9c1b3a7510d0592d2a2f357855abab18d7.tar.gz |
Displays the previous version of the gem when run bundle update
Change code in the 3 source files to display the method locked_gems in
lib/bundler.rb
Add 3 Rspec test in the update directory for each source: rubygems, git,
path.
Diffstat (limited to 'lib/bundler')
-rw-r--r-- | lib/bundler/source.rb | 12 | ||||
-rw-r--r-- | lib/bundler/source/git.rb | 4 | ||||
-rw-r--r-- | lib/bundler/source/git/git_proxy.rb | 2 | ||||
-rw-r--r-- | lib/bundler/source/path.rb | 6 | ||||
-rw-r--r-- | lib/bundler/source/path/installer.rb | 2 | ||||
-rw-r--r-- | lib/bundler/source/rubygems.rb | 9 |
6 files changed, 23 insertions, 12 deletions
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb index c75599f4db..2a7f0944ed 100644 --- a/lib/bundler/source.rb +++ b/lib/bundler/source.rb @@ -1,7 +1,17 @@ module Bundler - module Source + class Source autoload :Rubygems, 'bundler/source/rubygems' autoload :Path, 'bundler/source/path' autoload :Git, 'bundler/source/git' + + def version_message(spec) + locked_spec = Bundler.locked_gems.specs.find { |s| s.name == spec.name } if Bundler.locked_gems + locked_spec_version = locked_spec.version if locked_spec + message = "#{spec.name} (#{spec.version})" + old_version = " was (#{locked_spec_version})" + message << old_version if locked_spec_version && spec.version != locked_spec_version + message + end + end end diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index 0480428c3f..ad41a87e94 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -3,7 +3,7 @@ require 'uri' require 'digest/sha1' module Bundler - module Source + class Source class Git < Path autoload :GitProxy, 'bundler/source/git/git_proxy' @@ -159,7 +159,7 @@ module Bundler @copied = true end generate_bin(spec) - ["Using #{spec.name} (#{spec.version}) from #{to_s}", nil, debug] + ["Using #{version_message(spec)} from #{to_s}", nil, debug] end def cache(spec) diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb index fa398215bc..2a46566c6f 100644 --- a/lib/bundler/source/git/git_proxy.rb +++ b/lib/bundler/source/git/git_proxy.rb @@ -1,5 +1,5 @@ module Bundler - module Source + class Source class Git < Path # The GitProxy is responsible to iteract with git repositories. diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb index b95192fb9a..a6d9ba2b6d 100644 --- a/lib/bundler/source/path.rb +++ b/lib/bundler/source/path.rb @@ -1,7 +1,7 @@ module Bundler - module Source + class Source - class Path + class Path < Source autoload :Installer, 'bundler/source/path/installer' attr_reader :path, :options @@ -71,7 +71,7 @@ module Bundler def install(spec) generate_bin(spec, :disable_extensions) - ["Using #{spec.name} (#{spec.version}) from #{to_s}", nil] + ["Using #{version_message(spec)} from #{to_s}", nil] end def cache(spec) diff --git a/lib/bundler/source/path/installer.rb b/lib/bundler/source/path/installer.rb index 1bfdeac962..448a3b7c85 100644 --- a/lib/bundler/source/path/installer.rb +++ b/lib/bundler/source/path/installer.rb @@ -1,5 +1,5 @@ module Bundler - module Source + class Source class Path class Installer < Bundler::GemInstaller diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index b7fdbd2c7b..1482c318e1 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -3,9 +3,9 @@ require 'rubygems/user_interaction' require 'rubygems/spec_fetcher' module Bundler - module Source + class Source # TODO: Refactor this class - class Rubygems + class Rubygems < Source API_REQUEST_LIMIT = 100 # threshold for switching back to the modern index instead of fetching every spec attr_reader :remotes, :caches @@ -69,10 +69,11 @@ module Bundler def install(spec) if installed_specs[spec].any? - return ["Using #{spec.name} (#{spec.version})", nil] + return ["Using #{version_message(spec)}", nil] + else + install_message = "Installing #{version_message(spec)}" end - install_message = "Installing #{spec.name} (#{spec.version})" path = cached_gem(spec) if Bundler.requires_sudo? install_path = Bundler.tmp |