diff options
-rw-r--r-- | lib/bundler/plugin/api/source.rb | 18 | ||||
-rw-r--r-- | spec/plugins/source/example_spec.rb | 20 | ||||
-rw-r--r-- | spec/support/builders.rb | 2 |
3 files changed, 39 insertions, 1 deletions
diff --git a/lib/bundler/plugin/api/source.rb b/lib/bundler/plugin/api/source.rb index 4179f82498..78514563f7 100644 --- a/lib/bundler/plugin/api/source.rb +++ b/lib/bundler/plugin/api/source.rb @@ -84,6 +84,24 @@ module Bundler raise MalformattedPlugin, "Source plugins need to override the install method." end + # It builds extensions, generates bins and installs them for the spec + # provided. + # + # It depends on `spec.loaded_from` to get full_gem_path. The source + # plugins should set that. + # + # It should be called in `install` after the plugin is done placing the + # gem at correct install location. + # + # It also runs Gem hooks `post_install`, `post_build` and `post_install` + # + # Note: Do not override if you don't know what you are doing. + def post_install(spec, disable_exts = false) + opts = { :env_shebang => false, :disable_extensions => disable_exts } + installer = Bundler::Source::Path::Installer.new(spec, opts) + installer.post_install + end + # A default installation path to install a single gem. If the source # servers multiple gems, it's not of much use and the source should one # of its own. diff --git a/spec/plugins/source/example_spec.rb b/spec/plugins/source/example_spec.rb index c969ad92dc..b21ac1f638 100644 --- a/spec/plugins/source/example_spec.rb +++ b/spec/plugins/source/example_spec.rb @@ -37,6 +37,8 @@ describe "real source plugins" do mkdir_p(install_path.parent) FileUtils.cp_r(path, install_path) + post_install(spec) + nil end end @@ -95,6 +97,22 @@ describe "real source plugins" do expect(out).to eq(bundle("show a-path-gem")) end + it "installs the gem executables", :focused do + build_lib "gem-with-bin" do |s| + s.executables = ["foo"] + end + + install_gemfile <<-G + source "file://#{gem_repo2}" # plugin source + source "#{lib_path("gem-with-bin-1.0")}", :type => :mpath do + gem "gem-with-bin" + end + G + + bundle "exec foo" + expect(out).to eq("1.0") + end + describe "bundle cache/package" do let(:uri_hash) { Digest::SHA1.hexdigest(lib_path("a-path-gem-1.0").to_s) } it "copies repository to vendor cache and uses it" do @@ -210,6 +228,8 @@ describe "real source plugins" do `git reset --hard \#{revision}` end + post_install + nil end diff --git a/spec/support/builders.rb b/spec/support/builders.rb index 99acadc5d0..d091ff69a9 100644 --- a/spec/support/builders.rb +++ b/spec/support/builders.rb @@ -532,7 +532,7 @@ module Spec @spec.executables.each do |file| executable = "#{@spec.bindir}/#{file}" @spec.files << executable - write executable, "#!/usr/bin/env ruby\nrequire '#{@name}' ; puts #{@name.upcase}" + write executable, "#!/usr/bin/env ruby\nrequire '#{@name}' ; puts #{Builders.constantize(@name)}" end end |