summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsutosh Palai <asupalai@gmail.com>2016-06-09 18:44:45 +0530
committerAsutosh Palai <asupalai@gmail.com>2016-06-09 18:44:47 +0530
commitdf5a8e97044a92965e25a344da89f550ab570956 (patch)
tree895d8d2c292154d6d034a7c37a3cddda340a4244
parent7804310adb9e0b24798ed0cf33f29666a359ea4d (diff)
downloadbundler-df5a8e97044a92965e25a344da89f550ab570956.tar.gz
Added plugin install support for inline Gemfile
-rw-r--r--lib/bundler/inline.rb1
-rw-r--r--lib/bundler/plugin.rb17
-rw-r--r--lib/bundler/plugin/index.rb4
-rw-r--r--lib/bundler/plugin/installer.rb5
-rw-r--r--spec/plugins/install.rb25
-rw-r--r--spec/support/matchers.rb8
6 files changed, 55 insertions, 5 deletions
diff --git a/lib/bundler/inline.rb b/lib/bundler/inline.rb
index b6bddda5dd..01910ce6be 100644
--- a/lib/bundler/inline.rb
+++ b/lib/bundler/inline.rb
@@ -41,6 +41,7 @@ def gemfile(install = false, options = {}, &gemfile)
end
ENV["BUNDLE_GEMFILE"] ||= "Gemfile"
+ Bundler::Plugin.gemfile_install(&gemfile)
builder = Bundler::Dsl.new
builder.instance_eval(&gemfile)
diff --git a/lib/bundler/plugin.rb b/lib/bundler/plugin.rb
index f97de2b20d..9aabd73a42 100644
--- a/lib/bundler/plugin.rb
+++ b/lib/bundler/plugin.rb
@@ -36,8 +36,14 @@ module Bundler
# specified by plugin method
#
# @param [Pathname] gemfile path
- def gemfile_install(gemfile)
- definition = DSL.evaluate(gemfile, nil, {})
+ def gemfile_install(gemfile = nil, &inline)
+ if block_given?
+ builder = DSL.new
+ builder.instance_eval(&inline)
+ definition = builder.to_definition(nil, true)
+ else
+ definition = DSL.evaluate(gemfile, nil, {})
+ end
return unless definition.dependencies.any?
plugins = Installer.new.install_definition(definition)
@@ -80,6 +86,13 @@ module Bundler
@commands[command].new.exec(command, args)
end
+ # currently only intended for specs
+ #
+ # @return [String, nil] installed path
+ def installed?(plugin)
+ Index.new.installed?(plugin)
+ end
+
# Post installation processing and registering with index
#
# @param [Hash] plugins mapped to their installtion path
diff --git a/lib/bundler/plugin/index.rb b/lib/bundler/plugin/index.rb
index a10b023f4b..1e39eb0042 100644
--- a/lib/bundler/plugin/index.rb
+++ b/lib/bundler/plugin/index.rb
@@ -50,6 +50,10 @@ module Bundler
@commands[command]
end
+ def installed?(name)
+ @plugin_paths[name]
+ end
+
private
# Reads the index file from the directory and initializes the instance variables.
diff --git a/lib/bundler/plugin/installer.rb b/lib/bundler/plugin/installer.rb
index 7380977cf4..64d7f8a372 100644
--- a/lib/bundler/plugin/installer.rb
+++ b/lib/bundler/plugin/installer.rb
@@ -30,6 +30,7 @@ module Bundler
def install_definition(definition)
plugins = definition.dependencies.map(&:name)
+ def definition.lock(*); end
definition.resolve_remotely!
specs = definition.specs
@@ -54,7 +55,7 @@ module Bundler
deps = names.map {|name| Dependency.new name, version }
- definition = Definition.new(nil, deps, source_list, {})
+ definition = Definition.new(nil, deps, source_list, true)
install_definition(definition)
end
@@ -72,7 +73,7 @@ module Bundler
source_list = SourceList.new
source_list.add_rubygems_source("remotes" => sources)
- definition = Definition.new(nil, deps, source_list, {})
+ definition = Definition.new(nil, deps, source_list, true)
install_definition(definition)
end
diff --git a/spec/plugins/install.rb b/spec/plugins/install.rb
index 03868832d2..c9c0776f34 100644
--- a/spec/plugins/install.rb
+++ b/spec/plugins/install.rb
@@ -19,6 +19,7 @@ describe "bundler plugin install" do
bundle "plugin install foo --source file://#{gem_repo2}"
expect(out).to include("Installed plugin foo")
+ plugin_should_be_installed("foo")
end
it "installs multiple plugins" do
@@ -26,6 +27,8 @@ describe "bundler plugin install" do
expect(out).to include("Installed plugin foo")
expect(out).to include("Installed plugin kung-foo")
+
+ plugin_should_be_installed("foo", "kung-foo")
end
it "uses the same version for multiple plugins" do
@@ -38,6 +41,7 @@ describe "bundler plugin install" do
expect(out).to include("Installing foo 1.0")
expect(out).to include("Installing kung-foo 1.0")
+ plugin_should_be_installed("foo", "kung-foo")
end
context "malformatted plugin" do
@@ -81,6 +85,7 @@ describe "bundler plugin install" do
bundle "plugin install foo --git file://#{lib_path("foo-1.0")}"
expect(out).to include("Installed plugin foo")
+ plugin_should_be_installed("foo")
end
end
@@ -99,6 +104,7 @@ describe "bundler plugin install" do
expect(out).to include("Bundle complete!")
should_be_installed("rack 1.0.0")
+ plugin_should_be_installed("foo")
end
it "accepts plugin version" do
@@ -115,7 +121,7 @@ describe "bundler plugin install" do
expect(out).to include("Installing foo 1.0")
- expect(out).to include("Installed plugin foo")
+ plugin_should_be_installed("foo")
expect(out).to include("Bundle complete!")
end
@@ -130,6 +136,23 @@ describe "bundler plugin install" do
G
expect(out).to include("Installed plugin ga-plugin")
+ plugin_should_be_installed("ga-plugin")
+ end
+ end
+
+ context "inline gemfiles" do
+ it "installs the listed plugins" do
+ code = <<-RUBY
+ require "bundler/inline"
+
+ gemfile do
+ source 'file://#{gem_repo2}'
+ plugin 'foo'
+ end
+ RUBY
+
+ ruby code
+ plugin_should_be_installed("foo")
end
end
end
diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb
index 7047e1be76..76b0c32eef 100644
--- a/spec/support/matchers.rb
+++ b/spec/support/matchers.rb
@@ -63,6 +63,14 @@ module Spec
end
end
+ def plugin_should_be_installed(*names)
+ names.each do |name|
+ path = Plugin.installed?(name)
+ expect(path).to be_truthy
+ expect(Pathname.new(path).join("plugins.rb")).to exist
+ end
+ end
+
def should_be_locked
expect(bundled_app("Gemfile.lock")).to exist
end