uprb 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47c673bd86d084d70c17fdbf40a0b37752901835da0c7be9ca22e88a6800ea37
4
- data.tar.gz: 518ba4cfa3fe746297837a9309091e9bc00d51ea0aa72856a1a32b43d1c16c15
3
+ metadata.gz: 17ee10fe8ed29c4c60bb632f03e2e57a0a7c4ffb1087131a805bb8c0ee60f50c
4
+ data.tar.gz: 8f2f0a5bea6df8c8441415063454a27829e7eb0eab325e39bb4dcb75e385512c
5
5
  SHA512:
6
- metadata.gz: b5b3ec5ab5f74dcbc48f4ddc731f3a0ce84bfc2d3ec8a44a4189e4c45281e143492c1500f88bfd525be0ed5a7ed2cefa4e1717ba9b021001346ad13da19f9f7a
7
- data.tar.gz: 425d5e42fb25f92c8405aea0f0b22d952a379925ca5a5760587e43c35f2d2da2a6bd2fa799ae5f191d12e3e9b1f515e96e5d2561d539b2f3d13bf301177fffd0
6
+ metadata.gz: e4738b6c3b0663bca71c87fa7d9900f8718cdca3fef8d03b12d211c99b4868eb90024868f2ccbc38d1f68f6dc791979f244b56177e7e9048493bb58df8733b23
7
+ data.tar.gz: 97c84c60f9c6ac5e5591adb1517c35b18601c12724220853f13e6305137c1eddd00fc3105b4f913c0af0ff3a672dca7e1bd24fd0e83a35216e82cc8e21373c88
@@ -71,17 +71,40 @@ module Uprb
71
71
  target_name = name
72
72
  suffixes = Uprb::SUFFIXES
73
73
  end
74
+
75
+ # A suffix-only match against $LOADED_FEATURES can confuse `set` with
76
+ # an unrelated rubygems/resolver/set.rb that happened to be loaded.
77
+ # Prefer the file Ruby would resolve for the requested feature name.
78
+ unless absolute_path?(name)
79
+ $LOAD_PATH.each do |dir|
80
+ suffixes.each do |suffix|
81
+ candidate = File.join(dir, "#{target_name}#{suffix}")
82
+ return candidate if File.file?(candidate)
83
+ end
84
+ end
85
+ end
86
+
74
87
  suffixes.each do |suffix|
75
88
  pattern = /(?:\A|#{File::SEPARATOR})#{target_name}#{suffix}\z/
76
89
  # Ruby appends the parent after its nested children; search from the tail to hit it first.
77
90
  entries.reverse_each do |f|
78
- return f if pattern.match?(f)
91
+ next unless pattern.match?(f)
92
+ return f if absolute_path?(name) || resolves_from_load_path?(f, target_name, suffixes)
79
93
  end
80
94
  end
81
95
 
82
96
  nil
83
97
  end
84
98
 
99
+ def resolves_from_load_path?(path, target_name, suffixes)
100
+ expanded_path = File.expand_path(path)
101
+ $LOAD_PATH.any? do |dir|
102
+ suffixes.any? do |suffix|
103
+ expanded_path == File.expand_path("#{target_name}#{suffix}", dir)
104
+ end
105
+ end
106
+ end
107
+
85
108
  def absolute_path?(name)
86
109
  name.start_with?(File::SEPARATOR) ||
87
110
  (File::ALT_SEPARATOR && name.start_with?(File::ALT_SEPARATOR))
data/lib/uprb/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uprb
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uprb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - hogelog