diff --git a/gallery.gemspec b/gallery.gemspec index 419e85b..ce8659a 100644 --- a/gallery.gemspec +++ b/gallery.gemspec @@ -6,6 +6,20 @@ require 'json' 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+'/*/') @@ -40,9 +54,9 @@ if bundle_update_flag copy_h["name"][locale] = copy_h["name"][locale].sub(/\d+/){|ff| last_index.to_s} end widget_info << copy_h - Bundler.with_clean_env{%x[cp -f #{app_path}/modules/gallery/_#{h["filename"]}.html.erb #{folder}modules/gallery/_#{copy_h["filename"]}.html.erb]} + bundler_with_clean_env{%x[cp -f #{app_path}/modules/gallery/_#{h["filename"]}.html.erb #{folder}modules/gallery/_#{copy_h["filename"]}.html.erb]} elsif h["force_cover"] == "true" - Bundler.with_clean_env{%x[cp -f #{app_path}/modules/gallery/_#{h["filename"]}.html.erb #{folder}modules/gallery/_#{widget_info[widget_info_index]["filename"]}.html.erb]} + bundler_with_clean_env{%x[cp -f #{app_path}/modules/gallery/_#{h["filename"]}.html.erb #{folder}modules/gallery/_#{widget_info[widget_info_index]["filename"]}.html.erb]} end end if update_flag