archive/archive.gemspec

70 lines
2.5 KiB
Ruby

$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "archive/version"
env_pwd = ENV['PWD']
app_path = File.expand_path(__dir__)
template_path = env_pwd + '/app/templates'
all_template = Dir.glob(template_path+'/*/')
all_template.each do |folder|
if !folder.include?('mobile')
begin
next unless File.exist?("#{folder}modules/archive/info.json")
info_json_file = "#{folder}modules/archive/info.json"
info_json = JSON.parse(File.read(info_json_file))
check_files = ["archive_index7","archive_index8"]
file_infos = [
{
"filename" => "archive_index7",
"name" => {
"zh_tw" => "7. 表格列表 ( 模組標題, 類別標題, 檔案名稱, 檔案簡介, 下載連結 )",
"en" => "7. Table list (widget-title, category, filename, download link)"
},
"thumbnail" => "ar5.png"
},
{
"filename" => "archive_index8",
"name" => {
"zh_tw" => "8. 表格列表 ( 模組標題, 檔案名稱, 檔案簡介, 下載連結 )",
"en" => "8. Table list (widget-title, filename, download link)"
},
"thumbnail" => "ar5.png"
}
]
flags = []
check_files.each_with_index do |check_file,i|
flag = (info_json["frontend"].select{|h| h["filename"] == check_file}.count == 0 rescue false)
if flag
info_json["frontend"].push(file_infos[i])
end
flags << flag
end
if flags.select{|flag| flag }.count != 0
puts "updating archive index page"
flags.each_with_index do |flag,i|
if flag
Bundler.with_clean_env{%x[cp -f #{app_path}/modules/archive/#{check_files[i]} #{folder}modules/archive/#{check_files[i]}]}
end
end
File.open(info_json_file,"w+"){|f| f.write(info_json.to_json)}
end
rescue
puts "There has some error when updating archive index page."
end
end
end
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "archive"
s.version = Archive::VERSION
s.authors = ["Ruling Digital"]
s.email = ["orbit@rulingcom.com"]
s.homepage = "http://www.rulingcom.com"
s.summary = "Archive module for Orbit."
s.description = "Archive module for Orbit"
s.license = "MIT"
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
s.test_files = Dir["test/**/*"]
end