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

44 lines
1.0 KiB
Ruby
Raw Normal View History

2016-06-07 16:53:14 +03:00
require_relative 'osia_helper'
2016-08-10 17:39:26 +03:00
UNIQUES = 'check-unique.txt' # should be unique
LINKS = 'check-links.txt' # allow dupes
2016-06-07 16:53:14 +03: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 17:43:32 +03:00
active = a.reject { |x| archived.include? x }
2016-06-07 16:53:14 +03:00
2016-08-10 17:39:26 +03:00
uniques = []
2016-06-07 17:43:32 +03:00
active.each do |z|
2016-08-10 17:39:26 +03:00
uniques.push z['source']
uniques.push z['itunes'] unless z['itunes'].nil?
uniques.push z['screenshots'] unless z['screenshots'].nil?
2016-06-07 17:43:32 +03:00
end
2016-08-10 17:39:26 +03:00
uniques.each_with_index { |z, i| puts "#{i+1} #{z}" }
2016-06-07 16:53:14 +03:00
2016-08-10 17:39:26 +03:00
puts "Writing #{UNIQUES}"
File.open(UNIQUES, 'w') { |f| f.puts uniques }
2016-06-08 06:05:24 +03:00
2016-08-10 17:39:26 +03:00
links = []
2016-06-08 06:05:24 +03:00
active.each do |z|
2016-08-10 17:39:26 +03: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 17:39:26 +03:00
links.push z['title']
2016-06-08 06:05:24 +03:00
end
2016-08-10 17:39:26 +03:00
links.each_with_index { |z, i| puts "#{i+1} #{z}" }
2016-06-08 06:05:24 +03:00
2016-08-10 17:39:26 +03:00
puts "Writing #{LINKS}"
File.open(LINKS, 'w') { |f| f.puts links }