[script] Cleanup

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

100
.github/convert.rb vendored
View File

@ -1,7 +1,7 @@
require 'date'
require 'json'
OUTPUT = 'README.md'
README = 'README.md'
def output_stars(number)
case number
@ -83,53 +83,57 @@ def output_apps(apps)
o
end
def write_readme(j)
t = j['title']
desc = j['description']
h = j['header']
f = j['footer']
cats = j['categories']
apps = j['projects']
date = DateTime.now
date_display = date.strftime "%B %d, %Y"
output = '# ' + t
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|
temp = "#{' ' unless c['parent']==nil }- [#{c['title']}](\##{c['id']}) \n"
output << temp
end
output << "- [Bonus](#bonus) \n"
output << "\n"
output << h
output << "\n"
cats.each do |c|
temp = "\n#\##{'#' unless c['parent']==nil } #{c['title']} \n \n"
d = c['description']
temp << "#{d}" unless d.nil?
temp << "[back to top](#readme) \n \n"
output << temp
cat_apps = apps_for_cat(apps, c['id'])
output << output_apps(cat_apps)
end
output << "\n"
output << f
File.open(README, 'w') { |f| f.write output }
puts "wrote #{README}"
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']
date = DateTime.now
date_display = date.strftime "%B %d, %Y"
output = '# ' + t
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|
temp = "#{' ' unless c['parent']==nil }- [#{c['title']}](\##{c['id']}) \n"
output << temp
end
output << "- [Bonus](#bonus) \n"
output << "\n"
output << h
output << "\n"
cats.each do |c|
temp = "\n#\##{'#' unless c['parent']==nil } #{c['title']} \n \n"
d = c['description']
temp << "#{d}" unless d.nil?
temp << "[back to top](#readme) \n \n"
output << temp
cat_apps = apps_for_cat(apps, c['id'])
output << output_apps(cat_apps)
end
output << "\n"
output << f
File.open(OUTPUT, 'w') { |f| f.write output }
puts "wrote #{OUTPUT}"
write_readme(j)