mirror of
https://github.com/dkhamsing/open-source-ios-apps.git
synced 2025-01-18 11:54:10 +01:00
[script] improve
This commit is contained in:
parent
01cd410ce3
commit
f2d3e30bf4
3
.github/osia_category_list.rb
vendored
3
.github/osia_category_list.rb
vendored
@ -3,5 +3,4 @@ require_relative 'osia_helper'
|
||||
j = get_json
|
||||
c = j['categories']
|
||||
|
||||
c.sort_by { |h| h['title']}
|
||||
.each { |x| puts x['id']}
|
||||
osia_allowed_categories(c).each { |cat| puts cat }
|
4
.github/osia_helper.rb
vendored
4
.github/osia_helper.rb
vendored
@ -5,3 +5,7 @@ FILE = 'contents.json'
|
||||
def get_json
|
||||
JSON.parse(File.read FILE)
|
||||
end
|
||||
|
||||
def osia_allowed_categories(c)
|
||||
c.sort_by { |h| h['title']}.map { |x| x['id']}
|
||||
end
|
9
.github/osia_validate_categories.rb
vendored
9
.github/osia_validate_categories.rb
vendored
@ -2,7 +2,7 @@ require_relative 'osia_helper'
|
||||
|
||||
j = get_json
|
||||
c = j['categories']
|
||||
a = j['projects']
|
||||
apps = j['projects']
|
||||
|
||||
def failed(cat, app)
|
||||
puts "‼️ #{cat} is not a valid category for #{app}"
|
||||
@ -13,13 +13,12 @@ def verify(cat, allowed, app)
|
||||
failed(cat, app) unless allowed.include? cat
|
||||
end
|
||||
|
||||
allowed_categories = c.sort_by { |h| h['title']}.map { |x| x['id']}
|
||||
allowed_categories = osia_allowed_categories(c)
|
||||
|
||||
a.each do |a|
|
||||
apps.each do |a|
|
||||
cat = a['category']
|
||||
|
||||
if cat.nil?
|
||||
# failed(cat, a)
|
||||
puts "missing category for #{a}"
|
||||
exit 1
|
||||
end
|
||||
@ -27,7 +26,7 @@ a.each do |a|
|
||||
if cat.class == String
|
||||
verify(cat, allowed_categories, a)
|
||||
elsif cat.class == Array
|
||||
cat.each { |c| verify(c, allowed_categories, a) }
|
||||
cat.each { |d| verify(d, allowed_categories, a) }
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user