diff options
author | Carl Lerche <carllerche@mac.com> | 2010-07-09 11:36:02 -0700 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2010-07-09 16:32:50 -0700 |
commit | 25ab2dc405bce75fd9b1faff2b37fa79b5c2235d (patch) | |
tree | 513474fc808e5a69e416bd663f8dfbdf0d57c044 | |
parent | 33121dc148750bbae4858a381b081b2b4e3a3afc (diff) | |
download | bundler-25ab2dc405bce75fd9b1faff2b37fa79b5c2235d.tar.gz |
Make generating bin stubs an option
-rw-r--r-- | lib/bundler.rb | 3 | ||||
-rw-r--r-- | lib/bundler/cli.rb | 3 | ||||
-rw-r--r-- | lib/bundler/installer.rb | 2 | ||||
-rw-r--r-- | spec/runtime/executable_spec.rb | 46 |
4 files changed, 48 insertions, 6 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb index bbec5c2d64..eff89f2537 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -82,7 +82,8 @@ module Bundler def bin_path @bin_path ||= begin - path = settings[:bin] || "#{root}/bin" + path = settings[:bin] || "bin" + path = Pathname.new(path).expand_path(root) FileUtils.mkdir_p(path) Pathname.new(path).expand_path end diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 3176d0f2da..411b262800 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -96,6 +96,8 @@ 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 => + "Generate bin stubs for bundled gems to ./bin" def install(path = nil) opts = options.dup opts[:without] ||= [] @@ -104,6 +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[: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/lib/bundler/installer.rb b/lib/bundler/installer.rb index 839a78c678..7d9c664af9 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -37,7 +37,7 @@ module Bundler spec.source.install(spec) Bundler.ui.info "" - generate_bundler_executable_stubs(spec) + generate_bundler_executable_stubs(spec) if Bundler.settings[:bin] FileUtils.rm_rf(Bundler.tmp) end diff --git a/spec/runtime/executable_spec.rb b/spec/runtime/executable_spec.rb index e604682768..7cda266f20 100644 --- a/spec/runtime/executable_spec.rb +++ b/spec/runtime/executable_spec.rb @@ -2,11 +2,13 @@ require "spec_helper" describe "Running bin/* commands" do it "runs the bundled command when in the bundle" do - install_gemfile <<-G + gemfile <<-G source "file://#{gem_repo1}" gem "rack" G + bundle "install --binstubs" + build_gem "rack", "2.0", :to_system => true do |s| s.executables = "rackup" end @@ -16,11 +18,13 @@ describe "Running bin/* commands" do end it "runs the bundled command when out of the bundle" do - install_gemfile <<-G + gemfile <<-G source "file://#{gem_repo1}" gem "rack" G + bundle "install --binstubs" + build_gem "rack", "2.0", :to_system => true do |s| s.executables = "rackup" end @@ -36,10 +40,12 @@ describe "Running bin/* commands" do s.executables = 'rackup' end - install_gemfile <<-G + gemfile <<-G gem "rack", :path => "#{lib_path('rack')}" G + bundle "install --binstubs" + build_gem 'rack', '2.0', :to_system => true do |s| s.executables = 'rackup' end @@ -53,11 +59,43 @@ describe "Running bin/* commands" do s.executables = "bundle" end - install_gemfile <<-G + gemfile <<-G source "file://#{gem_repo1}" gem "bundler" G + bundle "install --binstubs" + bundled_app("bin/bundle").should_not exist 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 + end + + it "remembers that the option was specified" do + gemfile <<-G + source "file://#{gem_repo1}" + gem "activesupport" + G + + bundle "install --binstubs" + + gemfile <<-G + source "file://#{gem_repo1}" + gem "activesupport" + gem "rack" + G + + bundle "install" + + bundled_app("bin/rackup").should exist + end end
\ No newline at end of file |