From 1ab0e53a1c8088910a319d0c2a7080f1fb503be1 Mon Sep 17 00:00:00 2001 From: bohung Date: Thu, 8 Sep 2022 20:13:32 +0800 Subject: [PATCH] Fix deprecated for ruby 2.7. --- faq.gemspec | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/faq.gemspec b/faq.gemspec index c51bbf7..703b32a 100644 --- a/faq.gemspec +++ b/faq.gemspec @@ -5,6 +5,20 @@ require "faq/version" bundle_update_flag = ARGV[0]=='update' || ARGV[0]=='install' if bundle_update_flag env_pwd = ENV['PWD'] + begin + require ::File.expand_path('app/helpers/bundler_helper.rb', env_pwd) + extend BundlerHelper + rescue LoadError + def bundler_with_clean_env + if block_given? + if Bundler.respond_to?(:with_unbundled_env) + Bundler.with_unbundled_env(&Proc.new) + else + Bundler.with_clean_env(&Proc.new) + end + end + end + end app_path = File.expand_path(__dir__) template_path = env_pwd + '/app/templates' all_template = Dir.glob(template_path+'/*/') @@ -38,9 +52,9 @@ if bundle_update_flag copy_h["name"][locale] = copy_h["name"][locale].sub(/\d+/){|ff| last_index.to_s} end frontend_info << copy_h - Bundler.with_clean_env{%x[cp -f #{app_path}/modules/faq/#{h["filename"]}.html.erb #{folder}modules/faq/#{copy_h["filename"]}.html.erb]} + bundler_with_clean_env{%x[cp -f #{app_path}/modules/faq/#{h["filename"]}.html.erb #{folder}modules/faq/#{copy_h["filename"]}.html.erb]} elsif h["force_cover"] == "true" - Bundler.with_clean_env{%x[cp -f #{app_path}/modules/faq/#{h["filename"]}.html.erb #{folder}modules/faq/#{frontend_info[frontend_info_index]["filename"]}.html.erb]} + bundler_with_clean_env{%x[cp -f #{app_path}/modules/faq/#{h["filename"]}.html.erb #{folder}modules/faq/#{frontend_info[frontend_info_index]["filename"]}.html.erb]} end end if update_flag @@ -62,7 +76,7 @@ if bundle_update_flag end else if !Dir.exist?(File.dirname(info_json_file)) && Dir.exist?(File.dirname(File.dirname(info_json_file))) - Bundler.with_clean_env{system ('cp -r '+ app_path + '/modules/ ' + folder)} + bundler_with_clean_env{system ('cp -r '+ app_path + '/modules/ ' + folder)} end end end