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 +4 -4
- data/lib/uprb/require_tracker.rb +24 -1
- data/lib/uprb/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 17ee10fe8ed29c4c60bb632f03e2e57a0a7c4ffb1087131a805bb8c0ee60f50c
|
|
4
|
+
data.tar.gz: 8f2f0a5bea6df8c8441415063454a27829e7eb0eab325e39bb4dcb75e385512c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e4738b6c3b0663bca71c87fa7d9900f8718cdca3fef8d03b12d211c99b4868eb90024868f2ccbc38d1f68f6dc791979f244b56177e7e9048493bb58df8733b23
|
|
7
|
+
data.tar.gz: 97c84c60f9c6ac5e5591adb1517c35b18601c12724220853f13e6305137c1eddd00fc3105b4f913c0af0ff3a672dca7e1bd24fd0e83a35216e82cc8e21373c88
|
data/lib/uprb/require_tracker.rb
CHANGED
|
@@ -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
|
-
|
|
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