ADD init some licenses and ignores

This commit is contained in:
Jasder 2019-11-12 16:53:04 +08:00
parent 5466b44757
commit 69bdb65ec7
4 changed files with 98 additions and 0 deletions

20
lib/tasks/ignores.rake Normal file
View File

@ -0,0 +1,20 @@
require "json"
desc 'init ignores'
namespace :ignores do
task :init => :environment do
puts "------ init ignores start -----"
begin
file = File.read("public/ignore.json")
ignores = JSON.parse(file)
ignores.each do |json|
next if json['name'].blank?
Ignore.where(:name => json['name']).first_or_create(content: json["content"])
end
puts "------ init ignores success -----"
rescue Exception => e
puts(e.message)
puts "------ init ignores fail -----"
end
end
end

31
lib/tasks/licenses.rake Normal file
View File

@ -0,0 +1,31 @@
require "json"
desc 'init licenses '
namespace :licenses do
task :init => :environment do
puts "------ init licenses start -----"
begin
file = File.read("public/licenses.json")
licenses = JSON.parse(file)
licenses.each do |json|
next if json['name'].blank?
License.where(:name => json['name']).first_or_create do |license|
license.key = json["key"]
license.nickname = json["nickname"]
license.featured = json["featured"]
license.html_url = json["html_url"]
license.source_url = json["source_url"]
license.description = json["description"]
license.conditions = json["conditions"].join(",")
license.permissions = json["permissions"].join(",")
license.limitations = json["limitations"].join(",")
license.content = json["content"]
end
end
puts "------ init licenses success -----"
rescue Exception => e
puts(e.message)
puts "------ init licenses fail -----"
end
end
end

2
public/ignore.json Normal file

File diff suppressed because one or more lines are too long

45
public/licenses.json Normal file

File diff suppressed because one or more lines are too long