Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

First pass at output

  • Loading branch information...
commit 434fb42ade8e9a8d35e340fb48f1e3c7ca8c0668 1 parent ba90c2d
Carlhuda authored
View
9 lib/bundler.rb
@@ -16,12 +16,21 @@ module Bundler
autoload :Resolver, 'bundler/resolver'
autoload :Source, 'bundler/source'
autoload :Specification, 'bundler/specification'
+ autoload :UI, 'bundler/ui'
class GemfileNotFound < StandardError; end
class GemNotFound < StandardError; end
class VersionConflict < StandardError; end
class GemfileError < StandardError; end
+ def self.ui
+ @ui ||= UI.new
+ end
+
+ def self.ui=(ui)
+ @ui = ui
+ end
+
def self.setup(gemfile = default_gemfile)
load(gemfile).setup
end
View
5 lib/bundler/cli.rb
@@ -22,6 +22,11 @@ def init
end
end
+ def initialize(*)
+ super
+ Bundler.ui = UI::Shell.new(shell)
+ end
+
desc "check", "Checks if the dependencies listed in Gemfile are satisfied by currently installed gems"
def check
with_rescue do
View
22 lib/bundler/installer.rb
@@ -14,10 +14,17 @@ def initialize(root, definition)
end
def run
+ if dependencies.empty?
+ Bundler.ui.warn "The Gemfile specifies no dependencies"
+ return
+ end
+
specs.each do |spec|
next unless spec.source.respond_to?(:install)
spec.source.install(spec)
end
+
+ Bundler.ui.confirm "You have bundles. Now, go have fun."
end
def dependencies
@@ -25,7 +32,7 @@ def dependencies
end
def specs
- @specs ||= resolve_locally || Resolver.resolve(dependencies, index)
+ @specs ||= resolve_locally || resolve_remotely
end
private
@@ -47,6 +54,14 @@ def resolve_locally
nil
end
+ def resolve_remotely
+ index # trigger building the index
+ Bundler.ui.info "Resolving dependencies... "
+ specs = Resolver.resolve(dependencies, index)
+ Bundler.ui.info "Done."
+ specs
+ end
+
def unambiguous?(dep)
dep.version_requirements.requirements.all? { |op,_| op == '=' }
end
@@ -60,7 +75,10 @@ def index
end
sources.reverse_each do |source|
- index = index.merge(source.specs)
+ specs = source.specs
+ Bundler.ui.info "Source: Processing index... "
+ index = index.merge(specs)
+ Bundler.ui.info "Done."
end
index
View
10 lib/bundler/source.rb
@@ -19,27 +19,35 @@ def specs
end
def install(spec)
- return if Index.from_installed_gems[spec].any?
+ if Index.from_installed_gems[spec].any?
+ Bundler.ui.info "* #{spec.name} (#{spec.version}) is already installed... skipping"
+ return
+ end
destination = Gem.dir
+ Bundler.ui.info "* Downloading #{spec.name} (#{spec.version})... "
gem_path = Gem::RemoteFetcher.fetcher.download(spec, uri, destination)
+ Bundler.ui.info "Installing... "
installer = Gem::Installer.new gem_path,
:install_dir => Gem.dir,
:ignore_dependencies => true
installer.install
+ Bundler.ui.info "Done."
end
private
def fetch_specs
index = Index.new
+ Bundler.ui.info "Source: Fetching remote index for `#{uri}`... "
(main_specs + prerelease_specs).each do |name, version, platform|
spec = RemoteSpecification.new(name, version, platform, @uri)
spec.source = self
index << spec
end
+ Bundler.ui.info "done."
index
end
View
37 lib/bundler/ui.rb
@@ -0,0 +1,37 @@
+module Bundler
+ class UI
+ def warn(message)
+ end
+
+ def error(message)
+ end
+
+ def info(message)
+ end
+
+ def confirm(message)
+ end
+
+ class Shell < UI
+ def initialize(shell)
+ @shell = shell
+ end
+
+ def info(msg)
+ @shell.say(msg)
+ end
+
+ def confirm(msg)
+ @shell.say(msg, :green)
+ end
+
+ def warn(msg)
+ @shell.say(msg, :yellow)
+ end
+
+ def error(msg)
+ @shell.say(msg, :error)
+ end
+ end
+ end
+end
View
9 spec/install/gems_spec.rb
@@ -5,6 +5,15 @@
in_app_root
end
+ it "prints output and returns if no dependencies are specified" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ G
+
+ bundle :install
+ out.should =~ /no dependencies/
+ end
+
it "fetches gems" do
install_gemfile <<-G
source "file://#{gem_repo1}"
Please sign in to comment.
Something went wrong with that request. Please try again.