From 911403eb5ec2827c422bdd59a6bb10c9b0780e5c Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Tue, 13 Jul 2010 15:05:54 -0700 Subject: Allows the location of binstubs to be specified --- lib/bundler/cli.rb | 4 ++-- spec/runtime/executable_spec.rb | 31 ++++++++++++++++++++----------- spec/support/helpers.rb | 3 ++- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 24379b9e9e..6bcf944de4 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -96,7 +96,7 @@ module Bundler "Only output warnings and errors." method_option "local", :type => :boolean, :banner => "Do not attempt to fetch gems remotely and use the gem cache instead" - method_option "binstubs", :type => :boolean, :banner => + method_option "binstubs", :type => :string, :lazy_default => "bin", :banner => "Generate bin stubs for bundled gems to ./bin" def install(path = nil) opts = options.dup @@ -106,7 +106,7 @@ module Bundler # Can't use Bundler.settings for this because settings needs gemfile.dirname ENV['BUNDLE_GEMFILE'] = opts[:gemfile] if opts[:gemfile] Bundler.settings[:path] = path if path - Bundler.settings[:bin] = 'bin' if opts[:binstubs] + Bundler.settings[:bin] = opts["binstubs"] if opts[:binstubs] Bundler.settings[:disable_shared_gems] = '1' if options["disable-shared-gems"] || path Bundler.settings.without = opts[:without] Bundler.ui.be_quiet! if opts[:quiet] diff --git a/spec/runtime/executable_spec.rb b/spec/runtime/executable_spec.rb index 7cda266f20..da3cbe8d2a 100644 --- a/spec/runtime/executable_spec.rb +++ b/spec/runtime/executable_spec.rb @@ -1,12 +1,14 @@ require "spec_helper" describe "Running bin/* commands" do - it "runs the bundled command when in the bundle" do + before :each do gemfile <<-G source "file://#{gem_repo1}" gem "rack" G + end + it "runs the bundled command when in the bundle" do bundle "install --binstubs" build_gem "rack", "2.0", :to_system => true do |s| @@ -17,12 +19,24 @@ describe "Running bin/* commands" do out.should == "1.0.0" end - it "runs the bundled command when out of the bundle" do - gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - G + it "allows the location of the gem stubs to be specified" do + bundle "install --binstubs gbin" + + bundled_app("bin").should_not exist + bundled_app("gbin/rackup").should exist + + gembin bundled_app("gbin/rackup") + out.should == "1.0.0" + end + + it "allows absolute paths as a specification of where to install bin stubs" do + bundle "install --binstubs #{tmp}/bin" + + gembin tmp("bin/rackup") + out.should == "1.0.0" + end + it "runs the bundled command when out of the bundle" do bundle "install --binstubs" build_gem "rack", "2.0", :to_system => true do |s| @@ -70,11 +84,6 @@ describe "Running bin/* commands" do end it "does not generate bin stubs if the option was not specified" do - gemfile <<-G - source "file://#{gem_repo1}" - gem "rack" - G - bundle "install" bundled_app("bin/rackup").should_not exist diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index a1c202f45e..57b62710bc 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -72,7 +72,8 @@ module Spec def gembin(cmd) lib = File.expand_path("../../../lib", __FILE__) old, ENV['RUBYOPT'] = ENV['RUBYOPT'], "#{ENV['RUBYOPT']} -I#{lib}" - sys_exec(bundled_app("bin/#{cmd}")) + cmd = bundled_app("bin/#{cmd}") unless cmd.to_s.include?("/") + sys_exec(cmd.to_s) ensure ENV['RUBYOPT'] = old end -- cgit v1.2.1