add change bootstrap.js by code

This commit is contained in:
BOHUNG 2020-01-13 19:13:37 +08:00
parent 4620557e72
commit 25e3ae7fde
1 changed files with 20 additions and 3 deletions

View File

@ -2,19 +2,25 @@
# stub: cancerpredict 0.0.1 ruby lib # stub: cancerpredict 0.0.1 ruby lib
routes_text = File.read(ENV['PWD']+'/config/routes.rb') routes_text = File.read(ENV['PWD']+'/config/routes.rb')
insert_texts = ['get "cancerpredictResult",to: "cancerpredicts#calculate"','post "cancerpredictResult",to: "cancerpredicts#calculate"'] insert_texts = ['get "cancerpredictResult",to: "cancerpredicts#calculate"','post "cancerpredictResult",to: "cancerpredicts#calculate"']
insert_flag = 0
insert_texts.each do |insert_text| insert_texts.each do |insert_text|
if !routes_text.include?(insert_text) if !routes_text.include?(insert_text)
insert_index = routes_text.index('get "/admin/license_denied" => "store_api#render_license_denied"') insert_index = routes_text.index('get "/admin/license_denied" => "store_api#render_license_denied"')
routes_text.insert(insert_index,insert_text+"\n") routes_text.insert(insert_index,insert_text+"\n")
insert_flag = 1
end end
end end
app_path = File.expand_path(__dir__) app_path = File.expand_path(__dir__)
if insert_flag == 1
f = File.open(ENV['PWD']+'/config/routes.rb','w') f = File.open(ENV['PWD']+'/config/routes.rb','w')
f.write(routes_text) f.write(routes_text)
f.close f.close
end
template_path = ENV['PWD'] + '/app/templates' template_path = ENV['PWD'] + '/app/templates'
all_template = Dir.glob(template_path+'/*/') all_template = Dir.glob(template_path+'/*/')
puts 'copying module' 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| all_template.each do |folder|
if folder.split('/')[-1] != 'mobile' if folder.split('/')[-1] != 'mobile'
begin begin
@ -23,6 +29,17 @@ all_template.each do |folder|
puts 'error copy' puts 'error copy'
end end
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 end
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "cancerpredict" s.name = "cancerpredict"