Skip to content

Commit d09e24b

Browse files
ccutrerhsbt
authored andcommitted
Change how plugin deps are identified
Since #8486, hax to make any dependency type work inside bundler have been removed, so we mark plugins as type: :plugin. Instead, follow that PR's lead and just make it a dedicated option to Bundler::Dependency.
1 parent ad25ac8 commit d09e24b

5 files changed

Lines changed: 11 additions & 15 deletions

File tree

bundler/lib/bundler/definition.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def requested_dependencies
286286
end
287287

288288
def plugin_dependencies
289-
requested_dependencies.select {|dep| dep.type == :plugin }
289+
requested_dependencies.select(&:plugin?)
290290
end
291291

292292
def current_dependencies
@@ -1350,9 +1350,9 @@ def remove_plugin_dependencies_if_necessary
13501350
return if Bundler.settings[:plugins_in_lockfile]
13511351
# we already have plugin dependencies in the lockfile; continue to do so regardless
13521352
# of the current setting
1353-
return if @dependencies.any? {|d| d.type == :plugin && @locked_deps.key?(d.name) }
1353+
return if @dependencies.any? {|d| d.plugin? && @locked_deps.key?(d.name) }
13541354

1355-
@dependencies.reject! {|d| d.type == :plugin }
1355+
@dependencies.reject!(&:plugin?)
13561356
end
13571357
end
13581358
end

bundler/lib/bundler/dependency.rb

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,7 @@ module Bundler
77
class Dependency < Gem::Dependency
88
def initialize(name, version, options = {}, &blk)
99
type = options["type"] || :runtime
10-
if type == :plugin
11-
# RubyGems doesn't support plugin type, which only
12-
# makes sense in the context of Bundler, so bypass
13-
# the RubyGems validation
14-
super(name, version, :runtime)
15-
@type = type
16-
else
17-
super(name, version, type)
18-
end
10+
super(name, version, type)
1911

2012
@options = options
2113
end
@@ -126,6 +118,10 @@ def gemfile_dep?
126118
!gemspec_dev_dep?
127119
end
128120

121+
def plugin?
122+
@plugin ||= @options.fetch("plugin", false)
123+
end
124+
129125
def current_env?
130126
return true unless env
131127
if env.is_a?(Hash)

bundler/lib/bundler/dsl.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def plugin(name, *args)
267267
version = args || [">= 0"]
268268

269269
normalize_options(name, version, options)
270-
options["type"] = :plugin
270+
options["plugin"] = true
271271
options["require"] = false
272272

273273
add_dependency(name, version, options)

bundler/lib/bundler/plugin/installer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def install_rubygems(names, version, sources)
9595
end
9696

9797
def install_all_sources(names, version, source_list, source = nil)
98-
deps = names.map {|name| Dependency.new(name, version, { "source" => source, "type" => :plugin }) }
98+
deps = names.map {|name| Dependency.new(name, version, { "source" => source, "plugin" => true }) }
9999

100100
Bundler.configure_gem_home_and_path(Plugin.root)
101101

spec/bundler/plugin_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140

141141
before do
142142
allow(index).to receive(:installed?) { nil }
143-
allow(definition).to receive(:dependencies) { [Bundler::Dependency.new("new-plugin", ">=0", "type" => :plugin), Bundler::Dependency.new("another-plugin", ">=0", "type" => :plugin)] }
143+
allow(definition).to receive(:dependencies) { [Bundler::Dependency.new("new-plugin", ">=0", "plugin" => true), Bundler::Dependency.new("another-plugin", ">=0", "plugin" => true)] }
144144
allow(installer).to receive(:install_definition) { plugin_specs }
145145
end
146146

0 commit comments

Comments
 (0)