diff options
author | Samuel E. Giddins <segiddins@segiddins.me> | 2015-03-21 14:48:37 -0700 |
---|---|---|
committer | Samuel E. Giddins <segiddins@segiddins.me> | 2015-03-21 14:48:37 -0700 |
commit | aef35ac138168738323b0f90a2b2d5cd9cf9a379 (patch) | |
tree | 45ca6aa8c27dbc1770278453c031b254289cfdf4 /Rakefile | |
parent | 0f2adb28025911ed9ef19b4d67bd9431ac254eef (diff) | |
download | bundler-aef35ac138168738323b0f90a2b2d5cd9cf9a379.tar.gz |
[Vendor] Dont change the load path to require vendored gemsseg-fix-thor-vendoring
Properly fixes us uses of autoload in thor
Closes #3492
Diffstat (limited to 'Rakefile')
-rw-r--r-- | Rakefile | 35 |
1 files changed, 23 insertions, 12 deletions
@@ -27,23 +27,32 @@ module Rake end end +def clean_files(files, regex, replacement = '') + files.each do |file| + contents = File.read(file) + contents.gsub!(regex, replacement) + File.open(file, 'w') { |f| f << contents } + end +end + namespace :molinillo do task :namespace do - files = Dir.glob('lib/bundler/vendor/Molinillo*/**/*.rb') - sh "sed -i.bak 's/Molinillo/Bundler::Molinillo/g' #{files.join(' ')}" - sh "rm #{files.join('.bak ')}.bak" + files = Dir.glob('lib/bundler/vendor/molinillo*/**/*.rb') + clean_files(files, 'Molinillo', 'Bundler::Molinillo') + clean_files(files, /require (["'])molinillo/, 'require \1bundler/vendor/molinillo/lib/molinillo') end task :clean do - files = Dir.glob('lib/bundler/vendor/Molinillo*/*', File::FNM_DOTMATCH).reject { |f| %(. .. lib).include? f.split('/').last } - puts files - sh "rm -r #{files.join(' ')}" + files = Dir.glob('lib/bundler/vendor/molinillo*/*', File::FNM_DOTMATCH).reject { |f| %(. .. lib).include? f.split('/').last } + rm_r files end task :update, [:tag] => [] do |t, args| tag = args[:tag] Dir.chdir 'lib/bundler/vendor' do - `curl -L https://github.com/CocoaPods/molinillo/archive/#{tag}.tar.gz | tar -xz` + rm_rf 'molinillo' + sh "curl -L https://github.com/CocoaPods/molinillo/archive/#{tag}.tar.gz | tar -xz" + sh "mv Molinillo-* molinillo" end Rake::Task['molinillo:namespace'].invoke Rake::Task['molinillo:clean'].invoke @@ -53,20 +62,22 @@ end namespace :thor do task :namespace do files = Dir.glob('lib/bundler/vendor/thor*/**/*.rb') - sh "sed -i.bak 's/Thor/Bundler::Thor/g' #{files.join(' ')}" - sh "rm #{files.join('.bak ')}.bak" + clean_files(files, 'Thor', 'Bundler::Thor') + clean_files(files, /require (["'])thor/, 'require \1bundler/vendor/thor/lib/thor') + clean_files(files, /(autoload\s+[:\w]+,\s+["'])(thor[\w\/]+["'])/, '\1bundler/vendor/thor/lib/\2') end task :clean do files = Dir.glob('lib/bundler/vendor/thor*/*', File::FNM_DOTMATCH).reject { |f| %(. .. lib).include? f.split('/').last } - puts files - sh "rm -r #{files.join(' ')}" + rm_r files end task :update, [:tag] => [] do |t, args| tag = args[:tag] Dir.chdir 'lib/bundler/vendor' do - `curl -L https://github.com/erikhuda/thor/archive/#{tag}.tar.gz | tar -xz` + rm_rf 'thor' + sh "curl -L https://github.com/erikhuda/thor/archive/#{tag}.tar.gz | tar -xz" + sh "mv thor-* thor" end Rake::Task['thor:namespace'].invoke Rake::Task['thor:clean'].invoke |