1
0
mirror of https://github.com/dkhamsing/open-source-ios-apps.git synced 2024-12-27 00:42:43 +01:00
App-Open-Source-per-iPhone-.../.github/osia_validate_categories.rb

34 lines
609 B
Ruby
Raw Normal View History

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 ✅'