aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAsutosh Palai <asupalai@gmail.com>2016-06-14 18:42:05 +0530
committerAsutosh Palai <asupalai@gmail.com>2016-07-03 09:40:26 +0530
commit557c0e8999f090e3dd13eeb13797eefad586c13c (patch)
tree3cc9094e427db6e4893b60ccbcb76c05bb3aabe1
parentf0ebe72ea232e5534cb1fa3d5f9d19badcb0c626 (diff)
downloadbundler-557c0e8999f090e3dd13eeb13797eefad586c13c.tar.gz
gems from plugin sources are loading
-rw-r--r--lib/bundler/lockfile_parser.rb2
-rw-r--r--lib/bundler/plugin/api/source.rb2
-rw-r--r--lib/bundler/rubygems_ext.rb2
-rw-r--r--spec/plugins/source.rb41
4 files changed, 31 insertions, 16 deletions
diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb
index cd066e1f..638a308b 100644
--- a/lib/bundler/lockfile_parser.rb
+++ b/lib/bundler/lockfile_parser.rb
@@ -22,7 +22,7 @@ module Bundler
GIT = "GIT".freeze
GEM = "GEM".freeze
PATH = "PATH".freeze
- PLUGIN = "PATH".freeze
+ PLUGIN = "PLUGIN".freeze
SPECS = " specs:".freeze
OPTIONS = /^ ([a-z]+): (.*)$/i
SOURCE = [GIT, GEM, PATH, PLUGIN].freeze
diff --git a/lib/bundler/plugin/api/source.rb b/lib/bundler/plugin/api/source.rb
index dc7406ed..2d16513b 100644
--- a/lib/bundler/plugin/api/source.rb
+++ b/lib/bundler/plugin/api/source.rb
@@ -54,7 +54,7 @@ module Bundler
end
def fetch_gemfiles
- raise "Source plugins need to define fetch_gemfile method"
+ []
end
def options_to_lock
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
index 53db29a9..88c446e1 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -25,7 +25,7 @@ module Gem
attr_writer :full_gem_path unless instance_methods.include?(:full_gem_path=)
def full_gem_path
- if source.respond_to?(:path)
+ if source.respond_to?(:path) || source.is_a?(Bundler::Plugin::API::Source)
Pathname.new(loaded_from).dirname.expand_path(source.root).to_s.untaint
else
rg_full_gem_path
diff --git a/spec/plugins/source.rb b/spec/plugins/source.rb
index 642e91da..e49651d4 100644
--- a/spec/plugins/source.rb
+++ b/spec/plugins/source.rb
@@ -18,12 +18,15 @@ describe "bundler source plugin" do
def fetch_gemfiles
@gemfiles ||= begin
glob = "{,*,*/*}.gemspec"
-
if !cached?
cache_repo
end
-
- Dir["\#{cache_path}/\#{glob}"].sort_by {|p| -p.split(File::SEPARATOR).size }
+ if installed?
+ path = install_path
+ else
+ path = cache_path
+ end
+ Dir["\#{path}/\#{glob}"].sort_by {|p| -p.split(File::SEPARATOR).size }
end
end
@@ -43,7 +46,7 @@ describe "bundler source plugin" do
end
def cache_repo
- `git clone \#{@options["uri"]} \#{cache_path}`
+ `git clone --quiet \#{@options["uri"]} \#{cache_path}`
end
def cached?
@@ -59,8 +62,10 @@ describe "bundler source plugin" do
end
def revision
- Dir.chdir cache_path do
- `git rev-parse --verify \#{@ref}`.strip
+ @revision ||= cached_revision || begin
+ Dir.chdir cache_path do
+ `git rev-parse --verify \#{@ref}`.strip
+ end
end
end
@@ -89,6 +94,10 @@ describe "bundler source plugin" do
end
end
end
+
+ def installed?
+ File.directory?(install_path)
+ end
end
RUBY
end
@@ -96,30 +105,36 @@ describe "bundler source plugin" do
end
it "installs source automatically from #source :type option" do
+ update_repo2 do
+ build_plugin "bundler-source-psource" do |s|
+ s.write "plugins.rb", <<-RUBY
+ class Cheater < Bundler::Plugin::API
+ source "psource", self
+ end
+ RUBY
+ end
+ end
+
install_gemfile <<-G
source "file://#{gem_repo2}"
- source "file://#{lib_path("gitp")}", :type => :gitp do
+ source "file://#{lib_path("gitp")}", :type => :psource do
end
G
- expect(out).to include("Installed plugin bundler-source-gitp")
+ expect(out).to include("Installed plugin bundler-source-psource")
expect(out).to include("Bundle complete!")
end
- it "handles the source option", :focused do
+ it "handles the source option" do
build_git "ma-gitp-gem"
- build_git "ma-gitp-gem2"
install_gemfile <<-G
source "file://#{gem_repo2}"
source "#{lib_path("ma-gitp-gem-1.0")}", :type => :gitp do
gem "ma-gitp-gem"
end
- #gem 'ma-gitp-gem', :git => "#{lib_path("ma-gitp-gem-1.0")}"
- gem 'ma-gitp-gem2', :git => "#{lib_path("ma-gitp-gem2-1.0")}"
G
- puts out
expect(out).to include("Bundle complete!")
should_be_installed("ma-gitp-gem 1.0")
end