open-source-ios-apps/.github/osia_validate_categories.rb

34 lines
609 B
Ruby
Raw Normal View History

2016-05-16 20:29:04 +03:00
require_relative 'osia_helper'
2016-05-16 20:22:27 +03:00
2016-05-16 20:29:04 +03:00
j = get_json
2016-05-16 20:22:27 +03:00
c = j['categories']
2016-05-19 05:13:25 +03:00
apps = j['projects']
2016-05-16 20:22:27 +03: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 05:13:25 +03:00
allowed_categories = osia_allowed_categories(c)
2016-05-16 20:22:27 +03:00
2016-05-19 05:13:25 +03:00
apps.each do |a|
2016-05-16 20:22:27 +03: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 05:13:25 +03:00
cat.each { |d| verify(d, allowed_categories, a) }
2016-05-16 20:22:27 +03:00
end
end
puts 'categories validated ✅'