2014-04-01 07:12:43 +00:00
|
|
|
$:.push File.expand_path("../lib", __FILE__)
|
|
|
|
|
|
|
|
# Maintain your gem's version:
|
|
|
|
require "announcement/version"
|
2020-02-17 13:50:15 +00:00
|
|
|
env_pwd = ENV['PWD']
|
2020-02-14 14:31:52 +00:00
|
|
|
app_path = File.expand_path(__dir__)
|
2020-02-17 13:50:15 +00:00
|
|
|
template_path = env_pwd + '/app/templates'
|
2020-02-14 14:31:52 +00:00
|
|
|
all_template = Dir.glob(template_path+'/*/')
|
|
|
|
puts 'editing files for sassc'
|
|
|
|
new_gemfile_text = File.read(app_path+'/temp_file/Gemfile')
|
2020-02-17 13:50:15 +00:00
|
|
|
old_gemfile_text = File.read(env_pwd+'/Gemfile')
|
2020-02-14 14:31:52 +00:00
|
|
|
check_texts = ['@import "../../bootstrap/variables";',".response-content {\n position: relative;\n\n @media (min-width: $screen-sm) {\n width: 100%;\n }\n\n @media (min-width: $screen-md) {\n width: 970px;\n }\n\n @media (min-width: $screen-lg) {\n width: 1100px;\n }\n}\n"]
|
2020-02-17 13:50:15 +00:00
|
|
|
git_url = Bundler.with_clean_env{%x[cd '#{env_pwd}' && git config --get remote.origin.url].sub("\n",'')}
|
|
|
|
git_remote = Bundler.with_clean_env{%x[cd '#{env_pwd}' && git remote].sub("\n",'')}
|
2020-02-16 03:17:52 +00:00
|
|
|
if git_url != 'https://ruling.digital/git'
|
|
|
|
puts 'changing remote url'
|
2020-02-17 13:50:15 +00:00
|
|
|
Bundler.with_clean_env{system("cd #{env_pwd} && git remote set-url #{git_remote} https://ruling.digital/git")}
|
2020-02-16 03:17:52 +00:00
|
|
|
end
|
2020-02-14 14:31:52 +00:00
|
|
|
all_template.each do |folder|
|
|
|
|
if !folder.include?('mobile')
|
|
|
|
begin
|
|
|
|
if folder.split('/')[-1] != 'mobile'
|
2020-02-17 13:50:15 +00:00
|
|
|
filename = folder+'assets/stylesheets/template/base/_variables.scss'
|
|
|
|
texts = File.read(filename)
|
2020-02-14 14:31:52 +00:00
|
|
|
check_texts.each do |check_text|
|
|
|
|
if !texts.include?(check_text)
|
|
|
|
puts "editing #{folder}assets/stylesheets/template/base/_variables.scss"
|
2020-02-17 13:50:15 +00:00
|
|
|
File.open(filename, 'a') do |file|
|
2020-02-14 14:31:52 +00:00
|
|
|
file.puts check_text
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue => e
|
|
|
|
puts "not found #{folder}assets/stylesheets/template/base/_variables.scss"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if old_gemfile_text != new_gemfile_text
|
2020-02-14 15:19:35 +00:00
|
|
|
unicorn_rails = %x[which unicorn_rails].sub("\n",'')
|
2020-02-14 14:31:52 +00:00
|
|
|
puts 'updating gemfile'
|
2020-02-17 13:50:15 +00:00
|
|
|
Bundler.with_clean_env{%x[cp -f '#{env_pwd}'/Gemfile '#{env_pwd}'/Gemfile.bak123]}
|
|
|
|
Bundler.with_clean_env{%x[cp -f '#{app_path}'/temp_file/Gemfile '#{env_pwd}'/Gemfile]}
|
|
|
|
old_playground = File.read (env_pwd+'/app/controllers/admin/playground_controller.rb') rescue ''
|
2020-02-14 14:31:52 +00:00
|
|
|
new_playground = File.read (app_path+'/temp_file/playground_controller.rb') rescue ''
|
2020-02-15 02:22:57 +00:00
|
|
|
command2 = ''
|
2020-02-14 14:31:52 +00:00
|
|
|
if old_playground != new_playground
|
|
|
|
puts 'updating playground'
|
2020-02-21 07:37:33 +00:00
|
|
|
command2 = "cp -f #{app_path}/temp_file/playground_controller.rb #{env_pwd}/app/controllers/admin/playground_controller.rb ;"
|
2020-02-15 02:22:57 +00:00
|
|
|
#File.open(ENV['PWD']+'/app/controllers/admin/playground_controller.rb', 'w') do |file|
|
|
|
|
# file.write new_playground
|
|
|
|
#end
|
2020-02-14 14:31:52 +00:00
|
|
|
end
|
2020-02-17 13:50:15 +00:00
|
|
|
old_multithread = File.read (env_pwd+'/app/models/multithread.rb') rescue ''
|
2020-02-14 14:31:52 +00:00
|
|
|
new_multithread = File.read (app_path+'/temp_file/multithread.rb') rescue ''
|
2020-02-15 02:22:57 +00:00
|
|
|
command3 = ''
|
2020-02-14 14:31:52 +00:00
|
|
|
if old_multithread != new_multithread
|
|
|
|
puts 'updating multithread'
|
2020-02-21 07:37:33 +00:00
|
|
|
command3 = "cp -f #{app_path}/temp_file/multithread.rb #{env_pwd}/app/models/multithread.rb ;"
|
2020-02-15 02:22:57 +00:00
|
|
|
#File.open(ENV['PWD']+'/app/models/multithread.rb', 'w') do |file|
|
|
|
|
# file.write new_multithread
|
|
|
|
#end
|
2020-02-14 14:31:52 +00:00
|
|
|
end
|
2020-02-17 14:29:39 +00:00
|
|
|
command4 = "cp -rf #{app_path}/temp_file/app #{env_pwd}"
|
2020-02-17 13:50:15 +00:00
|
|
|
log_development = File.mtime(env_pwd+'/log/development.log').strftime('%Y%m%d%H%M').to_i rescue 0
|
|
|
|
log_production = File.mtime(env_pwd+'/log/production.log').strftime('%Y%m%d%H%M').to_i rescue 0
|
2020-02-14 14:31:52 +00:00
|
|
|
if log_development > log_production
|
|
|
|
mode = 'development'
|
|
|
|
else
|
|
|
|
mode = 'production'
|
|
|
|
end
|
2020-02-17 13:50:15 +00:00
|
|
|
files = Dir[env_pwd+'/Gemfile.lock']
|
|
|
|
dir_name = env_pwd.split('/')[-1]
|
|
|
|
watch_dog = %x[screen -ls auto_reopen_#{dir_name}]
|
|
|
|
if watch_dog.scan("auto_reopen_#{dir_name}").count != 0
|
|
|
|
Bundler.with_clean_env{%x[screen -ls | grep auto_reopen_#{dir_name} | cut -d. -f1 | awk '{print $1}' | xargs kill]}
|
|
|
|
end
|
2020-02-14 14:31:52 +00:00
|
|
|
if files.count ==0
|
2020-02-21 08:49:10 +00:00
|
|
|
command1 = "gem install bundler -v 1.17.3 ; bundle update --force"
|
2020-02-14 14:31:52 +00:00
|
|
|
else
|
2020-02-21 08:49:10 +00:00
|
|
|
command1 = "gem install bundler -v 1.17.3 ; mv -f Gemfile.lock Gemfile.lock.bak123 ; bundle update --force"
|
2020-02-14 14:31:52 +00:00
|
|
|
end
|
2020-02-19 10:36:14 +00:00
|
|
|
filedata = File.read(env_pwd+"/built_in_extensions.rb")
|
|
|
|
exist_str = "gem 'patchfile', git: 'http://gitlab.tp.rulingcom.com/chiu/patch_file.git'"
|
|
|
|
if filedata.include? exist_str
|
|
|
|
puts "patchfile exist"
|
|
|
|
else
|
|
|
|
file = env_pwd+"/built_in_extensions.rb"
|
|
|
|
open(file, 'a') { |f|
|
|
|
|
f.puts exist_str
|
|
|
|
}
|
|
|
|
end
|
2020-02-21 08:24:39 +00:00
|
|
|
all_command = "#{command1} ; #{command2} #{command3} #{command4} ; kill -s TERM `cat tmp/pids/unicorn.pid` ; unset UNICORN_FD ; bundle exec #{unicorn_rails} -c config/unicorn.rb -D -E #{mode}|at now;"
|
|
|
|
all_command = all_command + "watch -n 30 \"unset UNICORN_FD && bundle exec #{unicorn_rails} -c config/unicorn.rb -D -E #{mode}|at now\""
|
2020-02-21 08:37:47 +00:00
|
|
|
file = File.new(File.join(env_pwd,'bundle_update_background.sh'),"w")
|
|
|
|
file.write(all_command)
|
|
|
|
file.chmod(0755)
|
|
|
|
file.close
|
2020-02-14 14:31:52 +00:00
|
|
|
a = Thread.start do
|
|
|
|
Bundler.with_clean_env do
|
2020-02-17 13:50:15 +00:00
|
|
|
puts env_pwd
|
2020-02-14 14:31:52 +00:00
|
|
|
puts mode
|
2020-02-21 08:37:47 +00:00
|
|
|
exec("cd #{env_pwd} && screen -d -m -S auto_reopen_#{dir_name} #{env_pwd}/bundle_update_background.sh ")
|
2020-02-14 14:31:52 +00:00
|
|
|
end
|
|
|
|
end
|
2020-02-15 02:22:57 +00:00
|
|
|
now_priority = Thread.current.priority.to_i
|
|
|
|
system('sleep 2')
|
|
|
|
a.priority = now_priority + 2
|
2020-02-14 14:31:52 +00:00
|
|
|
a.run
|
|
|
|
#Thread.exit
|
|
|
|
end
|
2014-04-01 07:12:43 +00:00
|
|
|
# Describe your gem and declare its dependencies:
|
|
|
|
Gem::Specification.new do |s|
|
|
|
|
s.name = "announcement"
|
|
|
|
s.version = Announcement::VERSION
|
|
|
|
s.authors = ["RulingDigital"]
|
|
|
|
s.email = ["orbit@rulingcom.com"]
|
|
|
|
s.homepage = "http://www.rulingcom.com"
|
|
|
|
s.summary = "Announcements for Orbit"
|
|
|
|
s.description = "Announcements for Orbit"
|
|
|
|
s.license = "MIT"
|
|
|
|
|
|
|
|
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
|
|
|
|
s.test_files = Dir["test/**/*"]
|
2019-10-09 08:43:37 +00:00
|
|
|
|
|
|
|
s.add_dependency "rufus-scheduler", "~> 3.6.0"
|
2014-04-01 07:12:43 +00:00
|
|
|
end
|