2016-05-16 19:29:04 +02:00
|
|
|
require_relative 'osia_helper'
|
2016-05-16 19:22:27 +02:00
|
|
|
|
2016-05-16 19:29:04 +02:00
|
|
|
j = get_json
|
2016-05-16 19:22:27 +02:00
|
|
|
c = j['categories']
|
2016-05-19 04:13:25 +02:00
|
|
|
apps = j['projects']
|
2016-05-16 19:22:27 +02:00
|
|
|
|
|
|
|
def failed(cat, app)
|
|
|
|
puts "‼️ #{cat} is not a valid category for #{app}"
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
|
|
|
|
def verify(cat, allowed, app)
|
|
|
|
failed(cat, app) unless allowed.include? cat
|
|
|
|
end
|
|
|
|
|
2016-05-19 04:13:25 +02:00
|
|
|
allowed_categories = osia_allowed_categories(c)
|
2016-05-16 19:22:27 +02:00
|
|
|
|
2016-05-19 04:13:25 +02:00
|
|
|
apps.each do |a|
|
2016-05-16 19:22:27 +02:00
|
|
|
cat = a['category']
|
|
|
|
|
|
|
|
if cat.nil?
|
|
|
|
puts "missing category for #{a}"
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
|
|
|
|
if cat.class == String
|
|
|
|
verify(cat, allowed_categories, a)
|
|
|
|
elsif cat.class == Array
|
2016-05-19 04:13:25 +02:00
|
|
|
cat.each { |d| verify(d, allowed_categories, a) }
|
2016-05-16 19:22:27 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
puts 'categories validated ✅'
|