From 295c594621dadb604ad4c07471300b99a58989cc Mon Sep 17 00:00:00 2001 From: BOHUNG Date: Wed, 1 Apr 2020 17:04:41 +0800 Subject: [PATCH] test --- patchfile.gemspec | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/patchfile.gemspec b/patchfile.gemspec index 5631830..b428113 100644 --- a/patchfile.gemspec +++ b/patchfile.gemspec @@ -73,6 +73,24 @@ all_template.each do |folder| end end end +change_html_old = '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.pngs"))' +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') + f = File.open(ENV['PWD']+'/app/helpers/application_helper.rb','w') + 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.close + puts "finish change application_helper.rb in #{ENV['PWD']}/app/helpers/" +rescue + puts "Permission denied in #{ENV['PWD']}/app/helpers/application_helper.rb" +end # Describe your gem and declare its dependencies: Gem::Specification.new do |s| s.name = "patchfile"