require "diamonds/version" require "fileutils" module Diamonds this_file_is_call_by=$0 folder_caller_file=File.dirname(this_file_is_call_by) current_file=__FILE__ current_folder=File.dirname(current_file) file_to_save="" File.open(this_file_is_call_by).each do |line| if (line.include? "require") if (line.include? "diamonds") #We do not copy the line else if (line.include? "/") #it's a local gem require we copy the file and keep the require line= line.gsub("require","").gsub("'","").gsub('"',"").gsub("\n","").lstrip filename=line.sub("./","/") filename=folder_caller_file+filename filename= filename+".rb" filecontent=File.read(filename) line=line.sub("./","/") newfilename=current_folder+"/diamonds/user_app"+line+".rb" line='require "./user_app'+line+'"' dir_found= newfilename.split("/") dir_found.pop dir_found=dir_found.join("/") FileUtils::mkdir_p dir_found File.write(newfilename, filecontent) # on sauve la ligne file_to_save=file_to_save+line+"\n" else #it's a online gem require we add the line file_to_save=file_to_save+line end end else file_to_save=file_to_save+line end end File.write(current_folder+'/diamonds/user_app/main.rb', file_to_save) File.write(current_folder+'/diamonds/user_app/ID_Repository.txt', "0") File.write(current_folder+'/diamonds/apps/user_app.rb', "") exec "cd #{File.expand_path(current_folder)}/diamonds/;bundle install;bundle exec rackup -p9292 -o 0.0.0.0 -E production -q -s thin" # exec "cd #{File.expand_path(current_folder)}/diamonds/;bundle exec rackup -p9292 -o 0.0.0.0 -E production -q -s thin" end