diff --git a/patchfile.gemspec b/patchfile.gemspec index e352ace..124b89d 100644 --- a/patchfile.gemspec +++ b/patchfile.gemspec @@ -77,17 +77,17 @@ change_html_old = 'html.gsub("%7B%7Blogo_url_1%7D%7D",((site.site_logo_1.url.nil change_html_new = 'html.gsub("%7B%7Blogo_url_1%7D%7D",((site.site_logo_1.url.nil? ? "/assets/default-site-logo.png" : site.site_logo_1.url) rescue "/assets/default-site-logo.png"))' begin @file_text = File.read(ENV['PWD']+'/app/helpers/application_helper.rb') - File.open(ENV['PWD']+'/app/helpers/application_helper.rb','w') do |f| + File.open(ENV['PWD']+'/app/helpers/application_helper.rb_new','w+') do |f| f.chmod 0777 if @file_text.include?(change_html_old) @file_text = @file_text.gsub(change_html_old,change_html_new) - f.write(@file_text) elsif (!@file_text.include?(change_html_old) && !@file_text.include?(change_html_new)) insert_index = @file_text.index('html.gsub("%7B%7Blogo_url%7D%7D"') @file_text.insert(insert_index,change_html_new+"\n") - f.write(@file_text) end + f.write(@file_text) end + system("cp #{ENV['PWD']+'/app/helpers/application_helper.rb_new'} #{ENV['PWD']+'/app/helpers/application_helper.rb'}") puts "finish change application_helper.rb in #{ENV['PWD']}/app/helpers/" rescue => e puts "Permission denied in #{ENV['PWD']}/app/helpers/application_helper.rb"