|
68 | 68 | # |
69 | 69 | # Library path differs across implementations as `lib/ruby` on MRI and `lib/jruby` on JRuby. |
70 | 70 | GEM_PATH = ->(ruby_version, gem_name, gem_version) do |
71 | | - Dir.glob("lib/#{RbConfig::CONFIG['RUBY_INSTALL_NAME']}/#{ruby_version}/gems/#{gem_name}-#{gem_version}*").first |
| 71 | + glob = Dir.glob("lib/#{RbConfig::CONFIG['RUBY_INSTALL_NAME']}/#{ruby_version}/gems/#{gem_name}-#{gem_version}*").first |
| 72 | + alt_glob = Dir.glob("lib/#{RbConfig::CONFIG['RUBY_INSTALL_NAME']}/#{ruby_version}/bundler/gems/#{gem_name}-*").first |
| 73 | + glob || alt_glob |
72 | 74 | end |
73 | 75 |
|
74 | 76 | # For ordinary gems, this path is like 'lib/ruby/3.0.0/specifications/rspec-3.10.0.gemspec'. |
|
81 | 83 | # |
82 | 84 | # Library path differs across implementations as `lib/ruby` on MRI and `lib/jruby` on JRuby. |
83 | 85 | SPEC_PATH = ->(ruby_version, gem_name, gem_version) do |
84 | | - Dir.glob("lib/#{RbConfig::CONFIG['RUBY_INSTALL_NAME']}/#{ruby_version}/specifications/#{gem_name}-#{gem_version}*.gemspec").first |
| 86 | + glob = Dir.glob("lib/#{RbConfig::CONFIG['RUBY_INSTALL_NAME']}/#{ruby_version}/specifications/#{gem_name}-#{gem_version}*.gemspec").first |
| 87 | + alt_glob = Dir.glob("lib/#{RbConfig::CONFIG['RUBY_INSTALL_NAME']}/#{ruby_version}/bundler/gems/#{gem_name}-*/**/*.gemspec").first |
| 88 | + glob || alt_glob |
85 | 89 | end |
86 | 90 |
|
87 | 91 | HERE = File.absolute_path '.' |
@@ -193,7 +197,18 @@ def initialize(workspace_name:, |
193 | 197 | # This attribute returns 0 as the third minor version number, which happens to be |
194 | 198 | # what Ruby uses in the PATH to gems, eg. ruby 2.6.5 would have a folder called |
195 | 199 | # ruby/2.6.0/gems for all minor versions of 2.6.* |
196 | | - @ruby_version ||= (RUBY_VERSION.split('.')[0..1] << 0).join('.') |
| 200 | + @ruby_version ||= begin |
| 201 | + version_string = (RUBY_VERSION.split('.')[0..1] << 0).join('.') |
| 202 | + if File.exist?("lib/#{RbConfig::CONFIG['RUBY_INSTALL_NAME']}/#{version_string}") |
| 203 | + version_string |
| 204 | + else |
| 205 | + if File.exist?("lib/#{RbConfig::CONFIG['RUBY_INSTALL_NAME']}/#{version_string}+0") |
| 206 | + version_string + "+0" |
| 207 | + else |
| 208 | + raise "Cannot find directory named #{version_string} within lib/#{RbConfig::CONFIG['RUBY_INSTALL_NAME']}" |
| 209 | + end |
| 210 | + end |
| 211 | + end |
197 | 212 | end |
198 | 213 |
|
199 | 214 | def generate! |
|
0 commit comments