App-Open-Source-per-iPhone-.../.github/osia_get_links.rb

49 lines
1.2 KiB
Ruby
Raw Normal View History

2016-06-07 15:53:14 +02:00
require_relative 'osia_helper'
2016-08-10 16:39:26 +02:00
UNIQUES = 'check-unique.txt' # should be unique
LINKS = 'check-links.txt' # allow dupes
INFO = 'check-info.txt' # errors are allowed
2016-06-07 15:53:14 +02:00
def apps_archived(apps)
a = apps.select {|a| a['tags'] != nil }.select {|b| b['tags'].include?'archive'}
a.sort_by { |k, v| k['title'] }
end
j = get_json
a = j['projects']
archived = apps_archived a
2016-06-07 16:43:32 +02:00
active = a.reject { |x| archived.include? x }
2016-06-07 15:53:14 +02:00
2016-08-10 16:39:26 +02:00
uniques = []
info = []
2016-06-07 16:43:32 +02:00
active.each do |z|
2016-08-10 16:39:26 +02:00
uniques.push z['source']
uniques.push z['screenshots'] unless z['screenshots'].nil?
info.push z['itunes'] unless z['itunes'].nil?
2016-06-07 16:43:32 +02:00
end
2016-08-10 16:39:26 +02:00
uniques.each_with_index { |z, i| puts "#{i+1} #{z}" }
2016-06-07 15:53:14 +02:00
2016-08-10 16:39:26 +02:00
puts "Writing #{UNIQUES}"
File.open(UNIQUES, 'w') { |f| f.puts uniques }
2016-06-08 05:05:24 +02:00
puts "Writing #{INFO}"
File.open(INFO, 'w') { |f| f.puts info }
2016-08-10 16:39:26 +02:00
links = []
2016-06-08 05:05:24 +02:00
active.each do |z|
2016-08-10 16:39:26 +02:00
links.push z['homepage'] unless z['homepage'].nil?
links.push z['title'] unless z['title'].nil?
links.push z['description'] unless z['description'].nil?
end
c = j['categories']
c.each do |z|
2016-08-10 16:39:26 +02:00
links.push z['title']
2016-06-08 05:05:24 +02:00
end
2016-08-10 16:39:26 +02:00
links.each_with_index { |z, i| puts "#{i+1} #{z}" }
2016-06-08 05:05:24 +02:00
2016-08-10 16:39:26 +02:00
puts "Writing #{LINKS}"
File.open(LINKS, 'w') { |f| f.puts links }