1
0
mirror of https://github.com/dkhamsing/open-source-ios-apps.git synced 2024-12-22 21:38:44 +01:00

[script] Create

This commit is contained in:
dkhamsing 2016-05-11 07:22:10 -07:00
parent 760afceba7
commit 36b8174a3d
2 changed files with 124 additions and 0 deletions

110
convert.rb Normal file
View File

@ -0,0 +1,110 @@
require 'json'
OUTPUT = 'README.md'
def output_stars(number)
case number
when 100...200
'🔥'
when 200...500
'🔥🔥'
when 500...1000
'🔥🔥🔥'
when 1000...2000
'🔥🔥🔥🔥'
when 2000...100000
'🔥🔥🔥🔥🔥'
end
end
def output_flag(lang)
case lang
when 'jpn'
'🇯🇵'
when 'ltz'
'🇱🇺'
when 'por'
'🇧🇷'
when 'spa'
'🇪🇸'
when 'zho'
'🇨🇳'
end
end
def apps_for_cat(apps, id)
o = ''
apps.select { |a| a['category'] == id }.each do |a|
name = a['title']
link = a['source']
itunes = a['itunes']
desc = a['description']
tags = a['tags']
stars = a['stars']
lang = a['lang']
o << "- #{name}"
if desc.nil?
o << ' '
else
o << ": #{desc} " if desc.size>0
end
unless tags.nil?
o << "🔶" if tags.include? 'swift'
end
unless lang.nil?
o << output_flag(lang)
end
unless stars.nil?
o << output_stars(stars)
end
o << "\n"
o << " - #{link}\n"
o << " - #{itunes}\n" unless itunes.nil?
end
o
end
c = File.read 'contents.json'
j = JSON.parse c
t = j['title']
desc = j['description']
h = j['header']
f = j['footer']
cats = j['categories']
apps = j['projects']
output = '# ' + t
output << "\n\n"
output << desc
output << "\n \nJump to \n \n"
cats.each do |c|
temp = "#{' ' unless c['parent']==nil }- [#{c['title']}](\##{c['id']}) \n"
output << temp
end
output << "- [Bonus](#bonus)"
output << "\n \n"
output << h
output << "\n"
cats.each do |c|
temp = "\n#\##{'#' unless c['parent']==nil } #{c['title']} \n \n"
output << temp
output << apps_for_cat(apps, c['id'])
end
output << "\n"
output << f
File.open(OUTPUT, 'w') { |f| f.write output }
puts "wrote #{OUTPUT}"

14
deploy.sh Normal file
View File

@ -0,0 +1,14 @@
#!/bin/bash
set -e
git config user.name "Travis CI"
git config user.email "dkhamsing@users.noreply.github.com"
git checkout master
git add README.md
git commit -m "[auto] [ci skip] Generate README"
git push --quiet "https://${GH_TOKEN}@github.com/dkhamsing/open-source-ios-apps" master:master > /dev/null 2>&1