Skip to content

Commit

Permalink
Use "time ago in words" for last updated
Browse files Browse the repository at this point in the history
  • Loading branch information
sudara committed May 12, 2022
1 parent 4d07b57 commit 9e831d5
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
source 'https://rubygems.org'

gem 'octokit'

gem 'actionview'
gem 'activesupport'
35 changes: 35 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
GEM
remote: https://rubygems.org/
specs:
actionview (7.0.3)
activesupport (= 7.0.3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activesupport (7.0.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
builder (3.2.4)
concurrent-ruby (1.1.10)
crass (1.0.6)
erubi (1.10.0)
faraday (1.10.0)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
Expand All @@ -26,21 +41,41 @@ GEM
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
i18n (1.10.0)
concurrent-ruby (~> 1.0)
loofah (2.17.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
minitest (5.15.0)
multipart-post (2.1.1)
nokogiri (1.13.6-arm64-darwin)
racc (~> 1.4)
nokogiri (1.13.6-x86_64-linux)
racc (~> 1.4)
octokit (4.22.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
public_suffix (4.0.7)
racc (1.6.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.2)
loofah (~> 2.3)
ruby2_keywords (0.0.5)
sawyer (0.8.2)
addressable (>= 2.3.5)
faraday (> 0.8, < 2.0)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)

PLATFORMS
arm64-darwin-21
x86_64-linux

DEPENDENCIES
actionview
activesupport
octokit

BUNDLED WITH
Expand Down
21 changes: 18 additions & 3 deletions update_readme.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

require 'fileutils'
require 'octokit'
require 'action_view'
require 'active_support/all'
include ActionView::Helpers::DateHelper

heading = "\n| repo | description | license | ⭐️ | updated |\n"
heading += "| :--- | :--- | :---: | :---: | ---: |\n"
Expand All @@ -30,14 +33,17 @@
An [awesome list](https://github.com/topics/awesome-list) of open source [JUCE](http://github.com/juce-framework/JUCE/) libraries, plugins and utilities. Organized by category. Stats update nightly.
Something missing? [Add the url and a short description to sites.md](https://github.com/sudara/awesome-juce/edit/main/sites.md).
🟢 = updated recently. 🟠 = no commit in last year. 🔴 = no commit in the last 3 years.
Something missing? [Open a PR to sites.md with the url and a short description](https://github.com/sudara/awesome-juce/edit/main/sites.md).
I make more juce-y content over at https://melatonin.dev/blog
PREAMBLE

client = Octokit::Client.new(access_token: ENV["GITHUB_ACCESS_TOKEN"])

File.open('sites.md') do |file|
total = 0
while !(h2 = file.gets).nil? && h2.start_with?('##') do
rows = []
tempfile << "\n" << h2
Expand All @@ -52,8 +58,17 @@
begin
repo = client.repo(name_and_repo)
license = repo.license.nil? ? "" : repo.license[:spdx_id].gsub('NOASSERTION',"custom")
last_committed_at = client.commits(name_and_repo).first[:commit][:committer][:date].strftime('%b %d %Y')
table_row = "|[#{repo.name}](#{repo.html_url}) <br/> <sup>by [#{repo.owner[:login]}](#{repo.owner.html_url})</sup> | #{description.strip}| #{license}|#{repo.stargazers_count}|#{last_committed_at}|\n"
last_committed_at = client.commits(name_and_repo).first[:commit][:committer][:date]
status = case
when last_committed_at > 1.year.ago
"<sub><sup>  🟢</sup></sub>"
when last_committed_at > 3.years.ago
"<sub><sup>  🟠</sup></sub>"
else
"<sub><sup>  🔴</sup></sub>"
end
date = "#{time_ago_in_words(last_committed_at).gsub(/about|almost|over/, "")} ago"
table_row = "|[#{repo.name}](#{repo.html_url}) <br/> <sup>by [#{repo.owner[:login]}](#{repo.owner.html_url})</sup> | #{description.strip}| #{license}|#{repo.stargazers_count}|#{date}#{status}|\n"
rows << [repo.stargazers_count, table_row]
rescue Octokit::NotFound
puts "NOT FOUND OR MOVED?: #{name_and_repo}"
Expand Down

0 comments on commit 9e831d5

Please sign in to comment.