ADD init some licenses and ignores
This commit is contained in:
parent
5466b44757
commit
69bdb65ec7
|
@ -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
|
|
@ -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
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue