1
0
mirror of https://github.com/dkhamsing/open-source-ios-apps.git synced 2025-01-18 11:54:10 +01:00

[script] Improve 😊 [ci skip]

This commit is contained in:
dkhamsing 2019-05-07 18:39:12 -07:00
parent 7444b31d55
commit 0e3aa9802e

View File

@ -11,6 +11,8 @@ LATEST = 'LATEST.md'
NOT_ENGLISH = '🌐' NOT_ENGLISH = '🌐'
ARCHIVE_TAG = 'archive' ARCHIVE_TAG = 'archive'
LATEST_NUM = 15
# Helpers # Helpers
def app_store_total(j) def app_store_total(j)
@ -57,14 +59,12 @@ def apps_for_cat(apps, id)
s.sort_by { |k, v| k['title'].downcase } s.sort_by { |k, v| k['title'].downcase }
end end
LATEST_NUM = 15 def apps_latest(apps, num)
def apps_latest(apps)
a = apps.select { |a| a['date_added'] != nil } a = apps.select { |a| a['date_added'] != nil }
.sort_by { |k, v| DateTime.parse(k['date_added']) } .sort_by { |k, v| DateTime.parse(k['date_added']) }
.reverse .reverse
a[0..LATEST_NUM - 1] a[0..num - 1]
end end
def output_apps(apps, appstoreonly) def output_apps(apps, appstoreonly)
@ -206,12 +206,12 @@ def write_archive(j)
puts "wrote #{file}" puts "wrote #{file}"
end end
def write_latest(j) def write_latest(j, num)
t = j['title'] t = j['title']
desc = "These are the #{LATEST_NUM} latest entries from the [main list](https://github.com/dkhamsing/open-source-ios-apps).\n\n" desc = "These are the #{num} latest entries from the [main list](https://github.com/dkhamsing/open-source-ios-apps).\n\n"
f = "## Contact\n\n- [github.com/dkhamsing](https://github.com/dkhamsing)\n- [twitter.com/dkhamsing](https://twitter.com/dkhamsing)\n" f = "## Contact\n\n- [github.com/dkhamsing](https://github.com/dkhamsing)\n- [twitter.com/dkhamsing](https://twitter.com/dkhamsing)\n"
apps = j["projects"] apps = j["projects"]
latest = apps_latest apps latest = apps_latest(apps, num)
output = "\# #{t} Latest\n\n" output = "\# #{t} Latest\n\n"
output << desc output << desc
@ -311,4 +311,4 @@ j = get_json
write_list(j, README) write_list(j, README)
write_archive(j) write_archive(j)
write_list(j, APPSTORE, true) write_list(j, APPSTORE, true)
write_latest(j) write_latest(j, LATEST_NUM)