Add carrierwave migration.

This commit is contained in:
邱博亞 2024-03-27 00:09:46 +08:00
parent 5b0f05ba59
commit c99f1b9176
1 changed files with 15 additions and 0 deletions

View File

@ -300,6 +300,21 @@ if bundle_update_flag
c = YAML.dump(r).sub("---\n",'')
open("#{env_pwd}/config/mongoid.yml",'w+'){|f| f.write(c)}
end
if !File.exist?("#{env_pwd}/.carrierwave_upgraded")
upgrading = File.exist?("#{env_pwd}/.carrierwave_upgrading")
File.open("#{env_pwd}/.carrierwave_upgrading", "w") {}
uploaders = Dir.chdir(env_pwd){ Dir.glob("app/uploaders/*") }
uploaders.each do |uploader|
if upgrading
bundler_with_clean_env{%x[cd #{env_pwd} && git checkout -- #{uploader}]}
end
uploader_contents = File.read("#{env_pwd}/#{uploader}")
uploader_contents.gsub!(/^[ \t]*require[ \t]+['"]carrierwave\/processing\/mime_types['"][ \t]*$/, '')
uploader_contents.gsub!(/^[ \t]*include[ \t]+CarrierWave::MimeTypes[ \t]*$/, '')
File.open("#{env_pwd}/#{uploader}", "w"){|f| f.write(uploader_contents)}
end
File.open("#{env_pwd}/.carrierwave_upgraded", "w") {}
end
end
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|