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

Commit

Permalink
Install executable wrappers for git and path sources
Browse files Browse the repository at this point in the history
  • Loading branch information
Carl Lerche committed Feb 6, 2010
1 parent 2d05242 commit 92847ec
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 5 deletions.
2 changes: 2 additions & 0 deletions lib/bundler/installer.rb
Expand Up @@ -21,7 +21,9 @@ def run(options)
Bundler.ui.debug " * Not in requested group; skipping."
next
end

spec.source.install(spec)

Bundler.ui.info ""
end

Expand Down
27 changes: 25 additions & 2 deletions lib/bundler/source.rb
Expand Up @@ -118,8 +118,11 @@ def install(spec)

Bundler.ui.debug " * Installing from pack"
installer = Gem::Installer.new "#{@path}/#{spec.full_name}.gem",
:install_dir => Gem.dir,
:ignore_dependencies => true
:install_dir => Gem.dir,
:ignore_dependencies => true,
:wrappers => true,
:env_shebang => true,
:bin_dir => "#{Gem.dir}/bin"

installer.install
end
Expand Down Expand Up @@ -176,10 +179,29 @@ def local_specs

def install(spec)
Bundler.ui.debug " * Using path #{path}"
generate_bin(spec)
end

alias specs local_specs

private

def generate_bin(spec)
# HAX -- Generate the bin
bin_dir = "#{Gem.dir}/bin"
gem_dir = spec.full_gem_path
installer = Gem::Installer.allocate
installer.instance_eval do
@spec = spec
@bin_dir = bin_dir
@gem_dir = gem_dir
@wrappers = true
@env_shebang = false
@format_executable = false
end
installer.generate_bin
end

end

class Git < Path
Expand Down Expand Up @@ -241,6 +263,7 @@ def install(spec)
checkout
@installed = true
end
generate_bin(spec)
end

def lock
Expand Down
11 changes: 8 additions & 3 deletions spec/install/git_spec.rb
Expand Up @@ -3,9 +3,9 @@
describe "gemfile install with git sources" do
describe "when floating on master" do
before :each do
in_app_root

build_git "foo"
build_git "foo" do |s|
s.executables = "foobar"
end

install_gemfile <<-G
git "#{lib_path('foo-1.0')}"
Expand Down Expand Up @@ -43,6 +43,11 @@
out.should == "WIN"
end
end

it "setups executables" do
bundle "exec foobar"
out.should == "1.0"
end
end

describe "when specifying a revision" do
Expand Down
14 changes: 14 additions & 0 deletions spec/install/path_spec.rb
Expand Up @@ -60,6 +60,20 @@
should_be_installed "foo 1.0"
end

it "setups up executables" do
build_lib "foo" do |s|
s.executables = "foobar"
end

install_gemfile <<-G
path "#{lib_path('foo-1.0')}"
gem 'foo'
G

bundle "exec foobar"
out.should == "1.0"
end

describe "when locked" do
it "keeps source pinning" do
build_lib "foo", "1.0", :path => lib_path('foo')
Expand Down

0 comments on commit 92847ec

Please sign in to comment.