diff options
author | Carlhuda <carlhuda@engineyard.com> | 2010-01-26 16:19:55 -0800 |
---|---|---|
committer | Carlhuda <carlhuda@engineyard.com> | 2010-01-26 16:19:55 -0800 |
commit | 434fb42ade8e9a8d35e340fb48f1e3c7ca8c0668 (patch) | |
tree | da643595a758ad64e8d6b20b232e93bfd1198038 | |
parent | ba90c2d5aaf3ab2eb272e809963276f2c16d179f (diff) | |
download | bundler-434fb42ade8e9a8d35e340fb48f1e3c7ca8c0668.tar.gz |
First pass at output
-rw-r--r-- | lib/bundler.rb | 9 | ||||
-rw-r--r-- | lib/bundler/cli.rb | 5 | ||||
-rw-r--r-- | lib/bundler/installer.rb | 22 | ||||
-rw-r--r-- | lib/bundler/source.rb | 10 | ||||
-rw-r--r-- | lib/bundler/ui.rb | 37 | ||||
-rw-r--r-- | spec/install/gems_spec.rb | 9 |
6 files changed, 89 insertions, 3 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb index 93925374c2..2a53e2ee6b 100644 --- a/lib/bundler.rb +++ b/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 diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index eac8723bef..12b8124a64 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -22,6 +22,11 @@ module Bundler 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 diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb index 0ce8b4ca5b..bdde4628ba 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -14,10 +14,17 @@ module Bundler 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 @@ module Bundler end def specs - @specs ||= resolve_locally || Resolver.resolve(dependencies, index) + @specs ||= resolve_locally || resolve_remotely end private @@ -47,6 +54,14 @@ module Bundler 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 @@ module Bundler 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 diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb index f2ff5f9e05..d907adff62 100644 --- a/lib/bundler/source.rb +++ b/lib/bundler/source.rb @@ -19,27 +19,35 @@ module Bundler 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 diff --git a/lib/bundler/ui.rb b/lib/bundler/ui.rb new file mode 100644 index 0000000000..26dfb50fba --- /dev/null +++ b/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
\ No newline at end of file diff --git a/spec/install/gems_spec.rb b/spec/install/gems_spec.rb index d06810df0a..fa7b6cd691 100644 --- a/spec/install/gems_spec.rb +++ b/spec/install/gems_spec.rb @@ -5,6 +5,15 @@ describe "gemfile install with gem sources" do 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}" |