Skip to content

Commit 20f57c5

Browse files
deivid-rodriguezhsbt
authored andcommitted
[rubygems/rubygems] Refactor Path vs Gemspec source comparison
ruby/rubygems@58e9bd9962
1 parent 765da72 commit 20f57c5

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

lib/bundler/definition.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ def converge_paths
906906

907907
def converge_path_source_to_gemspec_source(source)
908908
return source unless source.instance_of?(Source::Path)
909-
gemspec_source = sources.path_sources.find {|s| s.is_a?(Source::Gemspec) && s.as_path_source == source }
909+
gemspec_source = sources.path_sources.find {|s| s == source }
910910
gemspec_source || source
911911
end
912912

lib/bundler/plugin/installer/path.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ def root
88
SharedHelpers.in_bundle? ? Bundler.root : Plugin.root
99
end
1010

11+
def eql?(other)
12+
return unless other.class == self.class
13+
expanded_original_path == other.expanded_original_path &&
14+
version == other.version
15+
end
16+
17+
alias_method :==, :eql?
18+
1119
def generate_bin(spec, disable_extensions = false)
1220
# Need to find a way without code duplication
1321
# For now, we can ignore this

lib/bundler/source/gemspec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ def initialize(options)
99
super
1010
@gemspec = options["gemspec"]
1111
end
12-
13-
def as_path_source
14-
Path.new(options)
15-
end
1612
end
1713
end
1814
end

lib/bundler/source/path.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def hash
6060
end
6161

6262
def eql?(other)
63-
return unless other.class == self.class
64-
expanded_original_path == other.expanded_original_path &&
63+
[Gemspec, Path].include?(other.class) &&
64+
expanded_original_path == other.expanded_original_path &&
6565
version == other.version
6666
end
6767

lib/bundler/source_list.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def map_sources(replacement_sources)
183183
end
184184

185185
path = @path_sources.map do |source|
186-
replacement_sources.find {|s| s == (source.is_a?(Source::Gemspec) ? source.as_path_source : source) } || source
186+
replace_source(replacement_sources, source)
187187
end
188188

189189
[rubygems, path, git, plugin]

0 commit comments

Comments
 (0)