1
0
mirror of https://github.com/dkhamsing/open-source-ios-apps.git synced 2025-02-26 08:37:44 +01:00

[script] Cleanup

This commit is contained in:
dkhamsing 2016-05-13 08:50:39 -07:00
parent 10d8469f95
commit 7e0cd5acf0

62
.github/convert.rb vendored
View File

@ -1,7 +1,7 @@
require 'date' require 'date'
require 'json' require 'json'
OUTPUT = 'README.md' README = 'README.md'
def output_stars(number) def output_stars(number)
case number case number
@ -83,39 +83,37 @@ def output_apps(apps)
o o
end end
c = File.read 'contents.json' def write_readme(j)
j = JSON.parse c t = j['title']
desc = j['description']
h = j['header']
f = j['footer']
cats = j['categories']
apps = j['projects']
t = j['title'] date = DateTime.now
desc = j['description'] date_display = date.strftime "%B %d, %Y"
h = j['header']
f = j['footer']
cats = j['categories']
apps = j['projects']
date = DateTime.now output = '# ' + t
date_display = date.strftime "%B %d, %Y" output << "\n\n"
output << desc
output << "\n\nA collaborative list of **#{apps.count}** open-source iOS apps, your [contribution](https://github.com/dkhamsing/open-source-ios-apps/blob/master/.github/CONTRIBUTING.md) is welcome :smile: "
output << "(last update *#{date_display}*)."
output = '# ' + t output << "\n \nJump to \n \n"
output << "\n\n"
output << desc
output << "\n\nA collaborative list of **#{apps.count}** open-source iOS apps, your [contribution](https://github.com/dkhamsing/open-source-ios-apps/blob/master/.github/CONTRIBUTING.md) is welcome :smile: "
output << "(last update *#{date_display}*)."
output << "\n \nJump to \n \n" cats.each do |c|
cats.each do |c|
temp = "#{' ' unless c['parent']==nil }- [#{c['title']}](\##{c['id']}) \n" temp = "#{' ' unless c['parent']==nil }- [#{c['title']}](\##{c['id']}) \n"
output << temp output << temp
end end
output << "- [Bonus](#bonus) \n" output << "- [Bonus](#bonus) \n"
output << "\n" output << "\n"
output << h output << h
output << "\n" output << "\n"
cats.each do |c| cats.each do |c|
temp = "\n#\##{'#' unless c['parent']==nil } #{c['title']} \n \n" temp = "\n#\##{'#' unless c['parent']==nil } #{c['title']} \n \n"
d = c['description'] d = c['description']
@ -126,10 +124,16 @@ cats.each do |c|
cat_apps = apps_for_cat(apps, c['id']) cat_apps = apps_for_cat(apps, c['id'])
output << output_apps(cat_apps) output << output_apps(cat_apps)
end
output << "\n"
output << f
File.open(README, 'w') { |f| f.write output }
puts "wrote #{README}"
end end
output << "\n" c = File.read 'contents.json'
output << f j = JSON.parse c
File.open(OUTPUT, 'w') { |f| f.write output } write_readme(j)
puts "wrote #{OUTPUT}"