Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Summarize the number of using gems
Browse files Browse the repository at this point in the history
  • Loading branch information
hbd225 committed Jul 26, 2015
1 parent 58e103d commit 0fa607d
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 18 deletions.
1 change: 1 addition & 0 deletions lib/bundler/cli/install.rb
Expand Up @@ -105,6 +105,7 @@ def run
Installer.install(Bundler.root, definition, options)
Bundler.load.cache if Bundler.app_cache.exist? && options["cache"] && !Bundler.settings[:frozen]

Bundler.ui.confirm "Using #{Installer.using_gems.size} already installed gems" if Installer.using_gems.size > 0
Bundler.ui.confirm "Bundle complete! #{dependencies_count_for(definition)}, #{gems_installed_for(definition)}."
confirm_without_groups

Expand Down
1 change: 1 addition & 0 deletions lib/bundler/cli/update.rb
Expand Up @@ -56,6 +56,7 @@ def run
Bundler::CLI::Clean.new(options).run
end

Bundler.ui.confirm "Using #{Installer.using_gems.size} already installed gems" if Installer.using_gems.size > 0
Bundler.ui.confirm "Bundle updated!"
without_groups_messages
end
Expand Down
3 changes: 2 additions & 1 deletion lib/bundler/installer.rb
Expand Up @@ -5,10 +5,11 @@
module Bundler
class Installer < Environment
class << self
attr_accessor :post_install_messages, :ambiguous_gems
attr_accessor :post_install_messages, :ambiguous_gems, :using_gems

Installer.post_install_messages = {}
Installer.ambiguous_gems = []
Installer.using_gems = []
end

# Begins the installation process for Bundler.
Expand Down
3 changes: 2 additions & 1 deletion lib/bundler/source/git.rb
Expand Up @@ -159,7 +159,8 @@ def specs(*)
end

def install(spec, force = false)
Bundler.ui.info "Using #{version_message(spec)} from #{to_s}"
Bundler.ui.debug "Using #{version_message(spec)} from #{to_s}"
Bundler::Installer.using_gems << spec

if requires_checkout? && !@copied && !force
Bundler.ui.debug " * Checking out revision: #{ref}"
Expand Down
3 changes: 2 additions & 1 deletion lib/bundler/source/path.rb
Expand Up @@ -69,7 +69,8 @@ def name
end

def install(spec, force = false)
Bundler.ui.info "Using #{version_message(spec)} from #{to_s}"
Bundler.ui.debug "Using #{version_message(spec)} from #{to_s}"
Bundler::Installer.using_gems << spec
generate_bin(spec, :disable_extensions)
nil # no post-install message
end
Expand Down
3 changes: 2 additions & 1 deletion lib/bundler/source/rubygems.rb
Expand Up @@ -99,7 +99,8 @@ def install(spec, opts = {})
end

if installed?(spec) && (!force || spec.name.eql?("bundler"))
Bundler.ui.info "Using #{version_message(spec)}"
Bundler.ui.debug "Using #{version_message(spec)}"
Bundler::Installer.using_gems << spec
return nil # no post-install message
end

Expand Down
21 changes: 20 additions & 1 deletion spec/commands/update_spec.rb
Expand Up @@ -182,7 +182,7 @@
gem "activesupport"
G

bundle "update"
bundle "update --verbose"
expect(out).to include("Using activesupport 2.3.5")

update_repo2 do
Expand All @@ -203,4 +203,23 @@
expect(err).to include("This Bundle hasn't been installed yet. Run `bundle install` to update and install the bundled gems.")
expect(exitstatus).to eq(22) if exitstatus
end

it "shows the summary of the using gems" do
build_repo2

install_gemfile <<-G
source "file://#{gem_repo2}"
gem "activesupport"
G

bundle "update --verbose"
expect(out).to include("Using activesupport 2.3.5")

update_repo2 do
build_gem "activesupport", "3.0"
end

bundle "update"
expect(out).to include("Using 1 already installed gems")
end
end
2 changes: 0 additions & 2 deletions spec/install/force_spec.rb
Expand Up @@ -17,7 +17,6 @@
bundle "install --force"

expect(exitstatus).to eq(0) if exitstatus
expect(out).to include "Using bundler"
expect(out).to include "Installing rack 1.0.0"
expect(rack_lib.open(&:read)).to eq("RACK = '1.0.0'\n")
should_be_installed "rack 1.0.0"
Expand All @@ -27,7 +26,6 @@
bundle "install --force"

expect(exitstatus).to eq(0) if exitstatus
expect(out).to include "Using bundler"
expect(out).to include "Installing rack 1.0.0"
should_be_installed "rack 1.0.0"
end
Expand Down
2 changes: 1 addition & 1 deletion spec/install/gemfile/git_spec.rb
Expand Up @@ -187,7 +187,7 @@
G

bundle %|config local.rack #{lib_path("local-rack")}|
bundle :install
bundle "install --verbose"
expect(out).to match(/at #{lib_path('local-rack')}/)

run "require 'rack'"
Expand Down
6 changes: 3 additions & 3 deletions spec/runtime/setup_spec.rb
Expand Up @@ -411,7 +411,7 @@
G

bundle %|config local.rack #{lib_path("local-rack")}|
bundle :install
bundle "install --verbose"
expect(out).to match(/at #{lib_path('local-rack')}/)

FileUtils.rm_rf(lib_path("local-rack"))
Expand All @@ -430,7 +430,7 @@
G

bundle %|config local.rack #{lib_path("local-rack")}|
bundle :install
bundle "install --verbose"
expect(out).to match(/at #{lib_path('local-rack')}/)

gemfile <<-G
Expand All @@ -453,7 +453,7 @@
G

bundle %|config local.rack #{lib_path("local-rack")}|
bundle :install
bundle "install --verbose"
expect(out).to match(/at #{lib_path('local-rack')}/)

gemfile <<-G
Expand Down
30 changes: 28 additions & 2 deletions spec/update/git_spec.rb
Expand Up @@ -31,7 +31,7 @@
gem "rails", :git => "#{lib_path("rails")}"
G

bundle "update rails"
bundle "update rails --verbose"
expect(out).to include("Using activesupport 3.0 from #{lib_path("rails")} (at master)")
should_be_installed "rails 3.0", "activesupport 3.0"
end
Expand Down Expand Up @@ -208,7 +208,7 @@
expect(out).to include("Bundle updated!")
end

it "shows the previous version of the gem" do
it "shows the summary of the using gems" do
build_git "rails", "3.0", :path => lib_path("rails")

install_gemfile <<-G
Expand All @@ -229,6 +229,32 @@
G

bundle "update"
expect(out).to include("Using 2 already installed gems")
end
end

describe "with --verbose option" do
it "shows the previous version of the gem" do
build_git "rails", "3.0", :path => lib_path("rails")

install_gemfile <<-G
gem "rails", :git => "#{lib_path("rails")}"
G

lockfile <<-G
GIT
remote: #{lib_path("rails")}
specs:
rails (2.3.2)
PLATFORMS
#{generic(Gem::Platform.local)}
DEPENDENCIES
rails!
G

bundle "update --verbose"
expect(out).to include("Using rails 3.0 (was 2.3.2) from #{lib_path("rails")} (at master)")
end
end
Expand Down
25 changes: 20 additions & 5 deletions spec/update/path_spec.rb
@@ -1,18 +1,33 @@
require "spec_helper"

describe "path sources" do
describe "bundle update --source" do
it "shows the previous version of the gem when updated from path source" do
describe "bundle update" do
describe "path sources" do
it "shows the summary of the using gems" do
build_lib "activesupport", "2.3.5", :path => lib_path("rails/activesupport")

install_gemfile <<-G
gem "activesupport", :path => "#{lib_path("rails/activesupport")}"
gem "activesupport", :path => "#{lib_path("rails/activesupport")}"
G

build_lib "activesupport", "3.0", :path => lib_path("rails/activesupport")

bundle "update --source activesupport"
expect(out).to include("Using activesupport 3.0 (was 2.3.5) from source at #{lib_path("rails/activesupport")}")
expect(out).to include("Using 2 already installed gems")
end

describe "with --verbose option" do
it "shows the previous version of the gem" do
build_lib "activesupport", "2.3.5", :path => lib_path("rails/activesupport")

install_gemfile <<-G
gem "activesupport", :path => "#{lib_path("rails/activesupport")}"
G

build_lib "activesupport", "3.0", :path => lib_path("rails/activesupport")

bundle "update --source activesupport --verbose"
expect(out).to include("Using activesupport 3.0 (was 2.3.5) from source at #{lib_path("rails/activesupport")}")
end
end
end
end

0 comments on commit 0fa607d

Please sign in to comment.