From 25e3ae7fdea83e9f4eeb5505412cabf9393f58a2 Mon Sep 17 00:00:00 2001 From: BOHUNG Date: Mon, 13 Jan 2020 19:13:37 +0800 Subject: [PATCH] add change bootstrap.js by code --- cancerpredict.gemspec | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/cancerpredict.gemspec b/cancerpredict.gemspec index dca7c07..9e89829 100644 --- a/cancerpredict.gemspec +++ b/cancerpredict.gemspec @@ -2,19 +2,25 @@ # stub: cancerpredict 0.0.1 ruby lib routes_text = File.read(ENV['PWD']+'/config/routes.rb') insert_texts = ['get "cancerpredictResult",to: "cancerpredicts#calculate"','post "cancerpredictResult",to: "cancerpredicts#calculate"'] +insert_flag = 0 insert_texts.each do |insert_text| if !routes_text.include?(insert_text) insert_index = routes_text.index('get "/admin/license_denied" => "store_api#render_license_denied"') routes_text.insert(insert_index,insert_text+"\n") + insert_flag = 1 end end app_path = File.expand_path(__dir__) -f = File.open(ENV['PWD']+'/config/routes.rb','w') -f.write(routes_text) -f.close +if insert_flag == 1 + f = File.open(ENV['PWD']+'/config/routes.rb','w') + f.write(routes_text) + f.close +end template_path = ENV['PWD'] + '/app/templates' all_template = Dir.glob(template_path+'/*/') puts 'copying module' +check_texts = '<%= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/js/bootstrap.min.js"%>' +edit_texts = '<%= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"%>' all_template.each do |folder| if folder.split('/')[-1] != 'mobile' begin @@ -23,6 +29,17 @@ all_template.each do |folder| puts 'error copy' end end + texts = File.read(folder+'/partial/_head.html.erb') + insert_flag = 0 + if texts.include?(check_texts) + texts.gsub(check_texts,edit_texts) + insert_flag = 1 + end + if insert_flag == 1 + f = File.open(folder+'/partial/_head.html.erb','w') + f.write(texts) + f.close + end end Gem::Specification.new do |s| s.name = "cancerpredict"